netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: David Miller <davem@davemloft.net>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	martin.varghese@nokia.com, Willem de Bruijn <willemb@google.com>
Subject: Re: [PATCH net] net: bareudp: add missing error handling for bareudp_link_config()
Date: Mon, 4 Jan 2021 22:22:05 -0800	[thread overview]
Message-ID: <CAM_iQpUTZ9ZOAgfWjBP83Q9J3UFpVKbueboAs7uQFFuieyDfug@mail.gmail.com> (raw)
In-Reply-To: <20210104094936.79247c33@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

On Mon, Jan 4, 2021 at 9:49 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Sat, 2 Jan 2021 15:49:54 -0800 Cong Wang wrote:
> > On Wed, Dec 30, 2020 at 7:46 PM Jakub Kicinski <kuba@kernel.org> wrote:
> > > @@ -661,9 +662,14 @@ static int bareudp_newlink(struct net *net, struct net_device *dev,
> > >
> > >         err = bareudp_link_config(dev, tb);
> > >         if (err)
> > > -               return err;
> > > +               goto err_unconfig;
> > >
> > >         return 0;
> > > +
> > > +err_unconfig:
> >
> > I think we can save this goto.
>
> I personally prefer more idiomatic code flow to saving a single LoC.
>
> > > +       list_del(&bareudp->next);
> > > +       unregister_netdevice(dev);
> >
> > Which is bareudp_dellink(dev, NULL). ;)
>
> I know, but calling full dellink when only parts of newlink fails felt
> weird. And it's not lower LoC, unless called with NULL as second arg,
> which again could be surprising to a person changing dellink.

I think calling a function with "bareudp_" prefix is more readable
than interpreting list_del()+unregister_netdevice(). I mean

if (bareudp_*())
  goto err;
...
err:
bareudp_*();

this looks cleaner, right?

Thanks.

      reply	other threads:[~2021-01-05  6:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-31  3:44 [PATCH net] net: bareudp: add missing error handling for bareudp_link_config() Jakub Kicinski
2021-01-02 23:49 ` Cong Wang
2021-01-04 17:49   ` Jakub Kicinski
2021-01-05  6:22     ` Cong Wang [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=CAM_iQpUTZ9ZOAgfWjBP83Q9J3UFpVKbueboAs7uQFFuieyDfug@mail.gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=martin.varghese@nokia.com \
    --cc=netdev@vger.kernel.org \
    --cc=willemb@google.com \
    /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).