]> git.itanic.dy.fi Git - linux-stable/commitdiff
modpost: refactor check_sec_ref()
authorMasahiro Yamada <masahiroy@kernel.org>
Sat, 7 Oct 2023 17:04:47 +0000 (02:04 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Wed, 18 Oct 2023 08:16:09 +0000 (17:16 +0900)
We can replace &elf->sechdrs[i] with &sechdrs[i] to slightly shorten
the code because we already have the local variable 'sechdrs'.

However, defining 'sechdr' instead shortens the code further.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
scripts/mod/modpost.c

index 99476a9695c520081b23cc0ecbaeab6850c5c936..441d57ee3275a09875bddc437b6bfb0f60e1a65c 100644 (file)
@@ -1518,16 +1518,17 @@ static void section_rel(struct module *mod, struct elf_info *elf,
 static void check_sec_ref(struct module *mod, struct elf_info *elf)
 {
        int i;
-       Elf_Shdr *sechdrs = elf->sechdrs;
 
        /* Walk through all sections */
        for (i = 0; i < elf->num_sections; i++) {
-               check_section(mod->name, elf, &elf->sechdrs[i]);
+               Elf_Shdr *sechdr = &elf->sechdrs[i];
+
+               check_section(mod->name, elf, sechdr);
                /* We want to process only relocation sections and not .init */
-               if (sechdrs[i].sh_type == SHT_RELA)
-                       section_rela(mod, elf, &elf->sechdrs[i]);
-               else if (sechdrs[i].sh_type == SHT_REL)
-                       section_rel(mod, elf, &elf->sechdrs[i]);
+               if (sechdr->sh_type == SHT_RELA)
+                       section_rela(mod, elf, sechdr);
+               else if (sechdr->sh_type == SHT_REL)
+                       section_rel(mod, elf, sechdr);
        }
 }