From owner-svn-src-all@FreeBSD.ORG Wed Sep 12 22:16:32 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F3C1106566C; Wed, 12 Sep 2012 22:16:32 +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 1156E8FC17; Wed, 12 Sep 2012 22:16:32 +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 q8CMGVPw059034; Wed, 12 Sep 2012 22:16:31 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8CMGVLX059032; Wed, 12 Sep 2012 22:16:31 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201209122216.q8CMGVLX059032@svn.freebsd.org> From: Ed Schouten Date: Wed, 12 Sep 2012 22:16:31 +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: r240425 - head/usr.bin/last 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: Wed, 12 Sep 2012 22:16:32 -0000 Author: ed Date: Wed Sep 12 22:16:31 2012 New Revision: 240425 URL: http://svn.freebsd.org/changeset/base/240425 Log: Switch batch to an SLIST. This code requires none of the features of LIST. Modified: head/usr.bin/last/last.c Modified: head/usr.bin/last/last.c ============================================================================== --- head/usr.bin/last/last.c Wed Sep 12 22:10:53 2012 (r240424) +++ head/usr.bin/last/last.c Wed Sep 12 22:16:31 2012 (r240425) @@ -72,12 +72,12 @@ typedef struct arg { } ARG; static ARG *arglist; /* head of linked list */ -static LIST_HEAD(idlisthead, idtab) idlist; +static SLIST_HEAD(, idtab) idlist; struct idtab { time_t logout; /* log out time */ char id[sizeof ((struct utmpx *)0)->ut_id]; /* identifier */ - LIST_ENTRY(idtab) list; + SLIST_ENTRY(idtab) list; }; static const char *crmsg; /* cause of last reboot */ @@ -206,7 +206,7 @@ wtmp(void) char ct[80]; struct tm *tm; - LIST_INIT(&idlist); + SLIST_INIT(&idlist); (void)time(&t); /* Load the last entries from the file. */ @@ -240,16 +240,14 @@ wtmp(void) static void doentry(struct utmpx *bp) { - struct idtab *tt, *ttx; /* idlist entry */ + struct idtab *tt; /* the machine stopped */ if (bp->ut_type == BOOT_TIME || bp->ut_type == SHUTDOWN_TIME) { /* everybody just logged out */ - for (tt = LIST_FIRST(&idlist); tt;) { - LIST_REMOVE(tt, list); - ttx = tt; - tt = LIST_NEXT(tt, list); - free(ttx); + while ((tt = SLIST_FIRST(&idlist)) != NULL) { + SLIST_REMOVE_HEAD(&idlist, list); + free(tt); } currentout = -bp->ut_tv.tv_sec; crmsg = bp->ut_type != SHUTDOWN_TIME ? @@ -279,7 +277,7 @@ doentry(struct utmpx *bp) return; /* find associated identifier */ - LIST_FOREACH(tt, &idlist, list) + SLIST_FOREACH(tt, &idlist, list) if (!memcmp(tt->id, bp->ut_id, sizeof bp->ut_id)) break; @@ -290,7 +288,7 @@ doentry(struct utmpx *bp) errx(1, "malloc failure"); tt->logout = currentout; memcpy(tt->id, bp->ut_id, sizeof bp->ut_id); - LIST_INSERT_HEAD(&idlist, tt, list); + SLIST_INSERT_HEAD(&idlist, tt, list); } /*