public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: hns3: use strscpy() to instead of strncpy()
@ 2022-12-09  7:38 yang.yang29
  2022-12-09  9:02 ` Jiri Pirko
  2022-12-12 21:11 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: yang.yang29 @ 2022-12-09  7:38 UTC (permalink / raw)
  To: salil.mehta
  Cc: yisen.zhuang, davem, edumazet, kuba, pabeni, brianvv, netdev,
	linux-kernel, xu.panda, yang.yang29

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 subject, replace linux-next with net-next.
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index cdf76fb58d45..55306fe8a540 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -639,13 +639,11 @@ static void hns3_get_drvinfo(struct net_device *netdev,
 		return;
 	}

-	strncpy(drvinfo->driver, dev_driver_string(&h->pdev->dev),
+	strscpy(drvinfo->driver, dev_driver_string(&h->pdev->dev),
 		sizeof(drvinfo->driver));
-	drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0';

-	strncpy(drvinfo->bus_info, pci_name(h->pdev),
+	strscpy(drvinfo->bus_info, pci_name(h->pdev),
 		sizeof(drvinfo->bus_info));
-	drvinfo->bus_info[ETHTOOL_BUSINFO_LEN - 1] = '\0';

 	fw_version = priv->ae_handle->ae_algo->ops->get_fw_version(h);

-- 
2.15.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: hns3: use strscpy() to instead of strncpy()
  2022-12-09  7:38 [PATCH net-next] net: hns3: use strscpy() to instead of strncpy() yang.yang29
@ 2022-12-09  9:02 ` Jiri Pirko
  2022-12-12 21:11 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2022-12-09  9:02 UTC (permalink / raw)
  To: yang.yang29
  Cc: salil.mehta, yisen.zhuang, davem, edumazet, kuba, pabeni, brianvv,
	netdev, linux-kernel, xu.panda

Fri, Dec 09, 2022 at 08:38:59AM CET, 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>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: hns3: use strscpy() to instead of strncpy()
  2022-12-09  7:38 [PATCH net-next] net: hns3: use strscpy() to instead of strncpy() yang.yang29
  2022-12-09  9:02 ` Jiri Pirko
@ 2022-12-12 21:11 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-12 21:11 UTC (permalink / raw)
  To: Yang Yang
  Cc: salil.mehta, yisen.zhuang, davem, edumazet, kuba, pabeni, brianvv,
	netdev, linux-kernel, xu.panda

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 9 Dec 2022 15:38:59 +0800 (CST) you 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>
> 
> [...]

Here is the summary with links:
  - [net-next] net: hns3: use strscpy() to instead of strncpy()
    https://git.kernel.org/bpf/bpf-next/c/80a464d83f08

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-12 21:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-09  7:38 [PATCH net-next] net: hns3: use strscpy() to instead of strncpy() yang.yang29
2022-12-09  9:02 ` Jiri Pirko
2022-12-12 21:11 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox