From: Chen Zhou <chenzhou10@huawei.com>
To: tanhuazhong <tanhuazhong@huawei.com>, <yisen.zhuang@huawei.com>,
<salil.mehta@huawei.com>, <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -next] net: hns3: replace snprintf with scnprintf in hns3_update_strings
Date: Mon, 20 Jan 2020 10:38:30 +0800 [thread overview]
Message-ID: <e7ae2607-1464-2268-03f7-244d6a2f2f43@huawei.com> (raw)
In-Reply-To: <3762cced-2a4a-7d54-787f-751c6fde2148@huawei.com>
On 2020/1/20 9:27, tanhuazhong wrote:
>
>
> On 2020/1/19 20:40, Chen Zhou wrote:
>> snprintf returns the number of bytes that would be written, which may be
>> greater than the the actual length to be written. Here use extra code to
>> handle this.
>>
>> scnprintf returns the number of bytes that was actually written, just use
>> scnprintf to simplify the code.
>>
>> Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
>> ---
>> drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
>> index 6e0212b..fa01888 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
>> @@ -423,9 +423,8 @@ static void *hns3_update_strings(u8 *data, const struct hns3_stats *stats,
>> data[ETH_GSTRING_LEN - 1] = '\0';
>> /* first, prepend the prefix string */
>> - n1 = snprintf(data, MAX_PREFIX_SIZE, "%s%d_",
>> + n1 = scnprintf(data, MAX_PREFIX_SIZE, "%s%d_",
>> prefix, i);
>
> not align?
Ok, I will fix it in next version.
Thanks,
Chen Zhou
>
>> - n1 = min_t(uint, n1, MAX_PREFIX_SIZE - 1);
>> size_left = (ETH_GSTRING_LEN - 1) - n1;
>> /* now, concatenate the stats string to it */
>>
>
>
> .
>
prev parent reply other threads:[~2020-01-20 2:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-19 12:40 [PATCH -next] net: hns3: replace snprintf with scnprintf in hns3_update_strings Chen Zhou
2020-01-20 1:27 ` tanhuazhong
2020-01-20 2:38 ` Chen Zhou [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=e7ae2607-1464-2268-03f7-244d6a2f2f43@huawei.com \
--to=chenzhou10@huawei.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=salil.mehta@huawei.com \
--cc=tanhuazhong@huawei.com \
--cc=yisen.zhuang@huawei.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).