]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
w: Fix premature rounding.
authorDag-Erling Smørgrav <des@FreeBSD.org>
Mon, 24 Oct 2022 14:02:11 +0000 (14:02 +0000)
committerDag-Erling Smørgrav <des@FreeBSD.org>
Wed, 26 Oct 2022 15:56:40 +0000 (15:56 +0000)
commitdeb2f1b616f1369d2e773096a6c0c302cb3a9060
treeea8f1ef1d081f9784e6661183b4b1daf6792eed3
parentd346e3ac33105922a5812d480b49f7dda674d136
w: Fix premature rounding.

If the system has been up more longer than a minute, we add 30 seconds to
the uptime so that subsequent calculations will round to the nearest minute
rather than truncate.  However, since the introduction of libxo, we output
the raw value after performing the adjustment.  Rewrite so that we output
the raw value first, then perform the adjustment and recalculate before
outputting the humanized value.

While there, reduce stack usage and avoid needless allocations.

Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37128
usr.bin/w/w.c