* [dpdk-dev] [PATCH] examples/ntb: fix error handling
@ 2019-08-05 5:03 Xiaoyun Li
2019-08-05 5:57 ` [dpdk-dev] [PATCH v2] " Xiaoyun Li
2019-08-05 6:04 ` [dpdk-dev] [PATCH] " Ye Xiaolong
0 siblings, 2 replies; 6+ messages in thread
From: Xiaoyun Li @ 2019-08-05 5:03 UTC (permalink / raw)
To: jingjing.wu; +Cc: dev, Xiaoyun Li, stable
This patch adds return value checking for fseek function to fix
error handling issue found by coverity scan.
Coverity issue: 344996
Fixes: c5eebf85badc ("examples/ntb: add example for NTB")
Cc: stable@dpdk.org
Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
---
examples/ntb/ntb_fwd.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c
index c169f01a3..671b13f50 100644
--- a/examples/ntb/ntb_fwd.c
+++ b/examples/ntb/ntb_fwd.c
@@ -107,6 +107,7 @@ cmd_sendfile_parsed(void *parsed_result,
uint8_t *buff;
uint32_t val;
FILE *file;
+ int status;
if (!rte_rawdevs[dev_id].started) {
printf("Device needs to be up first. Try later.\n");
@@ -125,9 +126,17 @@ cmd_sendfile_parsed(void *parsed_result,
return;
}
- fseek(file, 0, SEEK_END);
+ status = fseek(file, 0, SEEK_END);
+ if (status) {
+ printf("Fail to get file size.\n");
+ return;
+ }
size = ftell(file);
- fseek(file, 0, SEEK_SET);
+ status = fseek(file, 0, SEEK_SET);
+ if (status) {
+ printf("Fail to get file size.\n");
+ return;
+ }
/**
* No FIFO now. Only test memory. Limit sending file
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v2] examples/ntb: fix error handling
2019-08-05 5:03 [dpdk-dev] [PATCH] examples/ntb: fix error handling Xiaoyun Li
@ 2019-08-05 5:57 ` Xiaoyun Li
2019-08-06 7:45 ` Ye Xiaolong
2019-08-05 6:04 ` [dpdk-dev] [PATCH] " Ye Xiaolong
1 sibling, 1 reply; 6+ messages in thread
From: Xiaoyun Li @ 2019-08-05 5:57 UTC (permalink / raw)
To: jingjing.wu; +Cc: dev, Xiaoyun Li, stable
This patch adds return value checking for fseek function to fix
error handling issue found by coverity scan.
Coverity issue: 344996
Fixes: c5eebf85badc ("examples/ntb: add example for NTB")
Cc: stable@dpdk.org
Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
---
examples/ntb/ntb_fwd.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c
index c169f01a3..f8c970cdb 100644
--- a/examples/ntb/ntb_fwd.c
+++ b/examples/ntb/ntb_fwd.c
@@ -125,9 +125,15 @@ cmd_sendfile_parsed(void *parsed_result,
return;
}
- fseek(file, 0, SEEK_END);
+ if (fseek(file, 0, SEEK_END) < 0) {
+ printf("Fail to get file size.\n");
+ return;
+ }
size = ftell(file);
- fseek(file, 0, SEEK_SET);
+ if (fseek(file, 0, SEEK_SET) < 0) {
+ printf("Fail to get file size.\n");
+ return;
+ }
/**
* No FIFO now. Only test memory. Limit sending file
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] examples/ntb: fix error handling
2019-08-05 5:03 [dpdk-dev] [PATCH] examples/ntb: fix error handling Xiaoyun Li
2019-08-05 5:57 ` [dpdk-dev] [PATCH v2] " Xiaoyun Li
@ 2019-08-05 6:04 ` Ye Xiaolong
2019-08-05 6:19 ` Li, Xiaoyun
1 sibling, 1 reply; 6+ messages in thread
From: Ye Xiaolong @ 2019-08-05 6:04 UTC (permalink / raw)
To: Xiaoyun Li; +Cc: jingjing.wu, dev, stable
On 08/05, Xiaoyun Li wrote:
>This patch adds return value checking for fseek function to fix
>error handling issue found by coverity scan.
>
>Coverity issue: 344996
>Fixes: c5eebf85badc ("examples/ntb: add example for NTB")
>Cc: stable@dpdk.org
>
>Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
>---
> examples/ntb/ntb_fwd.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
>diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c
>index c169f01a3..671b13f50 100644
>--- a/examples/ntb/ntb_fwd.c
>+++ b/examples/ntb/ntb_fwd.c
>@@ -107,6 +107,7 @@ cmd_sendfile_parsed(void *parsed_result,
> uint8_t *buff;
> uint32_t val;
> FILE *file;
>+ int status;
>
> if (!rte_rawdevs[dev_id].started) {
> printf("Device needs to be up first. Try later.\n");
>@@ -125,9 +126,17 @@ cmd_sendfile_parsed(void *parsed_result,
> return;
> }
>
>- fseek(file, 0, SEEK_END);
>+ status = fseek(file, 0, SEEK_END);
>+ if (status) {
How about simplify to
if (fseek(file, 0, SEEK_END) < 0)
>+ printf("Fail to get file size.\n");
>+ return;
>+ }
> size = ftell(file);
>- fseek(file, 0, SEEK_SET);
>+ status = fseek(file, 0, SEEK_SET);
>+ if (status) {
Ditto.
Thanks,
Xiaolong
>+ printf("Fail to get file size.\n");
>+ return;
>+ }
>
> /**
> * No FIFO now. Only test memory. Limit sending file
>--
>2.17.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] examples/ntb: fix error handling
2019-08-05 6:04 ` [dpdk-dev] [PATCH] " Ye Xiaolong
@ 2019-08-05 6:19 ` Li, Xiaoyun
0 siblings, 0 replies; 6+ messages in thread
From: Li, Xiaoyun @ 2019-08-05 6:19 UTC (permalink / raw)
To: Ye, Xiaolong; +Cc: Wu, Jingjing, dev, stable
Sure. Will update in v2. Thx.
> -----Original Message-----
> From: Ye, Xiaolong
> Sent: Monday, August 5, 2019 14:05
> To: Li, Xiaoyun <xiaoyun.li@intel.com>
> Cc: Wu, Jingjing <jingjing.wu@intel.com>; dev@dpdk.org; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] examples/ntb: fix error handling
>
> On 08/05, Xiaoyun Li wrote:
> >This patch adds return value checking for fseek function to fix error
> >handling issue found by coverity scan.
> >
> >Coverity issue: 344996
> >Fixes: c5eebf85badc ("examples/ntb: add example for NTB")
> >Cc: stable@dpdk.org
> >
> >Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
> >---
> > examples/ntb/ntb_fwd.c | 13 +++++++++++--
> > 1 file changed, 11 insertions(+), 2 deletions(-)
> >
> >diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c index
> >c169f01a3..671b13f50 100644
> >--- a/examples/ntb/ntb_fwd.c
> >+++ b/examples/ntb/ntb_fwd.c
> >@@ -107,6 +107,7 @@ cmd_sendfile_parsed(void *parsed_result,
> > uint8_t *buff;
> > uint32_t val;
> > FILE *file;
> >+ int status;
> >
> > if (!rte_rawdevs[dev_id].started) {
> > printf("Device needs to be up first. Try later.\n"); @@ -125,9
> >+126,17 @@ cmd_sendfile_parsed(void *parsed_result,
> > return;
> > }
> >
> >- fseek(file, 0, SEEK_END);
> >+ status = fseek(file, 0, SEEK_END);
> >+ if (status) {
>
> How about simplify to
>
> if (fseek(file, 0, SEEK_END) < 0)
>
> >+ printf("Fail to get file size.\n");
> >+ return;
> >+ }
> > size = ftell(file);
> >- fseek(file, 0, SEEK_SET);
> >+ status = fseek(file, 0, SEEK_SET);
> >+ if (status) {
>
> Ditto.
>
> Thanks,
> Xiaolong
> >+ printf("Fail to get file size.\n");
> >+ return;
> >+ }
> >
> > /**
> > * No FIFO now. Only test memory. Limit sending file
> >--
> >2.17.1
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v2] examples/ntb: fix error handling
2019-08-05 5:57 ` [dpdk-dev] [PATCH v2] " Xiaoyun Li
@ 2019-08-06 7:45 ` Ye Xiaolong
2019-08-06 8:33 ` Thomas Monjalon
0 siblings, 1 reply; 6+ messages in thread
From: Ye Xiaolong @ 2019-08-06 7:45 UTC (permalink / raw)
To: Xiaoyun Li; +Cc: jingjing.wu, dev, stable
On 08/05, Xiaoyun Li wrote:
>This patch adds return value checking for fseek function to fix
>error handling issue found by coverity scan.
>
>Coverity issue: 344996
>Fixes: c5eebf85badc ("examples/ntb: add example for NTB")
>Cc: stable@dpdk.org
>
>Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
>---
> examples/ntb/ntb_fwd.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
>diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c
>index c169f01a3..f8c970cdb 100644
>--- a/examples/ntb/ntb_fwd.c
>+++ b/examples/ntb/ntb_fwd.c
>@@ -125,9 +125,15 @@ cmd_sendfile_parsed(void *parsed_result,
> return;
> }
>
>- fseek(file, 0, SEEK_END);
>+ if (fseek(file, 0, SEEK_END) < 0) {
>+ printf("Fail to get file size.\n");
>+ return;
>+ }
> size = ftell(file);
>- fseek(file, 0, SEEK_SET);
>+ if (fseek(file, 0, SEEK_SET) < 0) {
>+ printf("Fail to get file size.\n");
>+ return;
>+ }
>
> /**
> * No FIFO now. Only test memory. Limit sending file
>--
>2.17.1
>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v2] examples/ntb: fix error handling
2019-08-06 7:45 ` Ye Xiaolong
@ 2019-08-06 8:33 ` Thomas Monjalon
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2019-08-06 8:33 UTC (permalink / raw)
To: Xiaoyun Li; +Cc: dev, Ye Xiaolong, jingjing.wu, stable
06/08/2019 09:45, Ye Xiaolong:
> On 08/05, Xiaoyun Li wrote:
> >This patch adds return value checking for fseek function to fix
> >error handling issue found by coverity scan.
> >
> >Coverity issue: 344996
> >Fixes: c5eebf85badc ("examples/ntb: add example for NTB")
> >Cc: stable@dpdk.org
> >
> >Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
>
> Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-08-06 8:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-05 5:03 [dpdk-dev] [PATCH] examples/ntb: fix error handling Xiaoyun Li
2019-08-05 5:57 ` [dpdk-dev] [PATCH v2] " Xiaoyun Li
2019-08-06 7:45 ` Ye Xiaolong
2019-08-06 8:33 ` Thomas Monjalon
2019-08-05 6:04 ` [dpdk-dev] [PATCH] " Ye Xiaolong
2019-08-05 6:19 ` Li, Xiaoyun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).