Re: [PATCH] input: Fix format string for verify_internal_event

2011-05-16 Thread Mark Kettenis
On Sat, May 14, 2011 at 04:31:10PM -0700, Jeremy Huddleston wrote:
 
 inpututils.c:577:25: warning: conversion specifies type 'unsigned short' but 
 the argument has type 'unsigned char' [-Wformat,Format String Issue]
 ErrorF(%02hx , *data);
 ^~
 %02hhx
 1 warning generated.

While the fix isn't wrong, it's odd that clang complains about this.
Since ErrorF is a varargs function, *data will be promoted to int, so
while printing it with %02hx is a bit odd, it is perfectly legal C.
Because of the integer promotion, I would actually simply use %02x
here, since I think the h and hh length modifiers are a bit obscure.
Would clang complain about using %02x as well?
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: [PATCH] input: Fix format string for verify_internal_event

2011-05-16 Thread Jeremy Huddleston

On May 16, 2011, at 01:13, Mark Kettenis wrote:

 On Sat, May 14, 2011 at 04:31:10PM -0700, Jeremy Huddleston wrote:
 
 inpututils.c:577:25: warning: conversion specifies type 'unsigned short' but 
 the argument has type 'unsigned char' [-Wformat,Format String Issue]
ErrorF(%02hx , *data);
^~
%02hhx
 1 warning generated.
 
 While the fix isn't wrong, it's odd that clang complains about this.
 Since ErrorF is a varargs function, *data will be promoted to int, so
 while printing it with %02hx is a bit odd, it is perfectly legal C.
 Because of the integer promotion, I would actually simply use %02x
 here, since I think the h and hh length modifiers are a bit obscure.
 Would clang complain about using %02x as well?

Yes, and I believe gcc will complain about it as well if you specify a strict 
enough -Wformat.  The warning is there to ensure that you know what you are 
doing.  Yes, functionally they probably result in the bits output, but 
eliminating warnings helps the important ones stand out more.

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: [PATCH] input: Fix format string for verify_internal_event

2011-05-15 Thread Peter Hutterer
On Sat, May 14, 2011 at 04:31:10PM -0700, Jeremy Huddleston wrote:
 
 inpututils.c:577:25: warning: conversion specifies type 'unsigned short' but 
 the argument has type 'unsigned char' [-Wformat,Format String Issue]
 ErrorF(%02hx , *data);
 ^~
 %02hhx
 1 warning generated.
 
 Signed-off-by: Jeremy Huddleston jerem...@apple.com
 ---
  dix/inpututils.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/dix/inpututils.c b/dix/inpututils.c
 index aeace6e..49e1758 100644
 --- a/dix/inpututils.c
 +++ b/dix/inpututils.c
 @@ -574,7 +574,7 @@ void verify_internal_event(const InternalEvent *ev)
  
  for (i = 0; i  sizeof(xEvent); i++, data++)
  {
 -ErrorF(%02hx , *data);
 +ErrorF(%02hhx , *data);
  
  if ((i % 8) == 7)
  ErrorF(\n);
 -- 
 1.7.4.1

merged, thanks.
 
Cheers,
  Peter
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH] input: Fix format string for verify_internal_event

2011-05-14 Thread Jeremy Huddleston

inpututils.c:577:25: warning: conversion specifies type 'unsigned short' but 
the argument has type 'unsigned char' [-Wformat,Format String Issue]
ErrorF(%02hx , *data);
^~
%02hhx
1 warning generated.

Signed-off-by: Jeremy Huddleston jerem...@apple.com
---
 dix/inpututils.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dix/inpututils.c b/dix/inpututils.c
index aeace6e..49e1758 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -574,7 +574,7 @@ void verify_internal_event(const InternalEvent *ev)
 
 for (i = 0; i  sizeof(xEvent); i++, data++)
 {
-ErrorF(%02hx , *data);
+ErrorF(%02hhx , *data);
 
 if ((i % 8) == 7)
 ErrorF(\n);
-- 
1.7.4.1


___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel