[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <bf541f5de2624693ae96887afbfd04bc@AcuMS.aculab.com>
Date: Sat, 26 Dec 2020 20:40:48 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Tom Rix' <trix@...hat.com>, Joe Perches <joe@...ches.com>,
Simon Horman <simon.horman@...ronome.com>
CC: "kuba@...nel.org" <kuba@...nel.org>,
"davem@...emloft.net" <davem@...emloft.net>,
"ast@...nel.org" <ast@...nel.org>,
"daniel@...earbox.net" <daniel@...earbox.net>,
"andrii@...nel.org" <andrii@...nel.org>,
"kafai@...com" <kafai@...com>,
"songliubraving@...com" <songliubraving@...com>,
"yhs@...com" <yhs@...com>,
"john.fastabend@...il.com" <john.fastabend@...il.com>,
"kpsingh@...nel.org" <kpsingh@...nel.org>,
"gustavoars@...nel.org" <gustavoars@...nel.org>,
"louis.peens@...ronome.com" <louis.peens@...ronome.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"bpf@...r.kernel.org" <bpf@...r.kernel.org>,
"oss-drivers@...ronome.com" <oss-drivers@...ronome.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] nfp: remove h from printk format specifier
From: Tom Rix
> Sent: 25 December 2020 14:57
...
> > Kernel code doesn't use a signed char or short with %hx or %hu very often
> > but in case you didn't already know, any signed char/short emitted with
> > anything like %hx or %hu needs to be left alone as sign extension occurs so:
>
> Yes, this would also effect checkpatch.
Does the kernel printf do the masking for %hx and %hhx?
A quick check I did showed that (at least some versions of) glibc does.
But the printf builtin in bash doesn't.
If the masking is there then %h[diux] and %hh[diux] are valid
even though the varargs supplied parameter is always extended to
at least the size of int.
This is even true if the parameter might be large.
For instance doing:
..., "%hh02x:%hh02x:%hh02x:%hh02x", x >> 24, x >> 16, x >> 8, x);
will generate slightly smaller code than masking the passed values.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists