summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2023-10-08 02:04:47 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2023-10-18 17:16:09 +0900
commit29ae5c02ed743c62e3c0619013b2bcd280bc562d (patch)
tree0c1b797e78582d7d6c4d1b36326e966df71af756
parentbd78c9d714208fb5d989bd8ad007ff0e2bcfb2a9 (diff)
downloadlinux-stable-29ae5c02ed743c62e3c0619013b2bcd280bc562d.tar.gz
linux-stable-29ae5c02ed743c62e3c0619013b2bcd280bc562d.tar.bz2
linux-stable-29ae5c02ed743c62e3c0619013b2bcd280bc562d.zip
modpost: refactor check_sec_ref()
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>
-rw-r--r--scripts/mod/modpost.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 99476a9695c5..441d57ee3275 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -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);
}
}