diff mbox series

x86/vdso: fix a warning with x32 compiler

Message ID alpine.LRH.2.02.2101230548050.21951@file01.intranet.prod.int.rdu2.redhat.com (mailing list archive)
State New, archived
Headers show
Series x86/vdso: fix a warning with x32 compiler | expand

Commit Message

Mikulas Patocka Jan. 23, 2021, 10:50 a.m. UTC
This patch fixes a warning:
arch/x86/entry/vdso/vdso2c.h:38:52: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
when compiling the kernel with x32 compiler.

The reason for the warning is that in x32 mode, size_t is defined as
unsigned, not unsigned long.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: 8382c668ce4f ("x86/vdso: Add support for exception fixup in vDSO functions")

---
 arch/x86/entry/vdso/vdso2c.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jarkko Sakkinen Jan. 25, 2021, 5:14 p.m. UTC | #1
On Sat, Jan 23, 2021 at 05:50:31AM -0500, Mikulas Patocka wrote:
> This patch fixes a warning:
> arch/x86/entry/vdso/vdso2c.h:38:52: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
> when compiling the kernel with x32 compiler.
> 
> The reason for the warning is that in x32 mode, size_t is defined as
> unsigned, not unsigned long.
> 
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> Fixes: 8382c668ce4f ("x86/vdso: Add support for exception fixup in vDSO functions")

So... Why not %zu?

/Jarkko
Mikulas Patocka Jan. 25, 2021, 5:26 p.m. UTC | #2
On Mon, 25 Jan 2021, Jarkko Sakkinen wrote:

> On Sat, Jan 23, 2021 at 05:50:31AM -0500, Mikulas Patocka wrote:
> > This patch fixes a warning:
> > arch/x86/entry/vdso/vdso2c.h:38:52: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=]
> > when compiling the kernel with x32 compiler.
> > 
> > The reason for the warning is that in x32 mode, size_t is defined as
> > unsigned, not unsigned long.
> > 
> > Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> > Fixes: 8382c668ce4f ("x86/vdso: Add support for exception fixup in vDSO functions")
> 
> So... Why not %zu?
> 
> /Jarkko

You can use %zu - it doesn't matter, size_t has the same size as unsigned 
long on all supported architectures.

Mikulas
diff mbox series

Patch

Index: linux-2.6/arch/x86/entry/vdso/vdso2c.h
===================================================================
--- linux-2.6.orig/arch/x86/entry/vdso/vdso2c.h	2021-01-07 17:22:39.000000000 +0100
+++ linux-2.6/arch/x86/entry/vdso/vdso2c.h	2021-01-23 10:44:09.000000000 +0100
@@ -27,10 +27,10 @@  static void BITSFUNC(extract)(const unsi
 			      FILE *outfile, ELF(Shdr) *sec, const char *name)
 {
 	unsigned long offset;
-	size_t len;
+	unsigned long len;
 
 	offset = (unsigned long)GET_LE(&sec->sh_offset);
-	len = (size_t)GET_LE(&sec->sh_size);
+	len = GET_LE(&sec->sh_size);
 
 	if (offset + len > data_len)
 		fail("section to extract overruns input data");