[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdkVBRpOgDdwUQoAA=pUBBZ1AqU_GxUkr7y-566NrXQbNQ@mail.gmail.com>
Date: Thu, 28 Feb 2019 11:19:09 -0800
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Louis Taylor <louis@...gniz.eu>,
Greg KH <gregkh@...uxfoundation.org>
Cc: linux-usb@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
clang-built-linux@...glegroups.com,
Jon Flatley <jflat@...omium.org>,
Stephen Hines <srhines@...gle.com>,
inaky.perez-gonzalez@...el.com, david.vrabel@....com,
Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Subject: Re: [PATCH v2] wusb: use correct format characters
On Thu, Feb 28, 2019 at 4:28 AM Louis Taylor <louis@...gniz.eu> 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')
We should probably update Documentation/core-api/printk-formats.rst to
list [u|s][8|16] printk formats so that I don't have to go read
lib/vsprintf.c#format_decode(). (TODO in a separate patch)
> [-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@...gniz.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..625366d3499e 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",
> + "%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx "
> + "%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx",
Looks like lib/vsprintf.c#format_decode() accepts either %hh or %H for
lone unsigned bytes, IIUC.
Thanks for the patch and for following up on the feedback.
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>
I wonder if __attribute__((packed)) is needed on the definition of
`struct wusb_ckhdid`? hmm...
via Stephen: https://godbolt.org/z/vs5JNo
Looks like alignof(struct wusb_ckhdid) is 1. And struct wusb_ckhdid
was introduced as is in commit c7f736484f8e ("wusb: add the Wireless
USB include files.") so it's not like it ever had additional members
that would disturb the alignment. `__aligned(__alignof__(u8))` might
be clearer than `__attribute__((packed))`, but even then, I don't
think anything is necessary since the alignof should always be 1?
> ckhdid->data[0], ckhdid->data[1],
> ckhdid->data[2], ckhdid->data[3],
> ckhdid->data[4], ckhdid->data[5],
> --
> 2.20.1
>
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists