linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jon Flatley <jflat@chromium.org>
To: Joe Perches <joe@perches.com>
Cc: Jon Flatley <jflat@chromium.org>, Louis Taylor <louis@kragniz.eu>,
	gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	clang-built-linux@googlegroups.com,
	Nick Desaulniers <ndesaulniers@google.com>
Subject: Re: [PATCH v2] wusb: use correct format characters
Date: Thu, 28 Feb 2019 16:03:55 -0800	[thread overview]
Message-ID: <CACJJ=pz50c3oovHbKkjDDF=pabAj_9RtKGWvtpwx4nO+E_EtJg@mail.gmail.com> (raw)
In-Reply-To: <1450785b937f4a2b5f98c8548986b162684a719b.camel@perches.com>

On Thu, Feb 28, 2019 at 3:05 PM Joe Perches <joe@perches.com> wrote:
>
> On Thu, 2019-02-28 at 14:23 -0800, Jon Flatley wrote:
> > Thanks for the patch and comments.
> >
> > On Thu, Feb 28, 2019 at 1:53 PM Joe Perches <joe@perches.com> wrote:
> > > On Thu, 2019-02-28 at 12:24 +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],
> > > >   ^~~~~~~~~~~~~~~
> > >
> > > I think the message is somewhat misguided as all the
> > > vararg arguments have implicit integer promotions.
> >
> > That's a fair point, but Clang checks the arguments against their
> > format specifier before they're promoted when using -Wformat.
>
> Perhaps clang could be a bit more verbose if
> checking signed types emitted as unsigned or
> unsigned types emitted as signed instead.

It is a little strange that clang warns when the length specifier
doesn't match but not when an unsigned specifier is used for a signed
value and vice versa.
>
> > When
> > considering integer promotions it's difficult to say if this is
> > "wrong",
>
> I didn't write "wrong", I wrote misguided.

Apologies for my poor wording. I meant "wrong" in the sense that it's
unclear if an improper length specifier is deserving of a warning.
After all GCC doesn't warn for incorrect length specifiers, and as you
pointed out Clang doesn't pay attention to if the specifier expects a
signed or unsigned value.

Cheers,
Jon

  reply	other threads:[~2019-03-01  0:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28 11:52 [PATCH] wusb: use correct format characters Louis Taylor
2019-02-28 11:59 ` Greg KH
2019-02-28 12:24 ` [PATCH v2] " Louis Taylor
2019-02-28 19:19   ` Nick Desaulniers
2019-02-28 21:53   ` Joe Perches
2019-02-28 22:23     ` Jon Flatley
2019-02-28 23:05       ` Joe Perches
2019-03-01  0:03         ` Jon Flatley [this message]
2019-03-01  4:38           ` [PATCH] wusb: Remove unnecessary static function ckhdid_printf Joe Perches
2019-03-01 11:15             ` Louis Taylor
2019-03-01 18:18             ` Nick Desaulniers
2019-03-01 19:54               ` Greg KH
2019-03-05 16:21 ` [PATCH] wusb: use correct format characters Test
2019-03-05 16:28 ` Test

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACJJ=pz50c3oovHbKkjDDF=pabAj_9RtKGWvtpwx4nO+E_EtJg@mail.gmail.com' \
    --to=jflat@chromium.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=louis@kragniz.eu \
    --cc=ndesaulniers@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).