From: Stephen Hemminger <stephen@networkplumber.org>
To: Jiri Bohac <jbohac@suse.cz>
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, Jiri Pirko <jiri@nvidia.com>
Subject: Re: [PATCH] net: check all name nodes in __dev_alloc_name
Date: Wed, 17 Mar 2021 21:11:08 -0700 [thread overview]
Message-ID: <20210317211108.5b2cdc77@hermes.local> (raw)
In-Reply-To: <20210318034253.w4w2p3kvi4m6vqp5@dwarf.suse.cz>
On Thu, 18 Mar 2021 04:42:53 +0100
Jiri Bohac <jbohac@suse.cz> wrote:
> for_each_netdev(net, d) {
> + struct netdev_name_node *name_node;
> + list_for_each_entry(name_node, &d->name_node->list, list) {
> + if (!sscanf(name_node->name, name, &i))
> + continue;
> + if (i < 0 || i >= max_netdevices)
> + continue;
> +
> + /* avoid cases where sscanf is not exact inverse of printf */
> + snprintf(buf, IFNAMSIZ, name, i);
> + if (!strncmp(buf, name_node->name, IFNAMSIZ))
> + set_bit(i, inuse);
> + }
Rather than copy/paste same code two places, why not make a helper function?
next prev parent reply other threads:[~2021-03-18 4:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-18 3:42 [PATCH] net: check all name nodes in __dev_alloc_name Jiri Bohac
2021-03-18 4:11 ` Stephen Hemminger [this message]
2021-03-18 9:06 ` Jiri Bohac
2021-03-18 18:28 ` Stephen Hemminger
2021-03-18 7:43 ` Jiri Pirko
2021-03-18 21:40 ` Andrew Lunn
2021-03-18 21:50 ` patchwork-bot+netdevbpf
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=20210317211108.5b2cdc77@hermes.local \
--to=stephen@networkplumber.org \
--cc=davem@davemloft.net \
--cc=jbohac@suse.cz \
--cc=jiri@nvidia.com \
--cc=kuba@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).