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 /chip | |
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 'chip')
-rw-r--r-- | chip/g/dcrypto/app_cipher.c | 2 | ||||
-rw-r--r-- | chip/g/flash.c | 2 | ||||
-rw-r--r-- | chip/g/system.c | 2 | ||||
-rw-r--r-- | chip/nrf51/bluetooth_le.c | 4 |
4 files changed, 5 insertions, 5 deletions
diff --git a/chip/g/dcrypto/app_cipher.c b/chip/g/dcrypto/app_cipher.c index bc55705f32..2d95173c8f 100644 --- a/chip/g/dcrypto/app_cipher.c +++ b/chip/g/dcrypto/app_cipher.c @@ -260,7 +260,7 @@ static int prepare_running(struct test_info *pinfo) pinfo->test_blob_size |= 7; ccprintf("running %d iterations\n", number_of_iterations); - ccprintf("blob size %d at %p\n", pinfo->test_blob_size, pinfo->p); + ccprintf("blob size %d at %pP\n", pinfo->test_blob_size, pinfo->p); init_stats(&(pinfo->enc_stats)); init_stats(&(pinfo->dec_stats)); diff --git a/chip/g/flash.c b/chip/g/flash.c index fbf1af83a7..4829c986c8 100644 --- a/chip/g/flash.c +++ b/chip/g/flash.c @@ -270,7 +270,7 @@ static int do_flash_op(enum flash_op op, int is_info_bank, if (errors && (errors != prev_error)) { prev_error = errors; - CPRINTF("%s:%d errors %x fsh_pe_control %p\n", + CPRINTF("%s:%d errors %x fsh_pe_control %pP\n", __func__, __LINE__, errors, fsh_pe_control); } /* Error status is self-clearing. Read it until it does diff --git a/chip/g/system.c b/chip/g/system.c index c2ee5bdabb..1b0c285473 100644 --- a/chip/g/system.c +++ b/chip/g/system.c @@ -476,7 +476,7 @@ static int corrupt_header(volatile struct SignedHeader *header) GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, RD_EN, 1); GWRITE_FIELD(GLOBALSEC, FLASH_REGION6_CTRL, WR_EN, 1); - CPRINTS("%s: RW fallback must have happened, magic at %p before: %x", + CPRINTS("%s: RW fallback must have happened, magic at %pP before: %x", __func__, &header->magic, header->magic); rv = flash_physical_write((intptr_t)&header->magic - diff --git a/chip/nrf51/bluetooth_le.c b/chip/nrf51/bluetooth_le.c index 1c18a8a84f..6fe123ac4e 100644 --- a/chip/nrf51/bluetooth_le.c +++ b/chip/nrf51/bluetooth_le.c @@ -453,7 +453,7 @@ static int command_ble_adv(int argc, char **argv) rv = ble_radio_init(BLE_ADV_ACCESS_ADDRESS, BLE_ADV_CRCINIT); - CPRINTS("ADV @%p", &adv_packet); + CPRINTS("ADV @%pP", &adv_packet); ((uint32_t *)&addr)[0] = 0xA3A2A1A0 | type; ((uint32_t *)&addr)[1] = BLE_RANDOM_ADDR_MSBS_STATIC << 8 | 0x5A4; @@ -527,7 +527,7 @@ static int command_ble_adv_scan(int argc, char **argv) rv = radio_disable(); - CPRINTS("on_air payload rcvd %p", &rx_packet); + CPRINTS("on_air payload rcvd %pP", &rx_packet); return rv; } |