Skip to contentSkip to conversation

module: Remove unnecessary size argument when calling strscpy()

PATCH In review Thorsten Blum 2 participants 2 messages Mar 8, 2025 – Mar 10, 2025 Module support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 module: 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 shorten and simplify the code.

---
 kernel/module/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/module/main.c +2 -2
index 1fb9ad289a6f..e690f46a7ea7 100644
@@ -795,8 +795,8 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
 	async_synchronize_full();
 
 	/* Store the name and taints of the last unloaded module for diagnostic purposes */
-	strscpy(last_unloaded_module.name, mod->name, sizeof(last_unloaded_module.name));
-	strscpy(last_unloaded_module.taints, module_flags(mod, buf, false), sizeof(last_unloaded_module.taints));
+	strscpy(last_unloaded_module.name, mod->name);
+	strscpy(last_unloaded_module.taints, module_flags(mod, buf, false));
 
 	free_module(mod);
 	/* someone could wait for the module in add_unformed_module() */
Signature · 1 line
2.48.1
maintainer
#1 lore raw
Quoted 6 lines · Thorsten Blum

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 shorten and simplify the code.

Looks good to me. I've queued it on modules-next.

Signature · 2 lines
Thanks,
Petr