2023-05-28 16:30:01

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH 2/2] binfmt: Slightly simplify elf_fdpic_map_file()

There is no point in initializing 'load_addr' and 'seg' here, they are both
re-written just before being used below.

Doing so, 'load_addr' can be moved in the #ifdef CONFIG_MMU section.

Signed-off-by: Christophe JAILLET <[email protected]>
---
Compile tested on arm, with and without CONFIG_MMU
---
fs/binfmt_elf_fdpic.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 237ce388d06d..1c6c5832af86 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -743,11 +743,12 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
struct elf32_fdpic_loadmap *loadmap;
#ifdef CONFIG_MMU
struct elf32_fdpic_loadseg *mseg;
+ unsigned long load_addr;
#endif
struct elf32_fdpic_loadseg *seg;
struct elf32_phdr *phdr;
- unsigned long load_addr, stop;
unsigned nloads, tmp;
+ unsigned long stop;
int loop, ret;

/* allocate a load map table */
@@ -768,9 +769,6 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
loadmap->version = ELF32_FDPIC_LOADMAP_VERSION;
loadmap->nsegs = nloads;

- load_addr = params->load_addr;
- seg = loadmap->segs;
-
/* map the requested LOADs into the memory space */
switch (params->flags & ELF_FDPIC_FLAG_ARRANGEMENT) {
case ELF_FDPIC_FLAG_CONSTDISP:
--
2.34.1



2023-05-28 16:46:41

by Eric W. Biederman

[permalink] [raw]
Subject: Re: [PATCH 2/2] binfmt: Slightly simplify elf_fdpic_map_file()

Christophe JAILLET <[email protected]> writes:

> There is no point in initializing 'load_addr' and 'seg' here, they are both
> re-written just before being used below.
>
> Doing so, 'load_addr' can be moved in the #ifdef CONFIG_MMU section.
>

Acked-by: "Eric W. Biederman" <[email protected]>

Kees do you maybe want to pick these trivial fixes up?

> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> Compile tested on arm, with and without CONFIG_MMU
> ---
> fs/binfmt_elf_fdpic.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
> index 237ce388d06d..1c6c5832af86 100644
> --- a/fs/binfmt_elf_fdpic.c
> +++ b/fs/binfmt_elf_fdpic.c
> @@ -743,11 +743,12 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
> struct elf32_fdpic_loadmap *loadmap;
> #ifdef CONFIG_MMU
> struct elf32_fdpic_loadseg *mseg;
> + unsigned long load_addr;
> #endif
> struct elf32_fdpic_loadseg *seg;
> struct elf32_phdr *phdr;
> - unsigned long load_addr, stop;
> unsigned nloads, tmp;
> + unsigned long stop;
> int loop, ret;
>
> /* allocate a load map table */
> @@ -768,9 +769,6 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
> loadmap->version = ELF32_FDPIC_LOADMAP_VERSION;
> loadmap->nsegs = nloads;
>
> - load_addr = params->load_addr;
> - seg = loadmap->segs;
> -
> /* map the requested LOADs into the memory space */
> switch (params->flags & ELF_FDPIC_FLAG_ARRANGEMENT) {
> case ELF_FDPIC_FLAG_CONSTDISP: