* [PATCH] clocksource: Remove unnecessary size argument when calling strscpy()
@ 2025-03-11 11:06 Thorsten Blum
2025-03-13 10:33 ` Thomas Gleixner
2025-03-13 10:52 ` [tip: timers/core] clocksource: Remove unnecessary strscpy() size argument tip-bot2 for Thorsten Blum
0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2025-03-11 11:06 UTC (permalink / raw)
To: John Stultz, Thomas Gleixner, Stephen Boyd; +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/time/clocksource.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 2a7802ec480c..e0eeacbe2521 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -1510,7 +1510,7 @@ static int __init boot_override_clocksource(char* str)
{
mutex_lock(&clocksource_mutex);
if (str)
- strscpy(override_name, str, sizeof(override_name));
+ strscpy(override_name, str);
mutex_unlock(&clocksource_mutex);
return 1;
}
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] clocksource: Remove unnecessary size argument when calling strscpy()
2025-03-11 11:06 [PATCH] clocksource: Remove unnecessary size argument when calling strscpy() Thorsten Blum
@ 2025-03-13 10:33 ` Thomas Gleixner
2025-03-13 10:52 ` [tip: timers/core] clocksource: Remove unnecessary strscpy() size argument tip-bot2 for Thorsten Blum
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Gleixner @ 2025-03-13 10:33 UTC (permalink / raw)
To: Thorsten Blum, John Stultz, Stephen Boyd
Cc: linux-kernel, Kees Cook, Peter Zijlstra
On Tue, Mar 11 2025 at 12:06, 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.
If, and _only_ if the destination argument is a fixed length array.
That's the case here, but without that distinction the above sentence is
misleading at best.
Thanks,
tglx
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip: timers/core] clocksource: Remove unnecessary strscpy() size argument
2025-03-11 11:06 [PATCH] clocksource: Remove unnecessary size argument when calling strscpy() Thorsten Blum
2025-03-13 10:33 ` Thomas Gleixner
@ 2025-03-13 10:52 ` tip-bot2 for Thorsten Blum
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Thorsten Blum @ 2025-03-13 10:52 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Thorsten Blum, Thomas Gleixner, x86, linux-kernel
The following commit has been merged into the timers/core branch of tip:
Commit-ID: fc661d0a78673f23a3fd78d0bb20900ee64d1839
Gitweb: https://git.kernel.org/tip/fc661d0a78673f23a3fd78d0bb20900ee64d1839
Author: Thorsten Blum <thorsten.blum@linux.dev>
AuthorDate: Tue, 11 Mar 2025 12:06:24 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 13 Mar 2025 11:37:44 +01:00
clocksource: Remove unnecessary strscpy() size argument
The size argument of strscpy() is only required when the destination
pointer is not a fixed sized array or when the copy needs to be smaller
than the size of the fixed sized destination array.
For fixed sized destination arrays and full copies, strscpy() automatically
determines the length of the destination buffer if the size argument is
omitted.
This makes the explicit sizeof() unnecessary. Remove it.
[ tglx: Massaged change log ]
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250311110624.495718-2-thorsten.blum@linux.dev
---
kernel/time/clocksource.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 2a7802e..e0eeacb 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -1510,7 +1510,7 @@ static int __init boot_override_clocksource(char* str)
{
mutex_lock(&clocksource_mutex);
if (str)
- strscpy(override_name, str, sizeof(override_name));
+ strscpy(override_name, str);
mutex_unlock(&clocksource_mutex);
return 1;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-13 10:52 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:06 [PATCH] clocksource: Remove unnecessary size argument when calling strscpy() Thorsten Blum
2025-03-13 10:33 ` Thomas Gleixner
2025-03-13 10:52 ` [tip: timers/core] clocksource: Remove unnecessary strscpy() size argument tip-bot2 for Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox