examples/ntb: fix error handling
PATCH 1/1 examples/ntb: fix error handling
This patch adds return value checking for fseek function to fix error handling issue found by coverity scan.
Coverity issue: 344996
--- examples/ntb/ntb_fwd.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
examples/ntb/ntb_fwd.c +11 -2
@@ -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
Signature · 1 line
2.17.1
Quoted 25 lines · Xiaoyun Li
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")Signed-off-by Xiaoyun Li <[email protected]>---
examples/ntb/ntb_fwd.c| 13 +++++++++++--1 file changed, 11 insertions(+), 2 deletions(-)examples/ntb/ntb_fwd.c +1
-0@@ -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" );
examples/ntb/ntb_fwd.c cmd_sendfile_parsed(void *parsed_result, · line 130
Quoted 6 lines
examples/ntb/ntb_fwd.c +2
-1@@ -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)
examples/ntb/ntb_fwd.c cmd_sendfile_parsed(void *parsed_result, · line 136
Quoted 7 lines
examples/ntb/ntb_fwd.c +5
-1+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
Quoted 9 lines
examples/ntb/ntb_fwd.c +3
-0+printf ("Fail to get file size.\n" ); +return ; + }/** * No FIFO now. Only test memory. Limit sending file Signature · 1 line
2.17.1
Sure. Will update in v2. Thx.
Quoted 65 lines
-----Original Message-----
From: Ye, Xiaolong
Sent: Monday, August 5, 2019 14:05
To: Li, Xiaoyun <[email protected]>
Cc: Wu, Jingjing <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH] examples/ntb: fix error handlingQuoted 28 lines · Xiaoyun Li
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")Signed-off-by Xiaoyun Li <[email protected]>---
examples/ntb/ntb_fwd.c| 13 +++++++++++--1 file changed, 11 insertions(+), 2 deletions(-)examples/ntb/ntb_fwd.c index renamed from examples/ntb/ntb_fwd.c +0
-0
c169f01a3..671b13f50100644examples/ntb/ntb_fwd.c +2
-0@@ -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; }examples/ntb/ntb_fwd.c cmd_sendfile_parsed(void *parsed_result, · line 130
Quoted 3 lines
examples/ntb/ntb_fwd.c +2
-1-fseek (file,0 ,SEEK_END ); + status =fseek (file,0 ,SEEK_END ); +if (status) {How about simplify to
if (fseek(file, 0, SEEK_END) < 0)examples/ntb/ntb_fwd.c cmd_sendfile_parsed(void *parsed_result, · line 136
Quoted 7 lines
examples/ntb/ntb_fwd.c +3
-0+printf ("Fail to get file size.\n" ); +return ; + }size = ftell(file);examples/ntb/ntb_fwd.c +2
-1-fseek (file,0 ,SEEK_SET ); + status =fseek (file,0 ,SEEK_SET ); +if (status) {Ditto.
Thanks,
XiaolongQuoted 9 lines
examples/ntb/ntb_fwd.c +3
-0+printf ("Fail to get file size.\n" ); +return ; + }/** * No FIFO now. Only test memory. Limit sending file--
2.17.1
PATCH v2 1/1 examples/ntb: fix error handling
In reply to Xiaoyun LiThis patch adds return value checking for fseek function to fix error handling issue found by coverity scan.
Coverity issue: 344996
--- examples/ntb/ntb_fwd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
examples/ntb/ntb_fwd.c +8 -2
@@ -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
Signature · 1 line
2.17.1
Quoted 37 lines · Xiaoyun Li
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")Signed-off-by Xiaoyun Li <[email protected]>---
examples/ntb/ntb_fwd.c| 10 ++++++++--1 file changed, 8 insertions(+), 2 deletions(-)examples/ntb/ntb_fwd.c +8
-2@@ -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 Signature · 1 line
2.17.1
Thomas Monjalon
Applied06/08/2019 09:45, Ye Xiaolong:
Quoted 11 lines · Xiaoyun Li
Quoted 8 lines
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")Signed-off-by Xiaoyun Li <[email protected]>Reviewed-by Xiaolong Ye <[email protected]>
Applied, thanks