fork: Remove unnecessary size argument when calling strscpy()
Subsystems (3)
PATCH 1/1 fork: Remove unnecessary size argument when calling strscpy()
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.
--- kernel/fork.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/fork.c +1 -1
@@ -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 ;/*
Signature · 1 line
2.48.1
Quoted 6 lines · Thorsten Blum
The size parameter is optional and
strscpy()automatically determines the length of the destination buffer usingsizeof()if the argument is omitted. This makes the explicitsizeof()unnecessary. Remove it to simplify the code.Signed-off-by Thorsten Blum <[email protected]>
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.
Quoted 20 lines
--- kernel/fork.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/fork.c +1
-2@@ -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
Quoted 6 lines · Lorenzo Stoakes
Quoted 5 lines · Thorsten Blum
The size parameter is optional and
strscpy()automatically determines the length of the destination buffer usingsizeof()if the argument is omitted. This makes the explicitsizeof()unnecessary. Remove it to simplify the code.
Quoted 6 lines
Quoted 1 line
Signed-off-by Thorsten Blum <[email protected]>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