From: Jakub Kicinski <kuba@kernel.org>
To: Tang Bin <tangbin@cmss.chinamobile.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: tap: remove redundant assignments
Date: Mon, 22 Feb 2021 16:53:44 -0800 [thread overview]
Message-ID: <20210222165344.533bc87e@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <20210222145748.10496-1-tangbin@cmss.chinamobile.com>
On Mon, 22 Feb 2021 22:57:48 +0800 Tang Bin wrote:
> In the function tap_get_user, the assignment of 'err' at both places
> is redundant, so remove one.
>
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> ---
> drivers/net/tap.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/net/tap.c b/drivers/net/tap.c
> index 1f4bdd944..3e9c72738 100644
> --- a/drivers/net/tap.c
> +++ b/drivers/net/tap.c
> @@ -625,7 +625,7 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control,
> struct tap_dev *tap;
> unsigned long total_len = iov_iter_count(from);
> unsigned long len = total_len;
> - int err;
> + int err = -EINVAL;
> struct virtio_net_hdr vnet_hdr = { 0 };
> int vnet_hdr_len = 0;
> int copylen = 0;
> @@ -636,7 +636,6 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control,
> if (q->flags & IFF_VNET_HDR) {
> vnet_hdr_len = READ_ONCE(q->vnet_hdr_sz);
>
> - err = -EINVAL;
> if (len < vnet_hdr_len)
> goto err;
> len -= vnet_hdr_len;
> @@ -657,7 +656,6 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control,
> goto err;
> }
>
> - err = -EINVAL;
> if (unlikely(len < ETH_HLEN))
> goto err;
>
Assigning err close to the gotos makes the code more robust and easier
to read. No applying this, sorry.
prev parent reply other threads:[~2021-02-23 0:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 14:57 [PATCH] net: tap: remove redundant assignments Tang Bin
2021-02-23 0:53 ` Jakub Kicinski [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=20210222165344.533bc87e@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=tangbin@cmss.chinamobile.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).