netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adam Kandur <sys.arch.adam@gmail.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net/usb: remove goto in ax88772_reset()
Date: Wed, 29 Dec 2021 16:27:03 +0300	[thread overview]
Message-ID: <CAE28pkNsuEEPt5B-a7iqhcQftxRH15P-GKJfAEZUbEcYYMWWZQ@mail.gmail.com> (raw)
In-Reply-To: <YcxfJjpTBm6Gbiwb@kroah.com>

Greetings.
I thought, there is no reason to have out label. Because it has only
one return statement and there is return 0 before. So it seemed to me
that "goto out;" could be replaced with the "return ret;" line. Which
seems more readable to me.

thanks,

adam k.

On Wed, Dec 29, 2021 at 4:14 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Dec 29, 2021 at 03:57:30PM +0300, Adam Kandur wrote:
> > goto statements in ax88772_reset() in net/usb/asix_devices.c are used
> > to return ret variable. As function by default returns 0 if ret
> > variable >= 0 and "out:" only returns ret, I assume goto might be
> > removed.
> >
> > Signed-off-by: Adam Kandur <sys.arch.adam@gmail.com>
> >
> > ---
> >  drivers/net/usb/asix_devices.c | 9 +++------
> >  1 file changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
> > index 4514d35ef..9de5fc53f 100644
> > --- a/drivers/net/usb/asix_devices.c
> > +++ b/drivers/net/usb/asix_devices.c
> > @@ -332,23 +332,20 @@ static int ax88772_reset(struct usbnet *dev)
> >       ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0,
> >                            ETH_ALEN, data->mac_addr, 0);
> >       if (ret < 0)
> > -             goto out;
> > +             return ret;
> >
> >       /* Set RX_CTL to default values with 2k buffer, and enable cactus */
> >       ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, 0);
> >       if (ret < 0)
> > -             goto out;
> > +             return ret;
> >
> >       ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT, 0);
> >       if (ret < 0)
> > -             goto out;
> > +             return ret;
> >
> >       phy_start(priv->phydev);
> >
> >       return 0;
> > -
> > -out:
> > -     return ret;
> >  }
>
> There is nothing wrong with the goto here, it's the common error path
> style for the kernel.  Why should it be removed?  What is the benefit
> here?
>
> thanks,
>
> greg k-h

      reply	other threads:[~2021-12-29 13:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-29 12:57 [PATCH] net/usb: remove goto in ax88772_reset() Adam Kandur
2021-12-29 13:14 ` Greg KH
2021-12-29 13:27   ` Adam Kandur [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=CAE28pkNsuEEPt5B-a7iqhcQftxRH15P-GKJfAEZUbEcYYMWWZQ@mail.gmail.com \
    --to=sys.arch.adam@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --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).