mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-23 07:23:12 +02:00
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: https://github.com/KSPP/linux/issues/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>
This commit is contained in:
parent
83ab598362
commit
aa264d9511
|
@ -46,10 +46,7 @@ void __init setup_cpuinfo(void)
|
|||
cpuinfo.cpu_clock_freq = fcpu(cpu, "clock-frequency");
|
||||
|
||||
str = of_get_property(cpu, "altr,implementation", &len);
|
||||
if (str)
|
||||
strscpy(cpuinfo.cpu_impl, str, sizeof(cpuinfo.cpu_impl));
|
||||
else
|
||||
strcpy(cpuinfo.cpu_impl, "<unknown>");
|
||||
strscpy(cpuinfo.cpu_impl, str ?: "<unknown>");
|
||||
|
||||
cpuinfo.has_div = of_property_read_bool(cpu, "altr,has-div");
|
||||
cpuinfo.has_mul = of_property_read_bool(cpu, "altr,has-mul");
|
||||
|
|
Loading…
Reference in New Issue
Block a user