diff mbox series

wusb: use correct format characters

Message ID 20190228115256.5446-1-louis@kragniz.eu (mailing list archive)
State Superseded
Headers show
Series wusb: use correct format characters | expand

Commit Message

Louis Taylor Feb. 28, 2019, 11:52 a.m. UTC
When compiling with -Wformat, clang warns:

./include/linux/usb/wusb.h:245:5: warning: format specifies type
'unsigned short' but the argument has type 'u8' (aka 'unsigned char')
[-Wformat]
  ckhdid->data[0],  ckhdid->data[1],
  ^~~~~~~~~~~~~~~

ckhdid->data is unconditionally defined as `u8 data[16]`, so this patch
updates the format characters to the correct one for unsigned char types.

Link: https://github.com/ClangBuiltLinux/linux/issues/378
Signed-off-by: Louis Taylor <louis@kragniz.eu>
---
 include/linux/usb/wusb.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Greg KH Feb. 28, 2019, 11:59 a.m. UTC | #1
On Thu, Feb 28, 2019 at 11:52:56AM +0000, Louis Taylor wrote:
> When compiling with -Wformat, clang warns:
> 
> ./include/linux/usb/wusb.h:245:5: warning: format specifies type
> 'unsigned short' but the argument has type 'u8' (aka 'unsigned char')
> [-Wformat]
>   ckhdid->data[0],  ckhdid->data[1],
>   ^~~~~~~~~~~~~~~
> 
> ckhdid->data is unconditionally defined as `u8 data[16]`, so this patch
> updates the format characters to the correct one for unsigned char types.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/378
> Signed-off-by: Louis Taylor <louis@kragniz.eu>
> ---
>  include/linux/usb/wusb.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/usb/wusb.h b/include/linux/usb/wusb.h
> index 9e4a3213f2c2..0a3cdf10972d 100644
> --- a/include/linux/usb/wusb.h
> +++ b/include/linux/usb/wusb.h
> @@ -240,8 +240,8 @@ static inline size_t ckhdid_printf(char *pr_ckhdid, size_t size,
>  				   const struct wusb_ckhdid *ckhdid)
>  {
>  	return scnprintf(pr_ckhdid, size,
> -			 "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx "
> -			 "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
> +			 "%02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu "
> +			 "%02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu",

Why did you switch from hex to decimal in the output format?  That feels
very wrong to me.

greg k-h
Test March 5, 2019, 4:21 p.m. UTC | #2
Test

Am 28.02.19 um 12:52 schrieb Louis Taylor:
> When compiling with -Wformat, clang warns:
>
> ./include/linux/usb/wusb.h:245:5: warning: format specifies type
> 'unsigned short' but the argument has type 'u8' (aka 'unsigned char')
> [-Wformat]
>   ckhdid->data[0],  ckhdid->data[1],
>   ^~~~~~~~~~~~~~~
>
> ckhdid->data is unconditionally defined as `u8 data[16]`, so this patch
> updates the format characters to the correct one for unsigned char types.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/378
> Signed-off-by: Louis Taylor <louis@kragniz.eu>
> ---
>  include/linux/usb/wusb.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/usb/wusb.h b/include/linux/usb/wusb.h
> index 9e4a3213f2c2..0a3cdf10972d 100644
> --- a/include/linux/usb/wusb.h
> +++ b/include/linux/usb/wusb.h
> @@ -240,8 +240,8 @@ static inline size_t ckhdid_printf(char *pr_ckhdid, size_t size,
>  				   const struct wusb_ckhdid *ckhdid)
>  {
>  	return scnprintf(pr_ckhdid, size,
> -			 "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx "
> -			 "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
> +			 "%02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu "
> +			 "%02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu",
>  			 ckhdid->data[0],  ckhdid->data[1],
>  			 ckhdid->data[2],  ckhdid->data[3],
>  			 ckhdid->data[4],  ckhdid->data[5],
Test March 5, 2019, 4:28 p.m. UTC | #3
Hallo

Am 28.02.19 um 12:52 schrieb Louis Taylor:
> When compiling with -Wformat, clang warns:
>
> ./include/linux/usb/wusb.h:245:5: warning: format specifies type
> 'unsigned short' but the argument has type 'u8' (aka 'unsigned char')
> [-Wformat]
>   ckhdid->data[0],  ckhdid->data[1],
>   ^~~~~~~~~~~~~~~
>
> ckhdid->data is unconditionally defined as `u8 data[16]`, so this patch
> updates the format characters to the correct one for unsigned char types.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/378
> Signed-off-by: Louis Taylor <louis@kragniz.eu>
> ---
>  include/linux/usb/wusb.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/usb/wusb.h b/include/linux/usb/wusb.h
> index 9e4a3213f2c2..0a3cdf10972d 100644
> --- a/include/linux/usb/wusb.h
> +++ b/include/linux/usb/wusb.h
> @@ -240,8 +240,8 @@ static inline size_t ckhdid_printf(char *pr_ckhdid, size_t size,
>  				   const struct wusb_ckhdid *ckhdid)
>  {
>  	return scnprintf(pr_ckhdid, size,
> -			 "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx "
> -			 "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
> +			 "%02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu "
> +			 "%02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu",
>  			 ckhdid->data[0],  ckhdid->data[1],
>  			 ckhdid->data[2],  ckhdid->data[3],
>  			 ckhdid->data[4],  ckhdid->data[5],
diff mbox series

Patch

diff --git a/include/linux/usb/wusb.h b/include/linux/usb/wusb.h
index 9e4a3213f2c2..0a3cdf10972d 100644
--- a/include/linux/usb/wusb.h
+++ b/include/linux/usb/wusb.h
@@ -240,8 +240,8 @@  static inline size_t ckhdid_printf(char *pr_ckhdid, size_t size,
 				   const struct wusb_ckhdid *ckhdid)
 {
 	return scnprintf(pr_ckhdid, size,
-			 "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx "
-			 "%02hx %02hx %02hx %02hx %02hx %02hx %02hx %02hx",
+			 "%02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu "
+			 "%02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu %02hhu",
 			 ckhdid->data[0],  ckhdid->data[1],
 			 ckhdid->data[2],  ckhdid->data[3],
 			 ckhdid->data[4],  ckhdid->data[5],