linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen: move from strlcpy with unused retval to strscpy
@ 2022-08-18 21:01 Wolfram Sang
  2022-08-23 13:46 ` Oleksandr Tyshchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2022-08-18 21:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, Juergen Gross, Stefano Stabellini,
	Oleksandr Tyshchenko, xen-devel, linux-scsi

Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/xen/xen-scsiback.c                 | 2 +-
 drivers/xen/xenbus/xenbus_probe_frontend.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index 7a0c93acc2c5..d3dcda344989 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -1121,7 +1121,7 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
 				"%s: writing %s", __func__, state);
 		return;
 	}
-	strlcpy(phy, val, VSCSI_NAMELEN);
+	strscpy(phy, val, VSCSI_NAMELEN);
 	kfree(val);
 
 	/* virtual SCSI device */
diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c
index 07b010a68fcf..f44d5a64351e 100644
--- a/drivers/xen/xenbus/xenbus_probe_frontend.c
+++ b/drivers/xen/xenbus/xenbus_probe_frontend.c
@@ -40,7 +40,7 @@ static int frontend_bus_id(char bus_id[XEN_BUS_ID_SIZE], const char *nodename)
 		return -EINVAL;
 	}
 
-	strlcpy(bus_id, nodename + 1, XEN_BUS_ID_SIZE);
+	strscpy(bus_id, nodename + 1, XEN_BUS_ID_SIZE);
 	if (!strchr(bus_id, '/')) {
 		pr_warn("bus_id %s no slash\n", bus_id);
 		return -EINVAL;
-- 
2.35.1


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

* Re: [PATCH] xen: move from strlcpy with unused retval to strscpy
  2022-08-18 21:01 [PATCH] xen: move from strlcpy with unused retval to strscpy Wolfram Sang
@ 2022-08-23 13:46 ` Oleksandr Tyshchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Oleksandr Tyshchenko @ 2022-08-23 13:46 UTC (permalink / raw)
  To: Wolfram Sang, linux-kernel
  Cc: Juergen Gross, Stefano Stabellini, xen-devel, linux-scsi


On 19.08.22 00:01, Wolfram Sang wrote:


Hello Wolfram

> Follow the advice of the below link and prefer 'strscpy' in this
> subsystem. Conversion is 1:1 because the return value is not used.
> Generated by a coccinelle script.
>
> Link: https://urldefense.com/v3/__https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/__;!!GF_29dbcQIUBPA!x8tXRXTdzbSmaWA3GH-Aj-ZF2HrMIAVOr_qerO6avg05AKhT0RI7MnqV64DykFFHfuDwoDYtT-i5bw7nGYSpneDqzzGfhYFHcm7LBQ$  [lore[.]kernel[.]org]
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


Looks correct:

Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>


> ---
>   drivers/xen/xen-scsiback.c                 | 2 +-
>   drivers/xen/xenbus/xenbus_probe_frontend.c | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
> index 7a0c93acc2c5..d3dcda344989 100644
> --- a/drivers/xen/xen-scsiback.c
> +++ b/drivers/xen/xen-scsiback.c
> @@ -1121,7 +1121,7 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
>   				"%s: writing %s", __func__, state);
>   		return;
>   	}
> -	strlcpy(phy, val, VSCSI_NAMELEN);
> +	strscpy(phy, val, VSCSI_NAMELEN);
>   	kfree(val);
>   
>   	/* virtual SCSI device */
> diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c
> index 07b010a68fcf..f44d5a64351e 100644
> --- a/drivers/xen/xenbus/xenbus_probe_frontend.c
> +++ b/drivers/xen/xenbus/xenbus_probe_frontend.c
> @@ -40,7 +40,7 @@ static int frontend_bus_id(char bus_id[XEN_BUS_ID_SIZE], const char *nodename)
>   		return -EINVAL;
>   	}
>   
> -	strlcpy(bus_id, nodename + 1, XEN_BUS_ID_SIZE);
> +	strscpy(bus_id, nodename + 1, XEN_BUS_ID_SIZE);
>   	if (!strchr(bus_id, '/')) {
>   		pr_warn("bus_id %s no slash\n", bus_id);
>   		return -EINVAL;

-- 
Regards,

Oleksandr Tyshchenko

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

end of thread, other threads:[~2022-08-23 19:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18 21:01 [PATCH] xen: move from strlcpy with unused retval to strscpy Wolfram Sang
2022-08-23 13:46 ` Oleksandr Tyshchenko

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