[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c0183559e20747a69c8955bcb619fc07@AcuMS.aculab.com>
Date: Fri, 12 Apr 2019 15:48:18 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Nick Desaulniers' <ndesaulniers@...gle.com>,
Louis Taylor <louis@...gniz.eu>
CC: David Howells <dhowells@...hat.com>,
"linux-afs@...ts.infradead.org" <linux-afs@...ts.infradead.org>,
LKML <linux-kernel@...r.kernel.org>,
"clang-built-linux@...glegroups.com"
<clang-built-linux@...glegroups.com>
Subject: RE: [PATCH v2] afs: use correct format characters
From: Nick Desaulniers
> Sent: 10 April 2019 23:52
> On Wed, Apr 10, 2019 at 3:41 PM Louis Taylor <louis@...gniz.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)
Powered by blists - more mailing lists