[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] Fix %#0 misuses
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH v2] Fix %#0 misuses |
Date: |
Thu, 3 Feb 2022 00:05:16 +0100 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 |
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]'
chardev/baum.c:369: DPRINTF("Broken packet %#2x, tossing\n",
req); \
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);
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? :)
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>