From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 21B80A00E6 for ; Mon, 5 Aug 2019 08:05:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4FCF41BE3B; Mon, 5 Aug 2019 08:05:15 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id AF2331B959; Mon, 5 Aug 2019 08:05:13 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Aug 2019 23:05:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,348,1559545200"; d="scan'208";a="373600929" Received: from yexl-server.sh.intel.com (HELO localhost) ([10.67.117.5]) by fmsmga006.fm.intel.com with ESMTP; 04 Aug 2019 23:05:11 -0700 Date: Mon, 5 Aug 2019 14:04:47 +0800 From: Ye Xiaolong To: Xiaoyun Li Cc: jingjing.wu@intel.com, dev@dpdk.org, stable@dpdk.org Message-ID: <20190805060447.GG51603@intel.com> References: <20190805050313.28719-1-xiaoyun.li@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190805050313.28719-1-xiaoyun.li@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH] examples/ntb: fix error handling X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 >--- > 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 >