2008-08-19 09:43:43

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH] drivers/input/evdev.c: Fix printf() format for sizeof

commit f2afa7711f8585ffc088ba538b9a510e0d5dca12 ("Input: paper over a bug in
Synaptics X driver") introduced a compiler warning on 64-bit platforms, as
sizeof() returns a size_t, not an (unsigned) int:

| drivers/input/evdev.c: In function 'handle_eviocgbit':
| drivers/input/evdev.c:684: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int'

Use the proper `z' modifier for size_t, and make the printf() formats for the
sizes unsigned while we're at it.

Signed-off-by: Geert Uytterhoeven <[email protected]>

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index a92d815..3524bef 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -677,8 +677,8 @@ static int handle_eviocgbit(struct input_dev *dev, unsigned int cmd, void __user
len = OLD_KEY_MAX;
if (printk_timed_ratelimit(&keymax_warn_time, 10 * 1000))
printk(KERN_WARNING
- "evdev.c(EVIOCGBIT): Suspicious buffer size %d, "
- "limiting output to %d bytes. See "
+ "evdev.c(EVIOCGBIT): Suspicious buffer size %u, "
+ "limiting output to %zu bytes. See "
"http://userweb.kernel.org/~dtor/eviocgbit-bug.html\n",
OLD_KEY_MAX,
BITS_TO_LONGS(OLD_KEY_MAX) * sizeof(long));

With kind regards,

Geert Uytterhoeven
Software Architect

Sony Techsoft Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone: +32 (0)2 700 8453
Fax: +32 (0)2 700 8622
E-mail: [email protected]
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis 293-0376800-10 GEBA-BE-BB


2008-08-19 09:57:46

by Rufus & Azrael

[permalink] [raw]
Subject: Re:[PATCH] drivers/input/evdev.c: Fix printf() format for sizeof

Hello Geert,


I have tested your patch and all is now in order for evdev.c,

Thanks.

2008-08-19 15:37:31

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] drivers/input/evdev.c: Fix printf() format for sizeof

On Tue, Aug 19, 2008 at 11:43:32AM +0200, Geert Uytterhoeven wrote:
> commit f2afa7711f8585ffc088ba538b9a510e0d5dca12 ("Input: paper over a bug in
> Synaptics X driver") introduced a compiler warning on 64-bit platforms, as
> sizeof() returns a size_t, not an (unsigned) int:
>
> | drivers/input/evdev.c: In function 'handle_eviocgbit':
> | drivers/input/evdev.c:684: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int'
>
> Use the proper `z' modifier for size_t, and make the printf() formats for the
> sizes unsigned while we're at it.
>

Oops... Applied, thank you Geert.

--
Dmitry