Skip to content

Commit 46d57a7

Browse files
andy-shevpmladek
authored andcommitted
docs: printk-formats: Fix hex printing of signed values
The commit cbacb5a ("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: cbacb5a ("docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20230703145839.14248-1-andriy.shevchenko@linux.intel.com
1 parent 7ec85f3 commit 46d57a7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Documentation/core-api/printk-formats.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Integer types
1515

1616
If variable is of Type, use printk format specifier:
1717
------------------------------------------------------------
18-
char %d or %x
18+
char %d or %hhx
1919
unsigned char %u or %x
20-
short int %d or %x
20+
short int %d or %hx
2121
unsigned short int %u or %x
2222
int %d or %x
2323
unsigned int %u or %x
@@ -27,9 +27,9 @@ Integer types
2727
unsigned long long %llu or %llx
2828
size_t %zu or %zx
2929
ssize_t %zd or %zx
30-
s8 %d or %x
30+
s8 %d or %hhx
3131
u8 %u or %x
32-
s16 %d or %x
32+
s16 %d or %hx
3333
u16 %u or %x
3434
s32 %d or %x
3535
u32 %u or %x

0 commit comments

Comments
 (0)