Re: [PATCH v3] lib/vsprintf: Preserve the sign of seconds in %ptSp

From: Petr Mladek

Date: Tue Nov 10 2026 - 09:17:07 EST


On Mon 2026-11-09 21:54:45, Hungyu Lin wrote:
> The documentation defines %ptSp as equivalent to %lld.%09ld, but
> timespec64_str() formats tv_sec with default_dec_spec, which does not
> have SIGN set. Negative seconds are therefore printed as unsigned
> values: {-1, 0} produces "18446744073709551615.000000000" instead of
> "-1.000000000".
>
> Negative values can arise from time differences, for example in
> fnic_get_stats_data() after the realtime clock steps backwards.
>
> Use a signed decimal printf_spec for the seconds and add printf KUnit
> coverage for zero, negative seconds and the signed limits.
>
> Fixes: bccd5937447f ("lib/vsprintf: Add specifier for printing struct timespec64")
> Cc: stable@xxxxxxxxxxxxxxx
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> Tested-by: Keith Teeple <keithrteeple@xxxxxxxxx>
> Signed-off-by: Hungyu Lin <dennylin0707@xxxxxxxxx>

The patch looks good to me:

Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>

I am going to queue it for 7.5.

I am sorry that it me so long to get to it and missing 7.4 merge
window. My TODO list somehow exploded around the Plumbers conference
and I am still catching up with it.

Best Regards,
Petr