aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/modpost.c
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2022-05-24 01:46:26 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2022-05-27 16:16:35 +0900
commit68fef6704e38581f7462cb7aac349978fd4ca5cc (patch)
treed09b49103160016cd35072202924f9c8132f3693 /scripts/mod/modpost.c
parentmodpost: reuse ARRAY_SIZE() macro for section_mismatch() (diff)
downloadlinux-dev-68fef6704e38581f7462cb7aac349978fd4ca5cc.tar.xz
linux-dev-68fef6704e38581f7462cb7aac349978fd4ca5cc.zip
modpost: squash if...else-if in find_elf_symbol2()
if ((addr - sym->st_value) < distance) { distance = addr - sym->st_value; near = sym; } else if ((addr - sym->st_value) == distance) { near = sym; } is equivalent to: if (addr - sym->st_value <= distance) { distance = addr - sym->st_value; near = sym; } (The else-if block can overwrite 'distance' with the same value). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Diffstat (limited to '')
-rw-r--r--scripts/mod/modpost.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index fc8ba8585d23..b70a31b4245a 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1270,13 +1270,9 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
continue;
if (!is_valid_name(elf, sym))
continue;
- if (sym->st_value <= addr) {
- if ((addr - sym->st_value) < distance) {
- distance = addr - sym->st_value;
- near = sym;
- } else if ((addr - sym->st_value) == distance) {
- near = sym;
- }
+ if (sym->st_value <= addr && addr - sym->st_value <= distance) {
+ distance = addr - sym->st_value;
+ near = sym;
}
}
return near;