From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 1C4FE2C32 for ; Tue, 28 Jun 2016 11:52:07 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 28 Jun 2016 02:52:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,540,1459839600"; d="scan'208";a="1006567879" Received: from irsmsx109.ger.corp.intel.com ([163.33.3.23]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2016 02:52:05 -0700 Received: from irsmsx107.ger.corp.intel.com ([169.254.10.96]) by IRSMSX109.ger.corp.intel.com ([169.254.13.193]) with mapi id 14.03.0248.002; Tue, 28 Jun 2016 10:49:36 +0100 From: "Mrzyglod, DanielX T" To: Olivier Matz , "dev@dpdk.org" Thread-Topic: [PATCH] cmdline: fix unchecked return value Thread-Index: AQHRlkUcqnaDB48l60KMvUqIVGnNuZ+lsiEAgFlko4A= Date: Tue, 28 Jun 2016 09:49:36 +0000 Message-ID: <7ADD74816B4C8A45B56203CBA65FE5A63779734C@IRSMSX107.ger.corp.intel.com> References: <1460638879-45680-1-git-send-email-danielx.t.mrzyglod@intel.com> <57275802.7090606@6wind.com> In-Reply-To: <57275802.7090606@6wind.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] cmdline: fix unchecked return value X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jun 2016 09:52:08 -0000 >From: Olivier Matz [mailto:olivier.matz@6wind.com] >Sent: Monday, May 02, 2016 3:37 PM >To: Mrzyglod, DanielX T ; dev@dpdk.org >Subject: Re: [PATCH] cmdline: fix unchecked return value > >Hi Daniel, > >On 04/14/2016 03:01 PM, Daniel Mrzyglod wrote: >> This patch is for checking if error values occurs. >> fix for coverity errors #13209 & #13195 >> >> If the function returns an error value, the error value may be mistaken >> for a normal value. >> >> In rdline_char_in: Value returned from a function is not checked for err= ors >> before being used >> >> Signed-off-by: Daniel Mrzyglod >> --- >> lib/librte_cmdline/cmdline_rdline.c | 19 +++++++++++++++---- >> 1 file changed, 15 insertions(+), 4 deletions(-) >> >> diff --git a/lib/librte_cmdline/cmdline_rdline.c >b/lib/librte_cmdline/cmdline_rdline.c >> index 1ef2258..e75a556 100644 >> --- a/lib/librte_cmdline/cmdline_rdline.c >> +++ b/lib/librte_cmdline/cmdline_rdline.c >> @@ -377,7 +377,10 @@ rdline_char_in(struct rdline *rdl, char c) >> case CMDLINE_KEY_CTRL_K: >> cirbuf_get_buf_head(&rdl->right, rdl->kill_buf, >RDLINE_BUF_SIZE); >> rdl->kill_size =3D CIRBUF_GET_LEN(&rdl->right); >> - cirbuf_del_buf_head(&rdl->right, rdl->kill_size); >> + >> + if (cirbuf_del_buf_head(&rdl->right, rdl->kill_size) < 0) >> + return -EINVAL; >> + >> rdline_puts(rdl, vt100_clear_right); >> break; >> > >I wonder if a better way to fix wouldn't be to remove the checks >introduced in http://dpdk.org/browse/dpdk/commit/?id=3Dab971e562860 > >There is no reason to check that in cirbuf_get_buf_head/tail(): > if (!cbuf || !c) > >The function should never fail, it just returns the number of >copied chars. This is the responsibility of the caller to ensure >that the pointer to the circular buffer is not NULL. > >Also, rdline_char_in() is not expected to return -EINVAL, but >RDLINE_RES_* instead. > >So I think that partially revert ab971e562860 would fix the >coverity warning. > >Regards, >Olivier Removing checks probably will generate more Coverity errors somewhere. I see that only places where we test negative values are in unit tests. Reverting changes I think is overhead and maybe ignoring this patch and set= is as false positive in Coverity is better idea ? Regards Daniel