From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
Cc: z <zhaojunkui2008@126.com>,
"Wolfgang Grandegger" <wg@grandegger.com>,
"David S. Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Stefan Mätje" <stefan.maetje@esd.eu>,
linux-can@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, bernard@vivo.com
Subject: Re: [PATCH] usb/peak_usb: cleanup code
Date: Wed, 11 May 2022 10:47:05 +0200 [thread overview]
Message-ID: <20220511084705.zh5fdetggullt75i@pengutronix.de> (raw)
In-Reply-To: <CAMZ6RqKHs4gdcNjVONfOTsHh6ZFEt0qpbEaKqDM7c1Cbc1OLdQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1642 bytes --]
On 11.05.2022 17:28:26, Vincent MAILHOL wrote:
> On Wed. 11 May 2022 at 16:11, z <zhaojunkui2008@126.com> wrote:
> > At 2022-05-11 14:44:50, "Marc Kleine-Budde" <mkl@pengutronix.de> wrote:
> > >On 10.05.2022 23:38:38, Bernard Zhao wrote:
> > >> The variable fi and bi only used in branch if (!dev->prev_siblings)
> > >> , fi & bi not kmalloc in else branch, so move kfree into branch
> > >> if (!dev->prev_siblings),this change is to cleanup the code a bit.
> > >
> > >Please move the variable declaration into that scope, too. Adjust the
> > >error handling accordingly.
> >
> > Hi Marc:
> >
> > I am not sure if there is some gap.
> > If we move the variable declaration into that scope, then each error branch has to do the kfree job, like:
> > if (err) {
> > dev_err(dev->netdev->dev.parent,
> > "unable to read %s firmware info (err %d)\n",
> > pcan_usb_pro.name, err);
> > kfree(bi);
> > kfree(fi);
> > kfree(usb_if);
> >
> > return err;
> > }
> > I am not sure if this looks a little less clear?
> > Thanks!
>
> A cleaner way would be to move all the content of the if
> (!dev->prev_siblings) to a new function.
Good idea.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2022-05-11 8:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-11 6:38 Bernard Zhao
2022-05-11 6:44 ` Marc Kleine-Budde
2022-05-11 7:11 ` z
2022-05-11 8:28 ` Vincent MAILHOL
2022-05-11 8:46 ` z
2022-05-11 8:47 ` Marc Kleine-Budde [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=20220511084705.zh5fdetggullt75i@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=bernard@vivo.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stefan.maetje@esd.eu \
--cc=wg@grandegger.com \
--cc=zhaojunkui2008@126.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
all inboxes | Powered by JetHome®