diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-07-12 10:01:23 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-19 16:29:14 +0000 |
commit | 8d30a05ed74730fece3ebf0fd617426c565541ce (patch) | |
tree | 697a064455230b2358246d52feb5eb4e94ec2fd0 /chip/stm32 | |
parent | e97b3e407b786e95cabef7977d42998f0ed13be8 (diff) | |
download | chrome-ec-8d30a05ed74730fece3ebf0fd617426c565541ce.tar.gz |
tree: Remove non-standard "%ph" printf format
The non-standard "%ph" format is replaced with snprintf_hex_buffer and
then using "%s" to print the resulting buffer.
Using standard format specifiers makes it easier to switch between the
"builtin" EC standard library and the C standard library provided by the
toolchain (or Zephyr).
BRANCH=none
BUG=b:238433667, b:234181908
TEST=Enable CONFIG_CMD_RAND in nocturne_fp/board.h
On icetower v0.1 with servo_micro and J-Trace:
Before change:
> rand
rand 8ab8b15090ca5ae83bdad671c906d51a5f2b98a359a4106054ee6b54a4087190
After change:
> rand
rand 2a8645235a31936a28b8d1b9c4948f46d39662e7fcb10a185ddb14c6a998e2eb
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I3bff928d32579440d7cdb27a75899e45159accfb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3759123
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'chip/stm32')
-rw-r--r-- | chip/stm32/trng.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/chip/stm32/trng.c b/chip/stm32/trng.c index 6538263add..a975c4c584 100644 --- a/chip/stm32/trng.c +++ b/chip/stm32/trng.c @@ -9,6 +9,7 @@ #include "console.h" #include "host_command.h" #include "panic.h" +#include "printf.h" #include "registers.h" #include "system.h" #include "task.h" @@ -106,12 +107,15 @@ test_mockable void trng_exit(void) static int command_rand(int argc, char **argv) { uint8_t data[32]; + char str_buf[hex_str_buf_size(sizeof(data))]; trng_init(); trng_rand_bytes(data, sizeof(data)); trng_exit(); - ccprintf("rand %ph\n", HEX_BUF(data, sizeof(data))); + snprintf_hex_buffer(str_buf, sizeof(str_buf), + HEX_BUF(data, sizeof(data))); + ccprintf("rand %s\n", str_buf); return EC_SUCCESS; } |