Skip to content

Commit aa264d9

Browse files
tobluxDinh Nguyen
authored andcommitted
nios2: Replace strcpy() with strscpy() and simplify setup_cpuinfo()
strcpy() is deprecated; use strscpy() instead. Since the destination buffer has a fixed length, strscpy() automatically determines its size using sizeof() when the size argument is omitted. This makes the explicit size argument unnecessary - remove it. Now, combine both if-else branches using strscpy() and the same buffer into a single statement to simplify the code. No functional changes intended. Link: KSPP#88 Cc: linux-hardening@vger.kernel.org Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Reviewed-by: Kees Cook <kees@kernel.org> Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
1 parent 83ab598 commit aa264d9

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

arch/nios2/kernel/cpuinfo.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ void __init setup_cpuinfo(void)
4646
cpuinfo.cpu_clock_freq = fcpu(cpu, "clock-frequency");
4747

4848
str = of_get_property(cpu, "altr,implementation", &len);
49-
if (str)
50-
strscpy(cpuinfo.cpu_impl, str, sizeof(cpuinfo.cpu_impl));
51-
else
52-
strcpy(cpuinfo.cpu_impl, "<unknown>");
49+
strscpy(cpuinfo.cpu_impl, str ?: "<unknown>");
5350

5451
cpuinfo.has_div = of_property_read_bool(cpu, "altr,has-div");
5552
cpuinfo.has_mul = of_property_read_bool(cpu, "altr,has-mul");

0 commit comments

Comments
 (0)