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

From: Keith Teeple

Date: Wed Oct 21 2026 - 21:21:38 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".

Tested on mainline 4df4d2a577db with gcc 16.2.1 under UML and i386
(QEMU). With only the new tests applied and vsprintf.c unchanged,
time_and_date fails on both. The -1, -1.999999999 and S64_MIN checks
print the unsigned values and the 0, %ptS and S64_MAX checks pass.

All tests pass on UML and i386 with the full patch applied.

Tested-by: Keith Teeple <keithrteeple@xxxxxxxxx>