All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
To: z <zhaojunkui2008@126.com>
Cc: "Marc Kleine-Budde" <mkl@pengutronix.de>,
	"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: Re: [PATCH] usb/peak_usb: cleanup code
Date: Wed, 11 May 2022 17:28:26 +0900	[thread overview]
Message-ID: <CAMZ6RqKHs4gdcNjVONfOTsHh6ZFEt0qpbEaKqDM7c1Cbc1OLdQ@mail.gmail.com> (raw)
In-Reply-To: <4986975d.3de3.180b1f57189.Coremail.zhaojunkui2008@126.com>

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.


Yours sincerely,
Vincent Mailhol

  reply	other threads:[~2022-05-11  8:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-11  6:38 [PATCH] usb/peak_usb: cleanup code Bernard Zhao
2022-05-11  6:44 ` Marc Kleine-Budde
2022-05-11  7:11   ` z
2022-05-11  8:28     ` Vincent MAILHOL [this message]
2022-05-11  8:46       ` Re:Re: " z
2022-05-11  8:47       ` Marc Kleine-Budde

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=CAMZ6RqKHs4gdcNjVONfOTsHh6ZFEt0qpbEaKqDM7c1Cbc1OLdQ@mail.gmail.com \
    --to=mailhol.vincent@wanadoo.fr \
    --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=mkl@pengutronix.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.