Skip to contentSkip to conversation

examples/flow_classify: fix fseek error handling

PATCH Applied Bernard Iremonger 3 participants 3 messages Nov 1, 2017 – Nov 7, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/flow_classify: fix fseek error handling

Check return value of fseek and exit if non zero.

Coverity issue: 143435

Fixes bab16ddaf2c1 ("examples/flow_classify: add sample application")
---
 examples/flow_classify/flow_classify.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
examples/flow_classify/flow_classify.c +6 -2
index e4cabdb..766f1dd 100644
@@ -657,13 +657,17 @@ static __attribute__((noreturn)) void
 	unsigned int i = 0;
 	unsigned int total_num = 0;
 	struct rte_eth_ntuple_filter ntuple_filter;
+	int ret;
 
 	fh = fopen(rule_path, "rb");
 	if (fh == NULL)
-		rte_exit(EXIT_FAILURE, "%s: Open %s failed\n", __func__,
+		rte_exit(EXIT_FAILURE, "%s: fopen %s failed\n", __func__,
 			rule_path);
 
-	fseek(fh, 0, SEEK_SET);
+	ret = fseek(fh, 0, SEEK_SET);
+	if (ret)
+		rte_exit(EXIT_FAILURE, "%s: fseek %d failed\n", __func__,
+			ret);
 
 	i = 0;
 	while (fgets(buff, LINE_MAX, fh) != NULL) {
Signature · 1 line
1.9.1
Acked-by on v1 1/1
#1 lore raw
Quoted 45 lines

-----Original Message-----
From: Iremonger, Bernard
Sent: Wednesday, November 1, 2017 12:10 PM
To: [email protected]; Singh, Jasvinder <[email protected]>
Cc: Iremonger, Bernard <[email protected]>
Subject: [PATCH] examples/flow_classify: fix fseek error handling

Check return value of fseek and exit if non zero.

Coverity issue: 143435

Fixes bab16ddaf2c1 ("examples/flow_classify: add sample application")
---
 examples/flow_classify/flow_classify.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
examples/flow_classify/flow_classify.c +6 -3
index e4cabdb..766f1dd 100644
@@ -657,13 +657,17 @@ static __attribute__((noreturn)) void
 	unsigned int i = 0;
 	unsigned int total_num = 0;
 	struct rte_eth_ntuple_filter ntuple_filter;
+	int ret;
 
 	fh = fopen(rule_path, "rb");
 	if (fh == NULL)
-		rte_exit(EXIT_FAILURE, "%s: Open %s failed\n", __func__,
+		rte_exit(EXIT_FAILURE, "%s: fopen %s failed\n", __func__,
 			rule_path);
 
-	fseek(fh, 0, SEEK_SET);
+	ret = fseek(fh, 0, SEEK_SET);
+	if (ret)
+		rte_exit(EXIT_FAILURE, "%s: fseek %d failed\n", __func__,
+			ret);
 
 	i = 0;
 	while (fgets(buff, LINE_MAX, fh) != NULL) {
--
Quoted 1 line

1.9.1

Applied
#2 lore raw
Quoted 9 lines · Jasvinder
Quoted 9 lines

-----Original Message-----
From: Iremonger, Bernard
Sent: Wednesday, November 1, 2017 12:10 PM
To: [email protected]; Singh, Jasvinder <[email protected]>
Cc: Iremonger, Bernard <[email protected]>
Subject: [PATCH] examples/flow_classify: fix fseek error handling

Quoted 8 lines
Quoted 6 lines

Check return value of fseek and exit if non zero.

Coverity issue: 143435

Fixes bab16ddaf2c1 ("examples/flow_classify: add sample application")

Applied to dpdk-next-net/master, thanks.