tiny-printf: Handle formatting of %p with an extra Kconfig
PATCH v4 1/1 tiny-printf: Handle formatting of %p with an extra Kconfig
The formatting with %pa / %pap behaves like %x, which results in an incorrect value being output. To improve this, a new fine-tuning Kconfig SPL_USE_TINY_PRINTF_POINTER_SUPPORT for pointer formatting has been added. If it is enabled, the output of %pa / %pap should be correct, and if it is disabled, the pointer formatting is completely unsupported. In addition to indicate unsupported formatting, '?' will be output. This allows enabling pointer formatting only when needed. For SPL_NET it is selected by default. Then it also supports the formatting with %pm, %pM and %pI4.
In summery this level of %p support for tiny printf is possible now:
1) The standard tiny printf won't have support for pointer formatting. So it doesn't print misleading values for %pa, instead '?' will be output:
%p => ?
%pa => ?a
%pap => ?ap
2) If SPL_USE_TINY_PRINTF_POINTER_SUPPORT is enabled or DEBUG is defined tiny printf supports formatting %p and %pa / %pap.
3) If SPL_NET is enabled the support of pointers is extended for %pm, %pM and %pI4.
---
Cc: Tom Rini <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Michael Walle <[email protected]>
Cc: Quentin Schulz <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Benedikt Spranger <[email protected]>
Cc: Jerome Forissier <[email protected]>
Cc: John Ogness <[email protected]>
Cc: Ilias Apalodimas <[email protected]>
---
V2: - Rebase on current master
- Extend commit message
- Restrict use to SPL
- Rename Kconfig to SPL_USE_TINY_PRINTF_POINTER_SUPPORT
- Replace _DEBUG with defined(DEBUG)
- Output '?' if %pm, %pM and %pI4 isn't available
- Add break on case '%'
V3: - Add missing output '?' for the default case
V4: - Remove NET_LWIP support from tiny printf because SPL doesn't support lwIP
--- common/spl/Kconfig | 1 + lib/Kconfig | 8 ++++++++ lib/tiny-printf.c | 48 +++++++++++++++++++++++----------------------- 3 files changed, 33 insertions(+), 24 deletions(-)
common/spl/Kconfig +1 -0
@@ -1122,6 +1122,7 @@ config SPL_DM_SPI_FLASH config SPL_NET bool "Support networking" depends on !NET_LWIP + select SPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF help Enable support for network devices (such as Ethernet) in SPL. This permits SPL to load U-Boot over a network link rather than
lib/Kconfig +8 -0
@@ -253,6 +253,14 @@ config VPL_USE_TINY_PRINTF The supported format specifiers are %c, %s, %u/%d and %x. +config SPL_USE_TINY_PRINTF_POINTER_SUPPORT + bool "Extend tiny printf with the pointer formatting %p" + depends on SPL_USE_TINY_PRINTF + help + This option enables the formatting of pointers %p. It supports + %p and %pa / %pap. If this option is selected by SPL_NET + it also supports the formatting with %pm, %pM and %pI4. + config PANIC_HANG bool "Do not reset the system on fatal error" help
lib/tiny-printf.c +24 -24
100 lines not on this page · raw message
Signature · 1 line
2.30.2
Quoted 11 lines · Christoph Niedermaier
The formatting with %pa / %pap behaves like %x, which results in an incorrect value being output. To improve this, a new fine-tuning
KconfigSPL_USE_TINY_PRINTF_POINTER_SUPPORTfor pointer formatting has been added. If it is enabled, the output of %pa / %pap should be correct, and if it is disabled, the pointer formatting is completely unsupported. In addition to indicate unsupported formatting, '?' will be output. This allows enabling pointer formatting only when needed. ForSPL_NETit is selected by default. Then it also supports the formatting with %pm, %pM and %pI4.[...]
Applied to u-boot/next, thanks!
[1/1] tiny-printf: Handle formatting of %p with an extra Kconfig
commit: 1e24e84db41afc5beba0a0ef9dd6e0509127b1de
Signature · 1 line
Tom