From: Hao Lan <lanhao@huawei.com>
To: <yang.yang29@zte.com.cn>, <salil.mehta@huawei.com>
Cc: <yisen.zhuang@huawei.com>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<brianvv@google.com>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <xu.panda@zte.com.cn>
Subject: Re: [PATCH net-next v2] hns: use strscpy() to instead of strncpy()
Date: Tue, 13 Dec 2022 09:27:20 +0800 [thread overview]
Message-ID: <a3c3481f-e552-86c9-2b81-e07f91cc3df9@huawei.com> (raw)
In-Reply-To: <202212091533253334827@zte.com.cn>
On 2022/12/9 15:33, yang.yang29@zte.com.cn wrote:
> From: Xu Panda <xu.panda@zte.com.cn>
>
> The implementation of strscpy() is more robust and safer.
> That's now the recommended way to copy NUL terminated strings.
>
> Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
> Signed-off-by: Yang Yang <yang.yang29@zte.com>
> ---
> change for v2
> - change the prefix and subject: replace ethtool with hns,
> and replace linux-next with net-next.
> ---
> drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> index 54faf0f2d1d8..b54f3706fb97 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> @@ -644,18 +644,15 @@ static void hns_nic_get_drvinfo(struct net_device *net_dev,
> {
> struct hns_nic_priv *priv = netdev_priv(net_dev);
>
> - strncpy(drvinfo->version, HNAE_DRIVER_VERSION,
> + strscpy(drvinfo->version, HNAE_DRIVER_VERSION,
> sizeof(drvinfo->version));
> - drvinfo->version[sizeof(drvinfo->version) - 1] = '\0';
>
> - strncpy(drvinfo->driver, HNAE_DRIVER_NAME, sizeof(drvinfo->driver));
> - drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0';
> + strscpy(drvinfo->driver, HNAE_DRIVER_NAME, sizeof(drvinfo->driver));
>
> - strncpy(drvinfo->bus_info, priv->dev->bus->name,
> + strscpy(drvinfo->bus_info, priv->dev->bus->name,
> sizeof(drvinfo->bus_info));
> - drvinfo->bus_info[ETHTOOL_BUSINFO_LEN - 1] = '\0';
>
> - strncpy(drvinfo->fw_version, "N/A", ETHTOOL_FWVERS_LEN);
> + strscpy(drvinfo->fw_version, "N/A", ETHTOOL_FWVERS_LEN);
> drvinfo->eedump_len = 0;
> }
>
Reviewed-by: Hao Lan <lanhao@huawei.com>
prev parent reply other threads:[~2022-12-13 1:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-09 7:33 yang.yang29
2022-12-09 9:01 ` Jiri Pirko
2022-12-13 1:27 ` Hao Lan [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=a3c3481f-e552-86c9-2b81-e07f91cc3df9@huawei.com \
--to=lanhao@huawei.com \
--cc=brianvv@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=salil.mehta@huawei.com \
--cc=xu.panda@zte.com.cn \
--cc=yang.yang29@zte.com.cn \
--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®