diff options
author | Evan Green <evgreen@chromium.org> | 2019-08-01 16:04:42 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-05 00:47:33 +0000 |
commit | a41fea6b7df1c83072140c0da9e07f09a8b032e4 (patch) | |
tree | 283880db1385c93420de304b410a3bccafa90971 /common/memory_commands.c | |
parent | 4a29d2ecf4392cb995548e8f174cc85bac8361c1 (diff) | |
download | chrome-ec-a41fea6b7df1c83072140c0da9e07f09a8b032e4.tar.gz |
printf: Fix up %p to %pP
In order to avoid landmines later with future extensions to %p,
disallow %p by itself. The danger is that we'll have something
like: printf("%pFOO", myptr), and then later will add a %pF
extension, but miss this printf (maybe the string is split, maybe
it's just missed).
Missing a conversion during extension is worse than just seeing a
print like <ptr_val>OO, since %pF likely reaches through the
pointer and interprets its contents according to whatever F means.
Convert existing uses of %p to %pP, so they're explicitly printing
a pointer value, giving us flexibility to extend in the future.
BUG=chromium:984041
TEST=make -j buildall
BRANCH=None
Cq-Depend:chrome-internal:1560879
Change-Id: I36a4bee8d41cb9a6139171f8de0d8f2f19468132
Signed-off-by: Evan Green <evgreen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1730604
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'common/memory_commands.c')
-rw-r--r-- | common/memory_commands.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/common/memory_commands.c b/common/memory_commands.c index d946ad6e24..6a6455acdc 100644 --- a/common/memory_commands.c +++ b/common/memory_commands.c @@ -147,16 +147,16 @@ static int command_read_word(int argc, char **argv) if ((argc - argc_offs) < 3) { switch (access_size) { case 1: - ccprintf("read 0x%p = 0x%02x\n", + ccprintf("read 0x%pP = 0x%02x\n", address, *((uint8_t *)address)); break; case 2: - ccprintf("read 0x%p = 0x%04x\n", + ccprintf("read 0x%pP = 0x%04x\n", address, *((uint16_t *)address)); break; default: - ccprintf("read 0x%p = 0x%08x\n", address, *address); + ccprintf("read 0x%pP = 0x%08x\n", address, *address); break; } return EC_SUCCESS; @@ -169,17 +169,17 @@ static int command_read_word(int argc, char **argv) switch (access_size) { case 1: - ccprintf("write 0x%p = 0x%02x\n", address, (uint8_t)value); + ccprintf("write 0x%pP = 0x%02x\n", address, (uint8_t)value); cflush(); /* Flush before writing in case this crashes */ *((uint8_t *)address) = (uint8_t)value; break; case 2: - ccprintf("write 0x%p = 0x%04x\n", address, (uint16_t)value); + ccprintf("write 0x%pP = 0x%04x\n", address, (uint16_t)value); cflush(); *((uint16_t *)address) = (uint16_t)value; break; default: - ccprintf("write 0x%p = 0x%02x\n", address, value); + ccprintf("write 0x%pP = 0x%02x\n", address, value); cflush(); *address = value; break; |