examples/ntb: fix error handling
authorXiaoyun Li <xiaoyun.li@intel.com>
Mon, 5 Aug 2019 05:57:28 +0000 (13:57 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 6 Aug 2019 08:40:54 +0000 (10:40 +0200)
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>
examples/ntb/ntb_fwd.c

index c169f01..f8c970c 100644 (file)
@@ -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