From ec02b815a7e54fc05f73e3185d33bd16d2ce14fc Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Wed, 30 Oct 2024 13:20:34 +0200 Subject: [PATCH] LLEXT: (cosmetic) reduce the scope of a variable Move a variable calculation inside the block, where it is actually used. Signed-off-by: Guennadi Liakhovetski --- subsys/llext/llext_load.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/subsys/llext/llext_load.c b/subsys/llext/llext_load.c index 643f9b18461..3e8d7f97677 100644 --- a/subsys/llext/llext_load.c +++ b/subsys/llext/llext_load.c @@ -587,28 +587,29 @@ static int llext_copy_symbols(struct llext_loader *ldr, struct llext *ext, elf_shdr_t *shdr = ldr->sect_hdrs + shndx; uintptr_t section_addr = shdr->sh_addr; - const void *base; - - base = llext_loaded_sect_ptr(ldr, ext, shndx); - if (!base) { - /* If the section is not mapped, try to peek. - * Be noisy about it, since this is addressing - * data that was missed by llext_map_sections. - */ - base = llext_peek(ldr, shdr->sh_offset); - if (base) { - LOG_DBG("section %d peeked at %p", shndx, base); - } else { - LOG_ERR("No data for section %d", shndx); - return -ENOTSUP; - } - } if (ldr_parm->pre_located && (!ldr_parm->section_detached || !ldr_parm->section_detached(shdr))) { sym_tab->syms[j].addr = (uint8_t *)sym.st_value + (ldr->hdr.e_type == ET_REL ? section_addr : 0); } else { + const void *base; + + base = llext_loaded_sect_ptr(ldr, ext, shndx); + if (!base) { + /* If the section is not mapped, try to peek. + * Be noisy about it, since this is addressing + * data that was missed by llext_map_sections. + */ + base = llext_peek(ldr, shdr->sh_offset); + if (base) { + LOG_DBG("section %d peeked at %p", shndx, base); + } else { + LOG_ERR("No data for section %d", shndx); + return -ENOTSUP; + } + } + sym_tab->syms[j].addr = (uint8_t *)base + sym.st_value - (ldr->hdr.e_type == ET_REL ? 0 : section_addr); }