From c25ffdb3164b0421d73f5258a71f3d371bfea623 Mon Sep 17 00:00:00 2001 From: Bobby Casey Date: Thu, 16 Jun 2022 17:32:06 -0400 Subject: 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 Change-Id: If432f507a31cc12a4c5c4bdcd07c6141407bd70d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3707743 Reviewed-by: Andrea Grandi Reviewed-by: Tom Hughes --- util/config_allowed.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util') diff --git a/util/config_allowed.txt b/util/config_allowed.txt index 58317b8384..0e352e7602 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -716,7 +716,7 @@ CONFIG_POWER_SIGNAL_INTERRUPT_STORM_DETECT_THRESHOLD CONFIG_POWER_SIGNAL_RUNTIME_CONFIG CONFIG_POWER_TRACK_HOST_SLEEP_STATE CONFIG_PRESERVE_LOGS -CONFIG_PRINTF_LEGACY_LI_FORMAT +CONFIG_PRINTF_LONG_IS_32BITS CONFIG_PRINT_IN_INT CONFIG_PROGRAM_MEMORY_BASE CONFIG_PROGRAM_MEMORY_BASE_LOAD -- cgit v1.2.1