summaryrefslogtreecommitdiff
path: root/include/printf.h
diff options
context:
space:
mode:
authorBobby Casey <bobbycasey@google.com>2022-06-16 17:32:06 -0400
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-07 21:25:39 +0000
commitc25ffdb3164b0421d73f5258a71f3d371bfea623 (patch)
tree98fc0156448dd79b457f36896c385b5b04784733 /include/printf.h
parent7eab3811962cde5b5c66a5952a4f7d9b1b41cd67 (diff)
downloadchrome-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 'include/printf.h')
-rw-r--r--include/printf.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/printf.h b/include/printf.h
index 8eed1618f8..333e622b7b 100644
--- a/include/printf.h
+++ b/include/printf.h
@@ -51,7 +51,7 @@
* - 'c' - character
* - 's' - null-terminated ASCII string
* - 'd' - signed integer
- * - 'i' - signed integer if CONFIG_PRINTF_LEGACY_LI_FORMAT is set (ignore l)
+ * - 'i' - signed integer (if CONFIG_PRINTF_LONG_IS_32BITS is enabled)
* - 'u' - unsigned integer
* - 'x' - unsigned integer, print as lower-case hexadecimal
* - 'X' - unsigned integer, print as upper-case hexadecimal