linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] fs: binfmt_elf_efpic: fix variable set but not used warning
@ 2025-03-08  2:27 sunliming
  2025-03-08  3:42 ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: sunliming @ 2025-03-08  2:27 UTC (permalink / raw)
  To: viro, brauner, jack, kees, ebiederm
  Cc: linux-fsdevel, linux-mm, linux-kernel, sunliming, kernel test robot

From: sunliming <sunliming@kylinos.cn>

Fix below kernel warning:
fs/binfmt_elf_fdpic.c:1024:52: warning: variable 'excess1' set but not
used [-Wunused-but-set-variable]

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: sunliming <sunliming@kylinos.cn>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/binfmt_elf_fdpic.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index e3cf2801cd64..a1ad3c94b2b7 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -1024,7 +1024,7 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
 	/* deal with each load segment separately */
 	phdr = params->phdrs;
 	for (loop = 0; loop < params->hdr.e_phnum; loop++, phdr++) {
-		unsigned long maddr, disp, excess, excess1;
+		unsigned long maddr, disp, excess;
 		int prot = 0, flags;
 
 		if (phdr->p_type != PT_LOAD)
@@ -1120,9 +1120,10 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
 		 *   extant in the file
 		 */
 		excess = phdr->p_memsz - phdr->p_filesz;
-		excess1 = PAGE_SIZE - ((maddr + phdr->p_filesz) & ~PAGE_MASK);
 
 #ifdef CONFIG_MMU
+		unsiged long excess1
+			= PAGE_SIZE - ((maddr + phdr->p_filesz) & ~PAGE_MASK);
 		if (excess > excess1) {
 			unsigned long xaddr = maddr + phdr->p_filesz + excess1;
 			unsigned long xmaddr;
-- 
2.25.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] fs: binfmt_elf_efpic: fix variable set but not used warning
  2025-03-08  2:27 [PATCH V2] fs: binfmt_elf_efpic: fix variable set but not used warning sunliming
@ 2025-03-08  3:42 ` Kees Cook
  2025-03-08  4:01   ` Pedro Falcato
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2025-03-08  3:42 UTC (permalink / raw)
  To: viro, brauner, jack, ebiederm, sunliming
  Cc: Kees Cook, linux-fsdevel, linux-mm, linux-kernel, sunliming,
	kernel test robot

On Sat, 08 Mar 2025 10:27:54 +0800, sunliming@linux.dev wrote:
> Fix below kernel warning:
> fs/binfmt_elf_fdpic.c:1024:52: warning: variable 'excess1' set but not
> used [-Wunused-but-set-variable]
> 
> 

Adjusted Subject for typos.

Applied to for-next/execve, thanks!

[1/1] binfmt_elf_fdpic: fix variable set but not used warning
      https://git.kernel.org/kees/c/7845fe65b33d

Take care,

-- 
Kees Cook



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] fs: binfmt_elf_efpic: fix variable set but not used warning
  2025-03-08  3:42 ` Kees Cook
@ 2025-03-08  4:01   ` Pedro Falcato
  2025-03-08  4:07     ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Falcato @ 2025-03-08  4:01 UTC (permalink / raw)
  To: Kees Cook
  Cc: viro, brauner, jack, ebiederm, sunliming, linux-fsdevel,
	linux-mm, linux-kernel, sunliming, kernel test robot

On Sat, Mar 8, 2025 at 3:45 AM Kees Cook <kees@kernel.org> wrote:
>
> On Sat, 08 Mar 2025 10:27:54 +0800, sunliming@linux.dev wrote:
> > Fix below kernel warning:
> > fs/binfmt_elf_fdpic.c:1024:52: warning: variable 'excess1' set but not
> > used [-Wunused-but-set-variable]
> >
> >
>
> Adjusted Subject for typos.
>
> Applied to for-next/execve, thanks!
>
> [1/1] binfmt_elf_fdpic: fix variable set but not used warning
>       https://git.kernel.org/kees/c/7845fe65b33d
>

FYI, there's a typo so this patch won't compile

>+ unsiged long excess1
>+ = PAGE_SIZE - ((maddr + phdr->p_filesz) & ~PAGE_MASK);

s/unsiged/unsigned/

:)

-- 
Pedro


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] fs: binfmt_elf_efpic: fix variable set but not used warning
  2025-03-08  4:01   ` Pedro Falcato
@ 2025-03-08  4:07     ` Kees Cook
  0 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2025-03-08  4:07 UTC (permalink / raw)
  To: Pedro Falcato
  Cc: viro, brauner, jack, ebiederm, sunliming, linux-fsdevel,
	linux-mm, linux-kernel, sunliming, kernel test robot

On Sat, Mar 08, 2025 at 04:01:50AM +0000, Pedro Falcato wrote:
> On Sat, Mar 8, 2025 at 3:45 AM Kees Cook <kees@kernel.org> wrote:
> >
> > On Sat, 08 Mar 2025 10:27:54 +0800, sunliming@linux.dev wrote:
> > > Fix below kernel warning:
> > > fs/binfmt_elf_fdpic.c:1024:52: warning: variable 'excess1' set but not
> > > used [-Wunused-but-set-variable]
> > >
> > >
> >
> > Adjusted Subject for typos.
> >
> > Applied to for-next/execve, thanks!
> >
> > [1/1] binfmt_elf_fdpic: fix variable set but not used warning
> >       https://git.kernel.org/kees/c/7845fe65b33d
> >
> 
> FYI, there's a typo so this patch won't compile
> 
> >+ unsiged long excess1
> >+ = PAGE_SIZE - ((maddr + phdr->p_filesz) & ~PAGE_MASK);
> 
> s/unsiged/unsigned/

D'oh. Fixing in my tree..

-- 
Kees Cook


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-08  4:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-08  2:27 [PATCH V2] fs: binfmt_elf_efpic: fix variable set but not used warning sunliming
2025-03-08  3:42 ` Kees Cook
2025-03-08  4:01   ` Pedro Falcato
2025-03-08  4:07     ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox