Re: [PATCH v1 1/2] docs: printk-formats: Fix hex printing of signed values

From: Petr Mladek
Date: Fri Jul 14 2023 - 11:32:40 EST


On Mon 2023-07-03 17:58:38, Andy Shevchenko wrote:
> The commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of
> unnecessary %h[xudi] and %hh[xudi]") obviously missed the point of sign
> promotion for the signed values lesser than int. In such case %x prints
> not the same as %h[h]x. Restore back those specifiers for the signed hex
> cases.
>
> Fixes: cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>

Makes sense. %d would print the same (small) negative number even when
casted do int. But %x would always add more "ff"s up to 4 bytes.

Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>

Best Regards,
Petr