* [PATCH] md: move from strlcpy with unused retval to strscpy
@ 2022-08-18 21:00 Wolfram Sang
2022-08-23 17:46 ` [dm-devel] " Song Liu
0 siblings, 1 reply; 3+ messages in thread
From: Wolfram Sang @ 2022-08-18 21:00 UTC (permalink / raw)
To: linux-kernel
Cc: Wolfram Sang, Alasdair Kergon, Mike Snitzer, dm-devel, Song Liu,
linux-raid
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/md/dm-ioctl.c | 4 ++--
drivers/md/md.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 98976aaa9db9..6148fb73ccb4 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -921,9 +921,9 @@ static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
* Sneakily write in both the name and the uuid
* while we have the cell.
*/
- strlcpy(param->name, hc->name, sizeof(param->name));
+ strscpy(param->name, hc->name, sizeof(param->name));
if (hc->uuid)
- strlcpy(param->uuid, hc->uuid, sizeof(param->uuid));
+ strscpy(param->uuid, hc->uuid, sizeof(param->uuid));
else
param->uuid[0] = '\0';
diff --git a/drivers/md/md.c b/drivers/md/md.c
index afaf36b2f6ab..4d019ac0a549 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5743,7 +5743,7 @@ static int add_named_array(const char *val, const struct kernel_param *kp)
len--;
if (len >= DISK_NAME_LEN)
return -E2BIG;
- strscpy(buf, val, len+1);
+ strscpy(buf, val, len + 1);
if (strncmp(buf, "md_", 3) == 0)
return md_alloc_and_put(0, buf);
if (strncmp(buf, "md", 2) == 0 &&
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] md: move from strlcpy with unused retval to strscpy
2022-08-18 21:00 [PATCH] md: move from strlcpy with unused retval to strscpy Wolfram Sang
@ 2022-08-23 17:46 ` Song Liu
0 siblings, 0 replies; 3+ messages in thread
From: Song Liu @ 2022-08-23 17:46 UTC (permalink / raw)
To: Wolfram Sang
Cc: open list, Alasdair Kergon, Mike Snitzer, dm-devel, linux-raid
On Thu, Aug 18, 2022 at 2:00 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
>
> 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>
Looks good to me.
Alasdair and Mike,
This patch touches both dm and md code. Would you like me to take it
via the md tree?
Thanks,
Song
> ---
> drivers/md/dm-ioctl.c | 4 ++--
> drivers/md/md.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
> index 98976aaa9db9..6148fb73ccb4 100644
> --- a/drivers/md/dm-ioctl.c
> +++ b/drivers/md/dm-ioctl.c
> @@ -921,9 +921,9 @@ static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
> * Sneakily write in both the name and the uuid
> * while we have the cell.
> */
> - strlcpy(param->name, hc->name, sizeof(param->name));
> + strscpy(param->name, hc->name, sizeof(param->name));
> if (hc->uuid)
> - strlcpy(param->uuid, hc->uuid, sizeof(param->uuid));
> + strscpy(param->uuid, hc->uuid, sizeof(param->uuid));
> else
> param->uuid[0] = '\0';
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index afaf36b2f6ab..4d019ac0a549 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -5743,7 +5743,7 @@ static int add_named_array(const char *val, const struct kernel_param *kp)
> len--;
> if (len >= DISK_NAME_LEN)
> return -E2BIG;
> - strscpy(buf, val, len+1);
> + strscpy(buf, val, len + 1);
> if (strncmp(buf, "md_", 3) == 0)
> return md_alloc_and_put(0, buf);
> if (strncmp(buf, "md", 2) == 0 &&
> --
> 2.35.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dm-devel] [PATCH] md: move from strlcpy with unused retval to strscpy
@ 2022-08-23 17:46 ` Song Liu
0 siblings, 0 replies; 3+ messages in thread
From: Song Liu @ 2022-08-23 17:46 UTC (permalink / raw)
To: Wolfram Sang
Cc: linux-raid, dm-devel, Mike Snitzer, open list, Alasdair Kergon
On Thu, Aug 18, 2022 at 2:00 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
>
> 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>
Looks good to me.
Alasdair and Mike,
This patch touches both dm and md code. Would you like me to take it
via the md tree?
Thanks,
Song
> ---
> drivers/md/dm-ioctl.c | 4 ++--
> drivers/md/md.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
> index 98976aaa9db9..6148fb73ccb4 100644
> --- a/drivers/md/dm-ioctl.c
> +++ b/drivers/md/dm-ioctl.c
> @@ -921,9 +921,9 @@ static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
> * Sneakily write in both the name and the uuid
> * while we have the cell.
> */
> - strlcpy(param->name, hc->name, sizeof(param->name));
> + strscpy(param->name, hc->name, sizeof(param->name));
> if (hc->uuid)
> - strlcpy(param->uuid, hc->uuid, sizeof(param->uuid));
> + strscpy(param->uuid, hc->uuid, sizeof(param->uuid));
> else
> param->uuid[0] = '\0';
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index afaf36b2f6ab..4d019ac0a549 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -5743,7 +5743,7 @@ static int add_named_array(const char *val, const struct kernel_param *kp)
> len--;
> if (len >= DISK_NAME_LEN)
> return -E2BIG;
> - strscpy(buf, val, len+1);
> + strscpy(buf, val, len + 1);
> if (strncmp(buf, "md_", 3) == 0)
> return md_alloc_and_put(0, buf);
> if (strncmp(buf, "md", 2) == 0 &&
> --
> 2.35.1
>
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-24 7:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18 21:00 [PATCH] md: move from strlcpy with unused retval to strscpy Wolfram Sang
2022-08-23 17:46 ` Song Liu
2022-08-23 17:46 ` [dm-devel] " Song Liu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.