Skip to content

Commit 29ae5c0

Browse files
committed
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>
1 parent bd78c9d commit 29ae5c0

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

scripts/mod/modpost.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,16 +1518,17 @@ static void section_rel(struct module *mod, struct elf_info *elf,
15181518
static void check_sec_ref(struct module *mod, struct elf_info *elf)
15191519
{
15201520
int i;
1521-
Elf_Shdr *sechdrs = elf->sechdrs;
15221521

15231522
/* Walk through all sections */
15241523
for (i = 0; i < elf->num_sections; i++) {
1525-
check_section(mod->name, elf, &elf->sechdrs[i]);
1524+
Elf_Shdr *sechdr = &elf->sechdrs[i];
1525+
1526+
check_section(mod->name, elf, sechdr);
15261527
/* We want to process only relocation sections and not .init */
1527-
if (sechdrs[i].sh_type == SHT_RELA)
1528-
section_rela(mod, elf, &elf->sechdrs[i]);
1529-
else if (sechdrs[i].sh_type == SHT_REL)
1530-
section_rel(mod, elf, &elf->sechdrs[i]);
1528+
if (sechdr->sh_type == SHT_RELA)
1529+
section_rela(mod, elf, sechdr);
1530+
else if (sechdr->sh_type == SHT_REL)
1531+
section_rel(mod, elf, sechdr);
15311532
}
15321533
}
15331534

0 commit comments

Comments
 (0)