uptime: be more generous about read_utmp failure
commit1ea34cbf6a235f2436a3265ab9ded6f04748051e
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Aug 2023 21:00:54 +0000 (15 14:00 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Aug 2023 21:01:58 +0000 (15 14:01 -0700)
tree642c8ad5d4ac815e3fb67907027f42e989ac6206
parentd8cfa5db49641f39b63aba2037c6a9e6bd95c0e0
uptime: be more generous about read_utmp failure

* src/uptime.c (print_uptime): Check for overflow
when computing uptime.  Use C99-style decl after statements.
Do not let an idx_t value go negative.
(print_uptime, uptime): Be more generous about read_utmp failures,
or when read_utmp does not report the boot time.  Instead of
failing, warn but keep going, printing the information that we did
get, and then exit with nonzero status.
(print_uptime): Return the desired exit status.  Caller changed.
src/uptime.c