[PATCH 1/3] vsprintf: add support for printing raw buffers as hex (%*ph)

Sascha Hauer sha at pengutronix.de
Mon Dec 13 14:28:08 PST 2021


On Thu, Dec 09, 2021 at 11:57:06AM +0100, Ahmad Fatoum wrote:
> Import from Linux support for printing buffers as a hex string
> with a certain separator. For larger buffers consider using
> print_hex_dump(). Examples:
> 
>   %*ph	00 01 02  ...  3f
>   %*phC	00:01:02: ... :3f
>   %*phD	00-01-02- ... -3f
>   %*phN	000102 ... 3f
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
>  lib/Kconfig    |  3 +++
>  lib/vsprintf.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 53 insertions(+)
> 
> diff --git a/lib/Kconfig b/lib/Kconfig
> index 718033e56e64..27e7bea6852f 100644
> --- a/lib/Kconfig
> +++ b/lib/Kconfig
> @@ -166,6 +166,9 @@ config PRINTF_UUID
>  config PRINTF_WCHAR
>  	bool
>  
> +config PRINTF_HEXSTR
> +	bool

So hexdumps are silently ignored when this option is disabled. Not sure
if this should really be configurable, but I think when it is
configurable it should be default y to avoid surprises.

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list