netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Tom Rix' <trix@redhat.com>, Joe Perches <joe@perches.com>,
	Simon Horman <simon.horman@netronome.com>
Cc: "kuba@kernel.org" <kuba@kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"ast@kernel.org" <ast@kernel.org>,
	"daniel@iogearbox.net" <daniel@iogearbox.net>,
	"andrii@kernel.org" <andrii@kernel.org>,
	"kafai@fb.com" <kafai@fb.com>,
	"songliubraving@fb.com" <songliubraving@fb.com>,
	"yhs@fb.com" <yhs@fb.com>,
	"john.fastabend@gmail.com" <john.fastabend@gmail.com>,
	"kpsingh@kernel.org" <kpsingh@kernel.org>,
	"gustavoars@kernel.org" <gustavoars@kernel.org>,
	"louis.peens@netronome.com" <louis.peens@netronome.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"oss-drivers@netronome.com" <oss-drivers@netronome.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] nfp: remove h from printk format specifier
Date: Sat, 26 Dec 2020 20:40:48 +0000	[thread overview]
Message-ID: <bf541f5de2624693ae96887afbfd04bc@AcuMS.aculab.com> (raw)
In-Reply-To: <7b5517e6-41a9-cc7f-f42f-8ef449f3898e@redhat.com>

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)

      parent reply	other threads:[~2020-12-26 20:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23 20:20 [PATCH] nfp: remove h from printk format specifier trix
2020-12-24 20:21 ` Simon Horman
2020-12-24 22:14   ` Tom Rix
2020-12-24 22:39     ` Joe Perches
2020-12-25 14:56       ` Tom Rix
2020-12-25 17:06         ` Joe Perches
2020-12-25 22:13           ` Tom Rix
2020-12-25 23:00             ` Joe Perches
2020-12-26 20:40         ` David Laight [this message]

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=bf541f5de2624693ae96887afbfd04bc@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=gustavoars@kernel.org \
    --cc=joe@perches.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=louis.peens@netronome.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    --cc=simon.horman@netronome.com \
    --cc=songliubraving@fb.com \
    --cc=trix@redhat.com \
    --cc=yhs@fb.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).