From mboxrd@z Thu Jan 1 00:00:00 1970 From: yuan linyu Subject: Re: [PATCH net-next v3] net: assign err to 0 at begin in do_setlink() function Date: Sun, 19 Nov 2017 09:59:00 +0800 Message-ID: <1511056740.6425.4.camel@163.com> References: <1510833588-3841-1-git-send-email-cugyly@163.com> <20171117.150825.1222925061943453941.davem@davemloft.net> Reply-To: cugyly@163.com Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Cc: netdev@vger.kernel.org, Linyu.Yuan@alcatel-sbell.com.cn To: David Miller Return-path: Received: from m12-18.163.com ([220.181.12.18]:48634 "EHLO m12-18.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750732AbdKSB7N (ORCPT ); Sat, 18 Nov 2017 20:59:13 -0500 In-Reply-To: <20171117.150825.1222925061943453941.davem@davemloft.net> Sender: netdev-owner@vger.kernel.org List-ID: On 五, 2017-11-17 at 15:08 +0900, David Miller wrote: > From: yuan linyu > Date: Thu, 16 Nov 2017 19:59:48 +0800 > > > From: yuan linyu > >  > > each netlink attribute have proper process when error happen, > > when exit one attribute process, it implies that no error, > > so err = 0; is useless. > >  > > assign err = 0; at beginning if all attributes not set. > >  > > v1 -> v2: > >       fix review comment from David, clear err before > >       nla_for_each_nested() > >  > > v2 -> v3: > >       maybe wrong understanding of David comment, > >       provide a new version > >  > > Signed-off-by: yuan linyu > > I'm sorry I still find it hard to accept this change. > > What about all of the assignments of 'err' which only branch to > 'errout' if err is negative?  It is not easy to see that none of those > case ever result in 'err' holding a positive non-zero value. yes, i also try to check any function return > 0, but it hard, maybe some function not follow common rule. > > The code as-is is the easiest to understand, audit and prove correct > in the error-free case.  And this because of the explicit clearing or > 'err' to zero late in the function. yes, but this clearing will do three times every function call, but it is not big issue  > > Thanks you.