From: Jiri Pirko <jiri@resnulli.us>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, davem@davemloft.net, mlxsw@nvidia.com
Subject: Re: [patch net-next] devlink: append split port number to the port name
Date: Thu, 27 May 2021 12:12:40 +0200 [thread overview]
Message-ID: <YK9wmLUT22Gbc87V@nanopsycho> (raw)
In-Reply-To: <20210526170556.31336a06@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Thu, May 27, 2021 at 02:05:56AM CEST, kuba@kernel.org wrote:
>On Wed, 26 May 2021 12:35:08 +0200 Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@nvidia.com>
>>
>> Instead of doing sprintf twice in case the port is split or not, append
>> the split port suffix in case the port is split.
>>
>> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
>
>> diff --git a/net/core/devlink.c b/net/core/devlink.c
>> index 06b2b1941dce..c7754c293010 100644
>> --- a/net/core/devlink.c
>> +++ b/net/core/devlink.c
>> @@ -8632,12 +8632,10 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
>> switch (attrs->flavour) {
>> case DEVLINK_PORT_FLAVOUR_PHYSICAL:
>> case DEVLINK_PORT_FLAVOUR_VIRTUAL:
>> - if (!attrs->split)
>> - n = snprintf(name, len, "p%u", attrs->phys.port_number);
>> - else
>> - n = snprintf(name, len, "p%us%u",
>> - attrs->phys.port_number,
>> - attrs->phys.split_subport_number);
>> + n = snprintf(name, len, "p%u", attrs->phys.port_number);
>
>snprintf() can return n > len, you need to check for this before
>passing len - n as an unsigned argument below.
Correct, will send v2. Thanks!
>
>> + if (attrs->split)
>> + n += snprintf(name + n, len - n, "s%u",
>> + attrs->phys.split_subport_number);
>> break;
>> case DEVLINK_PORT_FLAVOUR_CPU:
>> case DEVLINK_PORT_FLAVOUR_DSA:
>
prev parent reply other threads:[~2021-05-27 10:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-26 10:35 [patch net-next] devlink: append split port number to the port name Jiri Pirko
2021-05-27 0:05 ` Jakub Kicinski
2021-05-27 10:12 ` Jiri Pirko [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=YK9wmLUT22Gbc87V@nanopsycho \
--to=jiri@resnulli.us \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=mlxsw@nvidia.com \
--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