From owner-svn-src-all@FreeBSD.ORG Fri Aug 31 08:48:54 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7FE87106566B; Fri, 31 Aug 2012 08:48:54 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B77B8FC29; Fri, 31 Aug 2012 08:48:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q7V8msTa099633; Fri, 31 Aug 2012 08:48:54 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7V8msTV099631; Fri, 31 Aug 2012 08:48:54 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201208310848.q7V8msTV099631@svn.freebsd.org> From: Ed Schouten Date: Fri, 31 Aug 2012 08:48:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r239938 - head/usr.sbin/ac X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Aug 2012 08:48:54 -0000 Author: ed Date: Fri Aug 31 08:48:53 2012 New Revision: 239938 URL: http://svn.freebsd.org/changeset/base/239938 Log: Use better variable naming. MFC after: 1 month Modified: head/usr.sbin/ac/ac.c Modified: head/usr.sbin/ac/ac.c ============================================================================== --- head/usr.sbin/ac/ac.c Fri Aug 31 06:42:51 2012 (r239937) +++ head/usr.sbin/ac/ac.c Fri Aug 31 08:48:53 2012 (r239938) @@ -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); } /*