diff options
author | coastal-hiker | 2017-06-27 14:14:49 +0200 |
---|---|---|
committer | Karel Zak | 2017-07-10 10:03:41 +0200 |
commit | 62f3e715972686670df030c1b0770c4527e40d9d (patch) | |
tree | bca00b5f792c54e2cb2f7959f778e32a9d095846 /login-utils/last.c | |
parent | last: don't show negative time (diff) | |
download | kernel-qcow2-util-linux-62f3e715972686670df030c1b0770c4527e40d9d.tar.gz kernel-qcow2-util-linux-62f3e715972686670df030c1b0770c4527e40d9d.tar.xz kernel-qcow2-util-linux-62f3e715972686670df030c1b0770c4527e40d9d.zip |
last: condition (secs == 0) - now handled correctly
Changed comparison "if (secs > 0)" to "if (secs >= 0)" to handle
condition (secs == 0) correctly. Suggestions to improve the
less-than-elegant if-else chain are welcome.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/last.c')
-rw-r--r-- | login-utils/last.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/login-utils/last.c b/login-utils/last.c index ad70b38fb..2d7eb049f 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -457,7 +457,7 @@ static int list(const struct last_control *ctl, struct utmpx *p, time_t logout_t sprintf(length, "(%d+%02d:%02d)", days, abs(hours), abs(mins)); /* hours and mins always shown as positive (w/o minus sign!) even if secs < 0 */ } else if (hours) { sprintf(length, " (%02d:%02d)", hours, abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */ - } else if (secs > 0) { + } else if (secs >= 0) { sprintf(length, " (%02d:%02d)", hours, mins); } else { sprintf(length, " (-00:%02d)", abs(mins)); /* mins always shown as positive (w/o minus sign!) even if secs < 0 */ |