Re: [PATCH next] ext4: Fix diagnostic printf formats
From: David Laight
Date: Fri Mar 27 2026 - 12:10:14 EST
On Fri, 27 Mar 2026 16:12:38 +0200
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
...
> P.S. A bit of off-topic, have you seen this?
> https://elixir.bootlin.com/linux/v7.0-rc5/source/kernel/stacktrace.c#L33
> Is it correct use of %c?
>
Works with glibc (or, rather, with whichever libc the shell I'm using
is linked against):
$ printf '|%*c|\n' 5 x
| x|
$
'man fprintf' tends to agree.
Left justify also works, either "%-*c" or passing -5.
The 'fun' starts if you print a zero with %c in the middle of some output.
I know some compilers have supported: int c = 'abcd';
But I can't remember whether the value could be printed with %4c.
I do remember that the value ended up byteswapped in memory on both
x86 and sparc.
David