Skip to content

Commit 68fef67

Browse files
committed
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 <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]>
1 parent c5c468d commit 68fef67

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

scripts/mod/modpost.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,13 +1270,9 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
12701270
continue;
12711271
if (!is_valid_name(elf, sym))
12721272
continue;
1273-
if (sym->st_value <= addr) {
1274-
if ((addr - sym->st_value) < distance) {
1275-
distance = addr - sym->st_value;
1276-
near = sym;
1277-
} else if ((addr - sym->st_value) == distance) {
1278-
near = sym;
1279-
}
1273+
if (sym->st_value <= addr && addr - sym->st_value <= distance) {
1274+
distance = addr - sym->st_value;
1275+
near = sym;
12801276
}
12811277
}
12821278
return near;

0 commit comments

Comments
 (0)