netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH wireless-next v2] wl18xx: use strscpy() to instead of strncpy()
@ 2022-12-26 11:14 yang.yang29
  2023-01-05 11:44 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: yang.yang29 @ 2022-12-26 11:14 UTC (permalink / raw)
  To: kvalo
  Cc: davem, edumazet, kuba, pabeni, linux-wireless, 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
 - use the right tag of wireless-next. 
---
 drivers/net/wireless/ti/wl18xx/main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
index 0b3cf8477c6c..1e4a430d1543 100644
--- a/drivers/net/wireless/ti/wl18xx/main.c
+++ b/drivers/net/wireless/ti/wl18xx/main.c
@@ -1516,12 +1516,9 @@ static int wl18xx_handle_static_data(struct wl1271 *wl,
 	struct wl18xx_static_data_priv *static_data_priv =
 		(struct wl18xx_static_data_priv *) static_data->priv;

-	strncpy(wl->chip.phy_fw_ver_str, static_data_priv->phy_version,
+	strscpy(wl->chip.phy_fw_ver_str, static_data_priv->phy_version,
 		sizeof(wl->chip.phy_fw_ver_str));

-	/* make sure the string is NULL-terminated */
-	wl->chip.phy_fw_ver_str[sizeof(wl->chip.phy_fw_ver_str) - 1] = '\0';
-
 	wl1271_info("PHY firmware version: %s", static_data_priv->phy_version);

 	return 0;
-- 
2.15.2

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

* Re: [PATCH wireless-next v2] wl18xx: use strscpy() to instead of strncpy()
  2022-12-26 11:14 [PATCH wireless-next v2] wl18xx: use strscpy() to instead of strncpy() yang.yang29
@ 2023-01-05 11:44 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2023-01-05 11:44 UTC (permalink / raw)
  To: yang.yang29
  Cc: kvalo, davem, edumazet, kuba, pabeni, linux-wireless, netdev,
	linux-kernel, xu.panda

On Mon, Dec 26, 2022 at 07:14:06PM +0800, 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
>  - use the right tag of wireless-next. 

Reviewed-by: Simon Horman <simon.horman@corigine.com>


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

end of thread, other threads:[~2023-01-05 11:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-26 11:14 [PATCH wireless-next v2] wl18xx: use strscpy() to instead of strncpy() yang.yang29
2023-01-05 11:44 ` Simon Horman

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).