netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: yuan linyu <cugyly@163.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Linyu.Yuan@alcatel-sbell.com.cn
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	[thread overview]
Message-ID: <1511056740.6425.4.camel@163.com> (raw)
In-Reply-To: <20171117.150825.1222925061943453941.davem@davemloft.net>

On 五, 2017-11-17 at 15:08 +0900, David Miller wrote:
> From: yuan linyu <cugyly@163.com>
> Date: Thu, 16 Nov 2017 19:59:48 +0800
> 
> > From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
> > 
> > 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 <Linyu.Yuan@alcatel-sbell.com.cn>
> 
> 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.

      reply	other threads:[~2017-11-19  1:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-16 11:59 [PATCH net-next v3] net: assign err to 0 at begin in do_setlink() function yuan linyu
2017-11-17  6:08 ` David Miller
2017-11-19  1:59   ` yuan linyu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1511056740.6425.4.camel@163.com \
    --to=cugyly@163.com \
    --cc=Linyu.Yuan@alcatel-sbell.com.cn \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).