alpha: Replace strncmp with str_has_prefix
PATCH 1/1 alpha: Replace strncmp with str_has_prefix
In commit b6b2735514bc
("tracing: Use str_has_prefix() instead of using fixed sizes") the newly introduced str_has_prefix() was used
to replace error-prone strncmp(str, const, len). Here fix codes with the same pattern.
Signed-off-by Chuhong Yuan <[email protected]>
--- arch/alpha/boot/tools/objstrip.c | 3 ++- arch/alpha/kernel/setup.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
arch/alpha/boot/tools/objstrip.c +2 -1
@@ -148,7 +148,8 @@ main (int argc, char *argv[])#ifdef __ELF__ elf = (struct elfhdr *) buf; -if (elf->e_ident[0 ] ==0x7f &&strncmp ((char *)elf->e_ident +1 ,"ELF" ,3 ) ==0 ) { +if (elf->e_ident[0 ] ==0x7f && +str_has_prefix ((char *)elf->e_ident +1 ,"ELF" )) {if (elf->e_type !=ET_EXEC ) {fprintf (stderr,"%s: %s is not an ELF executable\n" , prog_name, inname);
arch/alpha/kernel/setup.c +1 -1
@@ -466,7 +466,7 @@ setup_arch(char **cmdline_p)#ifndef alpha_using_srm/* Assume that we've booted from SRM if we haven't booted from MILO. Detect the later by looking for "MILO" in the system serial nr. */ - alpha_using_srm =strncmp ((const char *)hwrpb->ssn,"MILO" ,4 ) !=0 ; + alpha_using_srm = !str_has_prefix ((const char *)hwrpb->ssn,"MILO" );#endif #ifndef alpha_using_qemu/* Similarly, look for QEMU. */
Signature · 1 line
2.20.1
arch/alpha/boot/tools/objstrip.c
Quoted 13 lines · Chuhong Yuan
In commit
b6b2735514bc
("tracing: Usestr_has_prefix()instead of using fixed sizes") the newly introducedstr_has_prefix()was used
to replace error-pronestrncmp(str, const, len). Here fix codes with the same pattern.Signed-off-by Chuhong Yuan <[email protected]>--- arch/alpha/boot/tools/objstrip.c | 3 ++- arch/alpha/kernel/setup.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)arch/alpha/boot/tools/objstrip.c +0
-0
[]
arch/alpha/boot/tools/objstrip.c main (int argc, char *argv[]) · line 152
Quoted 7 lines
arch/alpha/boot/tools/objstrip.c +2
-1@@ -148,7 +148,8 @@ main (int argc, char *argv[])#ifdef __ELF__ elf = (struct elfhdr *) buf; -if (elf->e_ident[0 ] ==0x7f &&strncmp ((char *)elf->e_ident +1 ,"ELF" ,3 ) ==0 ) { +if (elf->e_ident[0 ] ==0x7f && +str_has_prefix ((char *)elf->e_ident +1 ,"ELF" )) {
While the original indentation didn't use tabs,
please do not make it worse by misaligning.