Commit 68fef670 authored by Masahiro Yamada's avatar Masahiro Yamada

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: default avatarMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
parent c5c468dc
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment