From: Huazhong Tan <tanhuazhong@huawei.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<salil.mehta@huawei.com>, <yisen.zhuang@huawei.com>,
<huangdaode@huawei.com>, <linuxarm@huawei.com>, <kuba@kernel.org>,
Guojia Liao <liaoguojia@huawei.com>,
Huazhong Tan <tanhuazhong@huawei.com>
Subject: [PATCH net-next 5/9] net: hns3: refine the input parameter 'size' for snprintf()
Date: Tue, 21 Jan 2020 16:42:09 +0800 [thread overview]
Message-ID: <1579596133-54842-6-git-send-email-tanhuazhong@huawei.com> (raw)
In-Reply-To: <1579596133-54842-1-git-send-email-tanhuazhong@huawei.com>
From: Guojia Liao <liaoguojia@huawei.com>
The function snprintf() writes at most size bytes (including the
terminating null byte ('\0') to str. Now, We can guarantee that the
parameter of size is lager than the length of str to be formatting
including its terminating null byte. So it's unnecessary to minus 1
for the input parameter 'size'.
Signed-off-by: Guojia Liao <liaoguojia@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 06c58ed..6271b69 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -4716,7 +4716,7 @@ static int __init hns3_init_module(void)
pr_info("%s: %s\n", hns3_driver_name, hns3_copyright);
client.type = HNAE3_CLIENT_KNIC;
- snprintf(client.name, HNAE3_CLIENT_NAME_LENGTH - 1, "%s",
+ snprintf(client.name, HNAE3_CLIENT_NAME_LENGTH, "%s",
hns3_driver_name);
client.ops = &client_ops;
--
2.7.4
next prev parent reply other threads:[~2020-01-21 8:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-21 8:42 [PATCH net-next 0/9] net: hns3: misc updates for -net-next Huazhong Tan
2020-01-21 8:42 ` [PATCH net-next 1/9] net: hns3: limit the error logging in the hns3_clean_tx_ring() Huazhong Tan
2020-01-21 8:42 ` [PATCH net-next 2/9] net: hns3: do not reuse pfmemalloc pages Huazhong Tan
2020-01-21 8:42 ` [PATCH net-next 3/9] net: hns3: set VF's default reset_type to HNAE3_NONE_RESET Huazhong Tan
2020-01-21 8:42 ` [PATCH net-next 4/9] net: hns3: move duplicated macro definition into header Huazhong Tan
2020-01-21 8:42 ` Huazhong Tan [this message]
2020-01-21 8:42 ` [PATCH net-next 6/9] net: hns3: rewrite a log in hclge_put_vector() Huazhong Tan
2020-01-21 8:42 ` [PATCH net-next 7/9] net: hns3: delete unnecessary blank line and space for cleanup Huazhong Tan
2020-01-21 8:42 ` [PATCH net-next 8/9] net: hns3: remove redundant print on ENOMEM Huazhong Tan
2020-01-21 8:42 ` [PATCH net-next 9/9] net: hns3: cleanup some coding style issue Huazhong Tan
2020-01-21 10:46 ` [PATCH net-next 0/9] net: hns3: misc updates for -net-next David Miller
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=1579596133-54842-6-git-send-email-tanhuazhong@huawei.com \
--to=tanhuazhong@huawei.com \
--cc=davem@davemloft.net \
--cc=huangdaode@huawei.com \
--cc=kuba@kernel.org \
--cc=liaoguojia@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=salil.mehta@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
all inboxes | Powered by JetHome®