* [PATCH] fork: Remove unnecessary size argument when calling strscpy()
@ 2025-03-11 11:05 Thorsten Blum
2025-03-11 11:13 ` Lorenzo Stoakes
0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2025-03-11 11:05 UTC (permalink / raw)
To: Andrew Morton, Lorenzo Stoakes, Christian Brauner,
Liam R. Howlett, Suren Baghdasaryan, Wei Yang, David Hildenbrand,
Miaohe Lin, Al Viro
Cc: Thorsten Blum, linux-kernel
The size parameter is optional and strscpy() automatically determines
the length of the destination buffer using sizeof() if the argument is
omitted. This makes the explicit sizeof() unnecessary. Remove it to
simplify the code.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
kernel/fork.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index 735405a9c5f3..81eef131e23c 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2248,7 +2248,7 @@ __latent_entropy struct task_struct *copy_process(
p->flags |= PF_IO_WORKER;
if (args->name)
- strscpy_pad(p->comm, args->name, sizeof(p->comm));
+ strscpy_pad(p->comm, args->name);
p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? args->child_tid : NULL;
/*
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fork: Remove unnecessary size argument when calling strscpy()
2025-03-11 11:05 [PATCH] fork: Remove unnecessary size argument when calling strscpy() Thorsten Blum
@ 2025-03-11 11:13 ` Lorenzo Stoakes
2025-03-18 22:50 ` Thorsten Blum
0 siblings, 1 reply; 3+ messages in thread
From: Lorenzo Stoakes @ 2025-03-11 11:13 UTC (permalink / raw)
To: Thorsten Blum
Cc: Andrew Morton, Christian Brauner, Liam R. Howlett,
Suren Baghdasaryan, Wei Yang, David Hildenbrand, Miaohe Lin,
Al Viro, linux-kernel
On Tue, Mar 11, 2025 at 12:05:39PM +0100, Thorsten Blum wrote:
> The size parameter is optional and strscpy() automatically determines
> the length of the destination buffer using sizeof() if the argument is
> omitted. This makes the explicit sizeof() unnecessary. Remove it to
> simplify the code.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Hm not sure about this one, it's not really simplifying anything all too
much and seems like somewhat useless churn?
It's pretty clear what's going on here already.
> ---
> kernel/fork.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 735405a9c5f3..81eef131e23c 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -2248,7 +2248,7 @@ __latent_entropy struct task_struct *copy_process(
> p->flags |= PF_IO_WORKER;
>
> if (args->name)
> - strscpy_pad(p->comm, args->name, sizeof(p->comm));
> + strscpy_pad(p->comm, args->name);
>
> p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? args->child_tid : NULL;
> /*
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fork: Remove unnecessary size argument when calling strscpy()
2025-03-11 11:13 ` Lorenzo Stoakes
@ 2025-03-18 22:50 ` Thorsten Blum
0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2025-03-18 22:50 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: Andrew Morton, Christian Brauner, Liam R. Howlett,
Suren Baghdasaryan, Wei Yang, David Hildenbrand, Miaohe Lin,
Al Viro, linux-kernel
On 11. Mar 2025, at 12:13, Lorenzo Stoakes wrote:
> On Tue, Mar 11, 2025 at 12:05:39PM +0100, Thorsten Blum wrote:
>> The size parameter is optional and strscpy() automatically determines
>> the length of the destination buffer using sizeof() if the argument is
>> omitted. This makes the explicit sizeof() unnecessary. Remove it to
>> simplify the code.
>>
>> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>
> Hm not sure about this one, it's not really simplifying anything all too
> much and seems like somewhat useless churn?
>
> It's pretty clear what's going on here already.
Yes, but explicitly specifying the default value for an optional
parameter is redundant, and omitting it simplifies the code.
Thanks,
Thorsten
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-18 22:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-11 11:05 [PATCH] fork: Remove unnecessary size argument when calling strscpy() Thorsten Blum
2025-03-11 11:13 ` Lorenzo Stoakes
2025-03-18 22:50 ` Thorsten Blum
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.