Skip to contentSkip to conversation

binfmt_flat: Use %u to format u32

PATCH New Geert Uytterhoeven 1 participant 5 messages Jul 16, 2017

Subsystems (3)
lore
Share & tools
lore

Geert Uytterhoeven

author maintainer
#0 lore raw

PATCH 1/3 binfmt_flat: Use %u to format u32

Several variables had their types changed from unsigned long to u32, but the printk()-style format to print them wasn't updated, leading to:

fs/binfmt_flat.c: In function ‘load_flat_file’:
fs/binfmt_flat.c:577: warning: format ‘%ld’ expects type ‘long int’, but argument 3 has type ‘u32’

Fixes 468138d78510688f ("binfmt_flat: flat_{get,put}_addr_from_rp() should be able to fail")
---
 fs/binfmt_flat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_flat.c +1 -1
index 69ec23daa25e003f..a1e6860b6f46a091 100644
@@ -574,7 +574,7 @@ static int load_flat_file(struct linux_binprm *bprm,
 				MAX_SHARED_LIBS * sizeof(unsigned long),
 				FLAT_DATA_ALIGN);
 
-		pr_debug("Allocated data+bss+stack (%ld bytes): %lx\n",
+		pr_debug("Allocated data+bss+stack (%u bytes): %lx\n",
 			 data_len + bss_len + stack_len, datapos);
 
 		fpos = ntohl(hdr->data_start);
Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH 2/3 blackfin, m68k: Fix flat_set_persistent() for unsigned long to u32 changes

Several variables had their types changed from unsigned long to u32, but the arch-specific implementations of flat_set_persistent() weren't updated, leading to compiler warnings on blackfin and m68k:

fs/binfmt_flat.c: In function ‘load_flat_file’:
fs/binfmt_flat.c:799: warning: passing argument 2 of ‘flat_set_persistent’ from incompatible pointer type

Fixes 468138d78510688f ("binfmt_flat: flat_{get,put}_addr_from_rp() should be able to fail")
---
 arch/blackfin/include/asm/flat.h | 3 +--
 arch/m68k/include/asm/flat.h     | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
arch/blackfin/include/asm/flat.h +1 -2
index 296d7f56fbfd005b..f1d6ba7afbf245a0 100644
@@ -44,8 +44,7 @@ flat_get_relocate_addr (unsigned long relval)
 	return relval & 0x03ffffff; /* Mask out top 6 bits */
 }
 
-static inline int flat_set_persistent(unsigned long relval,
-				      unsigned long *persistent)
+static inline int flat_set_persistent(u32 relval, u32 *persistent)
 {
 	int type = (relval >> 26) & 7;
 	if (type == 3) {
arch/m68k/include/asm/flat.h +1 -2
index 48b62790fe70f1a6..b2a41f5b3890a524 100644
@@ -30,8 +30,7 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel)
 }
 #define	flat_get_relocate_addr(rel)		(rel)
 
-static inline int flat_set_persistent(unsigned long relval,
-				      unsigned long *persistent)
+static inline int flat_set_persistent(u32 relval, u32 *persistent)
 {
 	return 0;
 }
Signature · 1 line
2.7.4
author maintainer
#2 lore raw

PATCH 2/3 blackfin, m68k: Fix flat_set_persistent() for unsigned long to u32 changes

In reply to Geert Uytterhoeven

Several variables had their types changed from unsigned long to u32, but the arch-specific implementations of flat_set_persistent() weren't updated, leading to compiler warnings on blackfin and m68k:

fs/binfmt_flat.c: In function ‘load_flat_file’:
fs/binfmt_flat.c:799: warning: passing argument 2 of ‘flat_set_persistent’ from incompatible pointer type

Fixes 468138d78510688f ("binfmt_flat: flat_{get,put}_addr_from_rp() should be able to fail")
---
 arch/blackfin/include/asm/flat.h | 3 +--
 arch/m68k/include/asm/flat.h     | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
arch/blackfin/include/asm/flat.h +1 -2
index 296d7f56fbfd005b..f1d6ba7afbf245a0 100644
@@ -44,8 +44,7 @@ flat_get_relocate_addr (unsigned long relval)
 	return relval & 0x03ffffff; /* Mask out top 6 bits */
 }
 
-static inline int flat_set_persistent(unsigned long relval,
-				      unsigned long *persistent)
+static inline int flat_set_persistent(u32 relval, u32 *persistent)
 {
 	int type = (relval >> 26) & 7;
 	if (type == 3) {
arch/m68k/include/asm/flat.h +1 -2
index 48b62790fe70f1a6..b2a41f5b3890a524 100644
@@ -30,8 +30,7 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel)
 }
 #define	flat_get_relocate_addr(rel)		(rel)
 
-static inline int flat_set_persistent(unsigned long relval,
-				      unsigned long *persistent)
+static inline int flat_set_persistent(u32 relval, u32 *persistent)
 {
 	return 0;
 }
Signature · 1 line
2.7.4
author maintainer
#3 lore raw

PATCH 3/3 h8300: Add missing closing parenthesis in flat_get_addr_from_rp()

In reply to Geert Uytterhoeven

In file included from include/linux/flat.h:13:0,

                 from fs/binfmt_flat.c:36:

arch/h8300/include/asm/flat.h: In function 'flat_get_addr_from_rp':
arch/h8300/include/asm/flat.h:28:3: error: expected ')' before 'val'
val &= 0x00ffffff;
^
arch/h8300/include/asm/flat.h:31:1: error: expected expression before '}' token
}
^
In file included from include/linux/flat.h:13:0,

                 from fs/binfmt_flat.c:36:
arch/h8300/include/asm/flat.h:26:6: warning: unused variable 'val' [-Wunused-variable]
  u32 val = get_unaligned((__force u32 *)rp);
      ^
In file included from include/linux/flat.h:13:0,
                 from fs/binfmt_flat.c:36:

arch/h8300/include/asm/flat.h:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^

Fixes 468138d78510688f ("binfmt_flat: flat_{get,put}_addr_from_rp() should be able to fail")
---
 arch/h8300/include/asm/flat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/h8300/include/asm/flat.h +1 -1
index 18d024251738dd4e..7e0bd6fa15324495 100644
@@ -24,7 +24,7 @@ static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
 					u32 *addr, u32 *persistent)
 {
 	u32 val = get_unaligned((__force u32 *)rp);
-	if (!(flags & FLAT_FLAG_GOTPIC)
+	if (!(flags & FLAT_FLAG_GOTPIC))
 		val &= 0x00ffffff;
 	*addr = val;
 	return 0;
Signature · 1 line
2.7.4
author maintainer
#4 lore raw

PATCH 3/3 h8300: Add missing closing parenthesis in flat_get_addr_from_rp()

In reply to Geert Uytterhoeven

In file included from include/linux/flat.h:13:0,

                 from fs/binfmt_flat.c:36:

arch/h8300/include/asm/flat.h: In function 'flat_get_addr_from_rp':
arch/h8300/include/asm/flat.h:28:3: error: expected ')' before 'val'
val &= 0x00ffffff;
^
arch/h8300/include/asm/flat.h:31:1: error: expected expression before '}' token
}
^
In file included from include/linux/flat.h:13:0,

                 from fs/binfmt_flat.c:36:
arch/h8300/include/asm/flat.h:26:6: warning: unused variable 'val' [-Wunused-variable]
  u32 val = get_unaligned((__force u32 *)rp);
      ^
In file included from include/linux/flat.h:13:0,
                 from fs/binfmt_flat.c:36:

arch/h8300/include/asm/flat.h:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^

Fixes 468138d78510688f ("binfmt_flat: flat_{get,put}_addr_from_rp() should be able to fail")
---
 arch/h8300/include/asm/flat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/h8300/include/asm/flat.h +1 -1
index 18d024251738dd4e..7e0bd6fa15324495 100644
@@ -24,7 +24,7 @@ static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags,
 					u32 *addr, u32 *persistent)
 {
 	u32 val = get_unaligned((__force u32 *)rp);
-	if (!(flags & FLAT_FLAG_GOTPIC)
+	if (!(flags & FLAT_FLAG_GOTPIC))
 		val &= 0x00ffffff;
 	*addr = val;
 	return 0;
Signature · 1 line
2.7.4