s390/module: avoid using strncmp with hardcoded length
authorVasily Gorbik <gor@linux.ibm.com>
Mon, 19 Aug 2019 15:05:44 +0000 (17:05 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Thu, 29 Aug 2019 13:34:57 +0000 (15:34 +0200)
Reuse str_has_prefix instead of strncmp with hardcoded length to
make the intent of a comparison more obvious.

Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/kernel/module.c

index 31889db609e904cbafbc2bdab9aa9500fe793b09..ba8f19bb438b85c0571dedf0d7295d4715091821 100644 (file)
@@ -472,11 +472,11 @@ int module_finalize(const Elf_Ehdr *hdr,
                        apply_alternatives(aseg, aseg + s->sh_size);
 
                if (IS_ENABLED(CONFIG_EXPOLINE) &&
-                   (!strncmp(".s390_indirect", secname, 14)))
+                   (str_has_prefix(secname, ".s390_indirect")))
                        nospec_revert(aseg, aseg + s->sh_size);
 
                if (IS_ENABLED(CONFIG_EXPOLINE) &&
-                   (!strncmp(".s390_return", secname, 12)))
+                   (str_has_prefix(secname, ".s390_return")))
                        nospec_revert(aseg, aseg + s->sh_size);
        }