x86/cpu: Replace deprecated strcpy() with strscpy()
PATCH 1/1 x86/cpu: Replace deprecated strcpy() with strscpy()
strcpy() is deprecated; use strscpy() instead.
In cyrix.c, use 'c->x86_model_id' directly and remove the local variable 'buf' to retain the array size of the destination buffer.
No functional changes intended.
Signed-off-by Thorsten Blum <[email protected]>
--- arch/x86/kernel/cpu/amd.c | 3 ++- arch/x86/kernel/cpu/common.c | 6 +++--- arch/x86/kernel/cpu/cyrix.c | 7 +++---- arch/x86/kernel/cpu/intel.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-)
arch/x86/kernel/cpu/amd.c +2 -1
@@ -8,6 +8,7 @@#include <linux/sched.h> #include <linux/sched/clock.h> #include <linux/random.h> +#include <linux/string.h> #include <linux/topology.h> #include <asm/processor.h> #include <asm/apic.h>
@@ -643,7 +644,7 @@ static void init_amd_k8(struct cpuinfo_x86 *c) }if (!c->x86_model_id[0 ]) -strcpy (c->x86_model_id,"Hammer" ); +strscpy (c->x86_model_id,"Hammer" );#ifdef CONFIG_SMP /*
arch/x86/kernel/cpu/common.c +3 -3
@@ -183,9 +183,9 @@ static void default_init(struct cpuinfo_x86 *c)if (c->cpuid_level ==-1 ) {/* No cpuid. It must be an ancient CPU */ if (c->x86 ==4 ) -strcpy (c->x86_model_id,"486" ); +strscpy (c->x86_model_id,"486" );else if (c->x86 ==3 ) -strcpy (c->x86_model_id,"386" ); +strscpy (c->x86_model_id,"386" ); }#endif }
@@ -1919,7 +1919,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)const char *p; p =table_lookup_model (c);if (p) -strcpy (c->x86_model_id, p); +strscpy (c->x86_model_id, p);else /* Last resort... */ sprintf(c->x86_model_id, "%02x/%02x",
arch/x86/kernel/cpu/cyrix.c +3 -4
@@ -192,7 +192,6 @@ static void early_init_cyrix(struct cpuinfo_x86 *c)static void init_cyrix (struct cpuinfo_x86 *c) {unsigned char dir0, dir0_msn, dir0_lsn, dir1 =0 ; -char *buf = c->x86_model_id;const char *p =NULL ;/*
@@ -352,9 +351,9 @@ static void init_cyrix(struct cpuinfo_x86 *c) dir0_msn =7 ;break ; } -strcpy (buf, Cx86_model[dir0_msn &7 ]); +strscpy (c->x86_model_id, Cx86_model[dir0_msn &7 ]);if (p) -strcat (buf, p); +strcat (c->x86_model_id, p);return ; }
@@ -416,7 +415,7 @@ static void cyrix_identify(struct cpuinfo_x86 *c)if (c->x86 ==4 &&test_cyrix_52div ()) {unsigned char dir0, dir1; -strcpy (c->x86_vendor_id,"CyrixInstead" ); +strscpy (c->x86_vendor_id,"CyrixInstead" ); c->x86_vendor =X86_VENDOR_CYRIX ;/* Actually enable cpuid on the older cyrix */
arch/x86/kernel/cpu/intel.c +1 -1
@@ -605,7 +605,7 @@ static void init_intel(struct cpuinfo_x86 *c) }if (p) -strcpy (c->x86_model_id, p); +strscpy (c->x86_model_id, p); }#endif
Signature · 1 line
2.49.0