LKML Archive on lore.kernel.org
 help / color / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Nick Desaulniers' <ndesaulniers@google.com>,
	Louis Taylor <louis@kragniz.eu>
Cc: David Howells <dhowells@redhat.com>,
	"linux-afs@lists.infradead.org" <linux-afs@lists.infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"clang-built-linux@googlegroups.com" 
	<clang-built-linux@googlegroups.com>
Subject: RE: [PATCH v2] afs: use correct format characters
Date: Fri, 12 Apr 2019 15:48:18 +0000
Message-ID: <c0183559e20747a69c8955bcb619fc07@AcuMS.aculab.com> (raw)
In-Reply-To: <CAKwvOdmCHfRZ8miaCie=f2Fd_2QoJAnhS7TC8T0NYyQdcop9zA@mail.gmail.com>

From: Nick Desaulniers
> Sent: 10 April 2019 23:52
> On Wed, Apr 10, 2019 at 3:41 PM Louis Taylor <louis@kragniz.eu> wrote:
> >
> > When compiling with -Wformat, clang warns:
> >
> > fs/afs/flock.c:632:29: warning: format specifies type 'short' but the argument has type
> >       'unsigned char' [-Wformat]
> >         _leave(" = %d [%hd]", ret, fl->fl_type);
> >                        ~~~         ^~~~~~~~~~~
> >
> > fs/afs/dir.c:138:11: warning: format specifies type 'unsigned short' but
> > the argument has type 'int' [-Wformat]
> >        ntohs(dbuf->blocks[tmp].hdr.magic));
> >        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > fl_type is declared as an unsigned char unconditionally in
> > include/linux/fs.h, so use the correct format characters.
> 
> Thanks for the v2, probably should include a note about ntohs.  That
> case in particular looks more complicated, due to the definition of
> ntohs (which uses __swab16).
> 
> If you keep the previous flag of %04hx, but add an explicit cast to
> u16, does the warning go away? If so, that might be a better fix.
> 
> - ntohs(dbuf->blocks[tmp].hdr.magic));
> + (u16)ntohs(dbuf->blocks[tmp].hdr.magic));

Or just append '+ 0u' forcing the type to 'unsigned int'.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-10 22:03 [PATCH] " Louis Taylor
2019-04-10 22:27 ` Nick Desaulniers
2019-04-10 22:41 ` [PATCH v2] " Louis Taylor
2019-04-10 22:52   ` Nick Desaulniers
2019-04-12 15:48     ` David Laight [this message]
2019-04-10 23:00 ` [PATCH] " Joe Perches
2019-04-11 16:31   ` Linus Torvalds
2019-04-11 17:41     ` Nick Desaulniers

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=c0183559e20747a69c8955bcb619fc07@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=dhowells@redhat.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git
	git clone --mirror https://lore.kernel.org/lkml/10 lkml/git/10.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git