[PATCH 3/7] modpost: add table_size local variable to symsearch_find_nearest()

From: Masahiro Yamada
Date: Wed Nov 01 2023 - 11:05:04 EST


Keep consistency with 'table', and make the conditional part slightly
shorter.

Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
---

scripts/mod/symsearch.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/mod/symsearch.c b/scripts/mod/symsearch.c
index 00f0f9c354db..97566aee0979 100644
--- a/scripts/mod/symsearch.c
+++ b/scripts/mod/symsearch.c
@@ -154,9 +154,10 @@ Elf_Sym *symsearch_find_nearest(struct elf_info *elf, Elf_Addr addr,
unsigned int secndx, bool allow_negative,
Elf_Addr min_distance)
{
- unsigned int hi = elf->symsearch->table_size;
- unsigned int lo = 0;
const struct syminfo *table = elf->symsearch->table;
+ unsigned int table_size = elf->symsearch->table_size;
+ unsigned int hi = table_size;
+ unsigned int lo = 0;
struct syminfo target;

target.addr = addr;
@@ -183,8 +184,7 @@ Elf_Sym *symsearch_find_nearest(struct elf_info *elf, Elf_Addr addr,
*/
Elf_Sym *result = NULL;

- if (allow_negative &&
- hi < elf->symsearch->table_size &&
+ if (allow_negative && hi < table_size &&
table[hi].section_index == secndx &&
table[hi].addr - addr <= min_distance) {
min_distance = table[hi].addr - addr;
--
2.40.1