diff options
author | Sami Kerola | 2014-08-16 11:38:04 +0200 |
---|---|---|
committer | Sami Kerola | 2014-09-19 20:31:01 +0200 |
commit | d4ce90d47cf89d018ac6fcf50481fbafa2682c46 (patch) | |
tree | 019e740ec053ce036c0f4f0bdf60740c1ef4bb1b /login-utils/last.c | |
parent | last: make is_phantom() when kernel config does not include audit support (diff) | |
download | kernel-qcow2-util-linux-d4ce90d47cf89d018ac6fcf50481fbafa2682c46.tar.gz kernel-qcow2-util-linux-d4ce90d47cf89d018ac6fcf50481fbafa2682c46.tar.xz kernel-qcow2-util-linux-d4ce90d47cf89d018ac6fcf50481fbafa2682c46.zip |
last: improve code readability by renaming variable names
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'login-utils/last.c')
-rw-r--r-- | login-utils/last.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/login-utils/last.c b/login-utils/last.c index fb82f31c0..54d9e1f8e 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -376,9 +376,9 @@ static void trim_trailing_spaces(char *s) /* * Show one line of information on screen */ -static int list(const struct last_control *ctl, struct utmp *p, time_t t, int what) +static int list(const struct last_control *ctl, struct utmp *p, time_t logout_time, int what) { - time_t secs, tmp, epoch; + time_t secs, utmp_time, now; char logintime[LAST_TIMESTAMP_LEN]; char logouttime[LAST_TIMESTAMP_LEN]; char length[LAST_TIMESTAMP_LEN]; @@ -417,22 +417,25 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t t, int wh /* * Calculate times */ - tmp = p->UL_UT_TIME; + utmp_time = p->UL_UT_TIME; - if (ctl->present && (ctl->present < tmp || (0 < t && t < ctl->present))) - return 0; - - if (time_formatter(ctl, &logintime[0], sizeof(logintime), &tmp, 0) < 0 || - time_formatter(ctl, &logouttime[0], sizeof(logouttime), &t, 1) < 0) + if (ctl->present) { + if (ctl->present < utmp_time) + return 0; + if (0 < logout_time && logout_time < ctl->present) + return 0; + } + if (time_formatter(ctl, &logintime[0], sizeof(logintime), &utmp_time, 0) < 0 || + time_formatter(ctl, &logouttime[0], sizeof(logouttime), &logout_time, 1) < 0) errx(EXIT_FAILURE, _("preallocation size exceeded")); - secs = t - p->UL_UT_TIME; + secs = logout_time - utmp_time; mins = (secs / 60) % 60; hours = (secs / 3600) % 24; days = secs / 86400; - epoch = time(NULL); - if (t == epoch) { + now = time(NULL); + if (logout_time == now) { if (ctl->time_fmt > LAST_TIMEFTM_SHORT_CTIME) { sprintf(logouttime, " still running"); length[0] = 0; |