]> git.baikalelectronics.ru Git - kernel.git/commitdiff
alpha: Replace strncmp with str_has_prefix
authorChuhong Yuan <hslester96@gmail.com>
Tue, 30 Jul 2019 03:02:39 +0000 (11:02 +0800)
committerMatt Turner <mattst88@gmail.com>
Sat, 13 Jun 2020 00:43:17 +0000 (17:43 -0700)
In commit 669951268b1b
("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 <hslester96@gmail.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
arch/alpha/boot/tools/objstrip.c
arch/alpha/kernel/setup.c

index 825a16f5f6224695b5fdadea5ac829d2b1144d8f..08b430d25a315ff07d37e5e95e6dbda9048f8183 100644 (file)
@@ -148,7 +148,7 @@ 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);
index c3934ef703d8fa86bae83b4a5d9db794d09e5a55..d1fba112bdb4f58138f024f84d1b462f41bc05c2 100644 (file)
@@ -474,7 +474,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.  */