Skip to contentSkip to conversation

fs: binfmt_elf_efpic: fix variable set but not used warning

PATCH Applied [email protected] 3 participants 4 messages Mar 8, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fs: binfmt_elf_efpic: fix variable set but not used warning

From: sunliming <[email protected]>

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

---
 fs/binfmt_elf_fdpic.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/binfmt_elf_fdpic.c +3 -2
index e3cf2801cd64..a1ad3c94b2b7 100644
@@ -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;
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 5 lines · On Sat, 08 Mar 2025 10:27:54 +0800, [email protected] 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,

Signature · 1 line
Kees Cook
#2 lore raw
Quoted 8 lines · Kees Cook
Quoted 5 lines · On Sat, 08 Mar 2025 10:27:54 +0800, [email protected] wrote:

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

Quoted 7 lines

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

Quoted 2 lines

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

s/unsiged/unsigned/

:)

Signature · 1 line
Pedro
maintainer
#3 lore raw
Quoted 17 lines · Pedro Falcato
Quoted 8 lines · Kees Cook
Quoted 5 lines · On Sat, 08 Mar 2025 10:27:54 +0800, [email protected] wrote:

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

Quoted 7 lines

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
Quoted 6 lines

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

Quoted 2 lines

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

s/unsiged/unsigned/

D'oh. Fixing in my tree..

Signature · 1 line
Kees Cook