diff options
author | ed <ed@FreeBSD.org> | 2012-08-31 08:48:53 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2012-08-31 08:48:53 +0000 |
commit | 80a343862a4ea0780552d7aaf07a17911476ccd8 (patch) | |
tree | 93362c5588b698b7edad749345f99a60e843bace | |
parent | 7a616648fc098fe68681c036f432247afe3bee9b (diff) | |
download | FreeBSD-src-80a343862a4ea0780552d7aaf07a17911476ccd8.zip FreeBSD-src-80a343862a4ea0780552d7aaf07a17911476ccd8.tar.gz |
Use better variable naming.
MFC after: 1 month
-rw-r--r-- | usr.sbin/ac/ac.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/usr.sbin/ac/ac.c b/usr.sbin/ac/ac.c index 1e2c54b..db275e0 100644 --- a/usr.sbin/ac/ac.c +++ b/usr.sbin/ac/ac.c @@ -269,8 +269,7 @@ show_today(struct timeval today) struct user_entry *up; struct utmpx_entry *lp; char date[64]; - struct timeval usec = { 0, 1 }; - struct timeval yesterday; + struct timeval diff, total = { 0, 0 }, usec = { 0, 1 }, yesterday; static int d_first = -1; if (d_first < 0) @@ -280,23 +279,19 @@ show_today(struct timeval today) d_first ? "%e %b total" : "%b %e total", localtime(&yesterday.tv_sec)); - /* restore the missing second */ - timeradd(&today, &usec, &yesterday); - SLIST_FOREACH(lp, &CurUtmpx, next) { - timersub(&yesterday, &lp->time, &today); - update_user(lp->user, today); + timersub(&today, &lp->time, &diff); + update_user(lp->user, diff); /* As if they just logged in. */ - lp->time = yesterday; + lp->time = today; } - timerclear(&today); SLIST_FOREACH(up, &Users, next) { - timeradd(&today, &up->time, &today); + timeradd(&total, &up->time, &total); /* For next day. */ timerclear(&up->time); } - if (timerisset(&today)) - (void)printf("%s %11.2f\n", date, (double)today.tv_sec / 3600); + if (timerisset(&total)) + (void)printf("%s %11.2f\n", date, (double)total.tv_sec / 3600); } /* |