summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorEvan Green <evgreen@chromium.org>2019-08-01 16:04:42 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-05 00:47:33 +0000
commita41fea6b7df1c83072140c0da9e07f09a8b032e4 (patch)
tree283880db1385c93420de304b410a3bccafa90971 /common
parent4a29d2ecf4392cb995548e8f174cc85bac8361c1 (diff)
downloadchrome-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')
-rw-r--r--common/bluetooth_le.c4
-rw-r--r--common/btle_hci_controller.c6
-rw-r--r--common/btle_ll.c2
-rw-r--r--common/hooks.c2
-rw-r--r--common/memory_commands.c12
-rw-r--r--common/new_nvmem.c2
6 files changed, 14 insertions, 14 deletions
diff --git a/common/bluetooth_le.c b/common/bluetooth_le.c
index bbc035a49d..5e611d1dd1 100644
--- a/common/bluetooth_le.c
+++ b/common/bluetooth_le.c
@@ -160,7 +160,7 @@ void dump_ble_packet(struct ble_pdu *ble_p)
int curr_offs;
if (ble_p->header_type_adv) {
- CPRINTF("BLE packet @ %p: type %d, len %d, %s %s\n",
+ CPRINTF("BLE packet @ %pP: type %d, len %d, %s %s\n",
ble_p, ble_p->header.adv.type, ble_p->header.adv.length,
(ble_p->header.adv.txaddr ? " TXADDR" : ""),
(ble_p->header.adv.rxaddr ? " RXADDR" : ""));
@@ -187,7 +187,7 @@ void dump_ble_packet(struct ble_pdu *ble_p)
mem_dump(ble_p->payload + curr_offs,
ble_p->header.adv.length - curr_offs);
} else { /* Data PDUs */
- CPRINTF("BLE data packet @%p: LLID %d,"
+ CPRINTF("BLE data packet @%pP: LLID %d,"
" nesn %d, sn %d, md %d, length %d\n",
ble_p, ble_p->header.data.llid, ble_p->header.data.nesn,
ble_p->header.data.sn, ble_p->header.data.md,
diff --git a/common/btle_hci_controller.c b/common/btle_hci_controller.c
index 3d4076b073..903e9d5624 100644
--- a/common/btle_hci_controller.c
+++ b/common/btle_hci_controller.c
@@ -503,7 +503,7 @@ static int command_ble_hci_cmd(int argc, char **argv)
hci_cmd(hci_buf);
- CPRINTS("hci cmd @%p", hci_buf);
+ CPRINTS("hci cmd @%pP", hci_buf);
return EC_SUCCESS;
}
@@ -543,7 +543,7 @@ static int command_hcitool(int argc, char **argv)
hci_cmd(hci_buf);
- CPRINTS("hci cmd @%p", hci_buf);
+ CPRINTS("hci cmd @%pP", hci_buf);
return EC_SUCCESS;
}
@@ -588,7 +588,7 @@ static int command_ble_hci_acl(int argc, char **argv)
hci_cmd(hci_buf);
- CPRINTS("hci acl @%p", hci_buf);
+ CPRINTS("hci acl @%pP", hci_buf);
return EC_SUCCESS;
}
diff --git a/common/btle_ll.c b/common/btle_ll.c
index d05813d95c..3557c9710d 100644
--- a/common/btle_ll.c
+++ b/common/btle_ll.c
@@ -766,7 +766,7 @@ void bluetooth_ll_task(void)
case ADVERTISING:
if (deadline.val == 0) {
- CPRINTS("ADV @%p", &ll_adv_pdu);
+ CPRINTS("ADV @%pP", &ll_adv_pdu);
deadline.val = get_time().val +
(uint32_t)ll_adv_timeout_us;
ll_adv_events = 0;
diff --git a/common/hooks.c b/common/hooks.c
index ce8712eca2..dcdb4d8ee4 100644
--- a/common/hooks.c
+++ b/common/hooks.c
@@ -190,7 +190,7 @@ void hook_task(void *u)
/* Handle deferred routines */
for (i = 0; i < DEFERRED_FUNCS_COUNT; i++) {
if (__deferred_until[i] && __deferred_until[i] < t) {
- CPRINTS("hook call deferred 0x%p",
+ CPRINTS("hook call deferred 0x%pP",
__deferred_funcs[i].routine);
/*
* Call deferred function. Clear timer first,
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;
diff --git a/common/new_nvmem.c b/common/new_nvmem.c
index e9fa2c1a0c..cd333520fa 100644
--- a/common/new_nvmem.c
+++ b/common/new_nvmem.c
@@ -1602,7 +1602,7 @@ static void verify_empty_page(void *ph)
for (i = 0; i < (CONFIG_FLASH_BANK_SIZE / sizeof(*word_p)); i++) {
if (word_p[i] != (uint32_t)~0) {
- CPRINTS("%s: corrupted page at %p!", __func__, word_p);
+ CPRINTS("%s: corrupted page at %pP!", __func__, word_p);
flash_physical_erase((uintptr_t)word_p -
CONFIG_PROGRAM_MEMORY_BASE,
CONFIG_FLASH_BANK_SIZE);