[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] Fix %#0 misuses
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [PATCH v2] Fix %#0 misuses |
Date: |
Thu, 3 Feb 2022 10:59:53 +0000 |
User-agent: |
Mutt/2.1.5 (2021-12-30) |
* 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