diff options
author | Bobby Casey <bobbycasey@google.com> | 2022-06-16 17:32:06 -0400 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-07 21:25:39 +0000 |
commit | c25ffdb3164b0421d73f5258a71f3d371bfea623 (patch) | |
tree | 98fc0156448dd79b457f36896c385b5b04784733 /baseboard | |
parent | 7eab3811962cde5b5c66a5952a4f7d9b1b41cd67 (diff) | |
download | chrome-ec-c25ffdb3164b0421d73f5258a71f3d371bfea623.tar.gz |
common: Conditionally support printf %l and %i modifiers
The libfp library prints some values with PRIx32 or PRId32 format
specifiers which, in their compilation environment, output "%lx" and
"%ld".
Unfortunately, support for printing any '%l' format in EC
code was deprecated in issuetracker.google.com/issues/172210614
after changing it from it being treated as a hard-coded 64-bit length.
There was concern that new code using %l with 32-bit values would be
cherry-picked to older branches without the updated printf. In these
cases, the older code would interpret that %l as 64-bit argument,
causing it to over-ingest arguments and potentially behave in an
undefined manner.
Printing 32-bit values with "%l" or "%i" is safe as long as we can
guarantee no legacy code will attempt to print using "%l" with a
64-bit value. The logic here is protected by a config flag that is
only enabled for FPMCU and FPMCU doesn't use long running release
branches.
A printf test is also added to ensure that only dartmonkey and
bloonchipper boards have long32 enabled.
BRANCH=none
BUG=b:234781655
BUG=b:234143158
TEST=./test/run_device_tests.py -b dartmonkey -t printf
TEST=./test/run_device_tests.py -b bloonchipper -t printf
TEST=make runhosttests
Signed-off-by: Bobby Casey <bobbycasey@google.com>
Change-Id: If432f507a31cc12a4c5c4bdcd07c6141407bd70d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3707743
Reviewed-by: Andrea Grandi <agrandi@google.com>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'baseboard')
-rw-r--r-- | baseboard/nucleo-f412zg/base-board.h | 2 | ||||
-rw-r--r-- | baseboard/nucleo-h743zi/base-board.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/baseboard/nucleo-f412zg/base-board.h b/baseboard/nucleo-f412zg/base-board.h index b104621ec7..bd5710e247 100644 --- a/baseboard/nucleo-f412zg/base-board.h +++ b/baseboard/nucleo-f412zg/base-board.h @@ -164,7 +164,7 @@ #define CONFIG_HOST_COMMAND_STATUS #define CONFIG_MKBP_EVENT #define CONFIG_MKBP_USE_GPIO -#define CONFIG_PRINTF_LEGACY_LI_FORMAT +#define CONFIG_PRINTF_LONG_IS_32BITS #define CONFIG_RNG #define CONFIG_SHA256 #define CONFIG_SHA256_UNROLLED diff --git a/baseboard/nucleo-h743zi/base-board.h b/baseboard/nucleo-h743zi/base-board.h index 10f780505d..f96ba41bcc 100644 --- a/baseboard/nucleo-h743zi/base-board.h +++ b/baseboard/nucleo-h743zi/base-board.h @@ -92,7 +92,7 @@ #define CONFIG_LOW_POWER_IDLE #define CONFIG_MKBP_EVENT #define CONFIG_MKBP_USE_GPIO -#define CONFIG_PRINTF_LEGACY_LI_FORMAT +#define CONFIG_PRINTF_LONG_IS_32BITS #define CONFIG_RNG #define CONFIG_RWSIG_TYPE_RWSIG #define CONFIG_SHA256 |