All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: qemu-devel@nongnu.org, shorne@gmail.com,
	richard.henderson@linaro.org, qemu-trivial@nongnu.org
Subject: Re: [PATCH v2] Fix %#0 misuses
Date: Thu, 3 Feb 2022 10:59:53 +0000	[thread overview]
Message-ID: <Yfu1qfCH73D4zA1l@work-vm> (raw)
In-Reply-To: <77c6899b-5892-5aaa-97ee-a79a74928c09@amsat.org>

* Philippe Mathieu-Daudé (f4bug@amsat.org) wrote:
> On 2/2/22 19:34, Dr. David Alan Gilbert (git) wrote:
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> > 
> > Joe Perches pointed out on lkml [1] that the format special %# (which
> > adds 0x) is included in the character count, i.e.:
> > 
> >    printf("0: %#08x\n0: %#08x\n", 0xabcdef01,1);
> > gives:
> > 0: 0xabcdef01
> > 0: 0x000001
> > 
> > rather than padding to the expected 8 data characters.
> > 
> > Replace all the '%#08' cases by '0x%08' and
> > also handle a '%#02'; there are some other cases mostly
> > in testing and a few that look like the authors have
> > thought about the size, that I've ignored for now.
> > 
> > (Note I've not managed to test most of these)
> > 
> > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> > 
> > [1] https://lore.kernel.org/lkml/9499203f1e993872b384aabdec59ac223a8ab931.camel@perches.com/
> > 
> > Fixup %#
> > ---
> >   chardev/baum.c          | 2 +-
> >   disas/alpha.c           | 2 +-
> >   disas/sparc.c           | 2 +-
> >   hw/arm/omap1.c          | 2 +-
> >   hw/timer/a9gtimer.c     | 4 ++--
> >   include/hw/arm/omap.h   | 5 +++--
> >   softmmu/device_tree.c   | 2 +-
> >   target/openrisc/disas.c | 2 +-
> >   8 files changed, 11 insertions(+), 10 deletions(-)
> 
> Few more:
> 
> $ git grep -E '\%#[0-9]{1,2}[dDxX]'

Thanks, actually 1,3 is worth it :-)

> chardev/baum.c:369:            DPRINTF("Broken packet %#2x, tossing\n",
> req); \

Interestingly without the 0

> disas/alpha.c:1854:  (*info->fprintf_func) (info->stream, ".long %#08x",
> insn);
> hw/audio/ac97.c:244:    dolog ("bd %2d addr=%#x ctl=%#06x len=%#x(%d
> bytes)\n",
> hw/dma/i8257.c:265:        linfo ("write_cont: nport %#06x, ichan % 2d, val
> %#06x\n",
> hw/dma/i8257.c:290:    ldebug ("read_cont: nport %#06x, iport %#04x val
> %#x\n", nport, iport, val);

So some of these are a bit weird and might need thinking about; I
*think* they're 06 because the author realised the 0x was counted and
bumped it up from 04; but that actually means I'd need to understand the
device code before changing it.

> softmmu/device_tree.c:372:        error_report("%s: Couldn't set %s/%s =
> %#08x: %s", __func__,
> target/openrisc/disas.c:48:        output(".long", "%#08x", insn);
> tests/qemu-iotests/nbd-fault-injector.py:187: print('unrecognized command
> type %#02x' % req.type)
> tests/tcg/arm/fcvt.c:60:    printf("%02d   HALF: %#04x  (%#x => %s)\n",
> tests/tcg/multiarch/libs/float_helpers.c:72:    asprintf(&fmt, "f16(%#04x)",
> num);
> 
> In mood to add a regexp to checkpatch? :)

I think it already has one for new patches.

> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Thanks!

Dave

-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



      reply	other threads:[~2022-02-03 11:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-02 18:34 [PATCH v2] Fix %#0 misuses Dr. David Alan Gilbert (git)
2022-02-02 23:05 ` Philippe Mathieu-Daudé
2022-02-03 10:59   ` Dr. David Alan Gilbert [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=Yfu1qfCH73D4zA1l@work-vm \
    --to=dgilbert@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=shorne@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.