From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Masahiro Yamada <masahiroy@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nicolas@fjasle.eu>
Subject: [PATCH 4/5] modpost: refactor check_sec_ref()
Date: Sun, 8 Oct 2023 02:04:47 +0900 [thread overview]
Message-ID: <20231007170448.505487-4-masahiroy@kernel.org> (raw)
In-Reply-To: <20231007170448.505487-1-masahiroy@kernel.org>
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 | 13 +++++++------
1 file 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);
}
}
--
2.39.2
next prev parent reply other threads:[~2023-10-07 17:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-07 17:04 [PATCH 1/5] modpost: fix tee MODULE_DEVICE_TABLE built on big endian host Masahiro Yamada
2023-10-07 17:04 ` [PATCH 2/5] modpost: fix ishtp " Masahiro Yamada
2023-10-08 7:51 ` Thomas Weißschuh
2023-10-09 16:50 ` srinivas pandruvada
2023-10-14 14:38 ` Masahiro Yamada
2023-10-07 17:04 ` [PATCH 3/5] modpost: define TO_NATIVE() using bswap_* functions Masahiro Yamada
2023-10-09 17:43 ` Nick Desaulniers
2023-10-14 14:16 ` Masahiro Yamada
2023-10-07 17:04 ` Masahiro Yamada [this message]
2023-10-07 17:04 ` [PATCH 5/5] modpost: factor out the common boilerplate of section_rel(a) Masahiro Yamada
2023-10-09 6:27 ` [PATCH 1/5] modpost: fix tee MODULE_DEVICE_TABLE built on big endian host Sumit Garg
2023-10-09 6:57 ` Masahiro Yamada
2023-10-09 9:24 ` Sumit Garg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231007170448.505487-4-masahiroy@kernel.org \
--to=masahiroy@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nicolas@fjasle.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox