Re: [PATCH v2] lib/vsprintf: Preserve the sign of seconds in %ptSp
From: Andy Shevchenko
Date: Wed Oct 21 2026 - 10:25:28 EST
On Wed, Oct 21, 2026 at 11:06:28AM +0000, 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")
Should we Cc to stable@?
> Signed-off-by: Hungyu Lin <dennylin0707@xxxxxxxxx>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
--
With Best Regards,
Andy Shevchenko