]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
last: improve code readability by renaming variable names
authorSami Kerola <kerolasa@iki.fi>
Sat, 16 Aug 2014 09:38:04 +0000 (10:38 +0100)
committerSami Kerola <kerolasa@iki.fi>
Fri, 19 Sep 2014 18:31:01 +0000 (19:31 +0100)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils/last.c

index fb82f31c0339c6a8e215bc0ecca3065e0a070029..54d9e1f8e32e677121a43643b29c85ee0709fed5 100644 (file)
@@ -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;