summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMaxim Moskalets <maximmosk4@gmail.com>2024-08-17 14:02:22 +0300
committerTom Rini <trini@konsulko.com>2024-08-27 18:01:21 -0600
commitd8503a45dfe48cdf764e143d9de851924b214f67 (patch)
tree34905b890b9a80393e8eaf59420423618b2e356c /lib
parent314fdd2e7392bc3480104a1f15001f0f6f25a4dd (diff)
lib: move phdr increment to for loop heading
Shifting this pointer in the loop will be more logical when working with the code later, because you can see at a glance what exactly changes at each iteration. Moreover, the code remains equivalent because this variable is not used after the loop. Signed-off-by: Maxim Moskalets <maximmosk4@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/elf.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/elf.c b/lib/elf.c
index 28ec87b8e48..e767a42a3b3 100644
--- a/lib/elf.c
+++ b/lib/elf.c
@@ -86,7 +86,7 @@ unsigned long load_elf64_image_phdr(unsigned long addr)
phdr = (Elf64_Phdr *)(addr + (ulong)ehdr->e_phoff);
/* Load each program header */
- for (i = 0; i < ehdr->e_phnum; ++i) {
+ for (i = 0; i < ehdr->e_phnum; ++i, ++phdr) {
void *dst = (void *)(ulong)phdr->p_paddr;
void *src = (void *)addr + phdr->p_offset;
@@ -103,7 +103,6 @@ unsigned long load_elf64_image_phdr(unsigned long addr)
phdr->p_memsz - phdr->p_filesz);
flush_cache(rounddown((unsigned long)dst, ARCH_DMA_MINALIGN),
roundup(phdr->p_memsz, ARCH_DMA_MINALIGN));
- ++phdr;
}
if (ehdr->e_machine == EM_PPC64 && (ehdr->e_flags &
@@ -205,7 +204,7 @@ unsigned long load_elf_image_phdr(unsigned long addr)
phdr = (Elf32_Phdr *)(addr + ehdr->e_phoff);
/* Load each program header */
- for (i = 0; i < ehdr->e_phnum; ++i) {
+ for (i = 0; i < ehdr->e_phnum; ++i, ++phdr) {
void *dst = (void *)(uintptr_t)phdr->p_paddr;
void *src = (void *)addr + phdr->p_offset;
@@ -222,7 +221,6 @@ unsigned long load_elf_image_phdr(unsigned long addr)
phdr->p_memsz - phdr->p_filesz);
flush_cache(rounddown((unsigned long)dst, ARCH_DMA_MINALIGN),
roundup(phdr->p_memsz, ARCH_DMA_MINALIGN));
- ++phdr;
}
return ehdr->e_entry;