Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/w Move enough additional 'w' code into 'uptime' to k...



details:   https://anonhg.NetBSD.org/src/rev/891febee49f2
branches:  trunk
changeset: 335034:891febee49f2
user:      dennis <dennis%NetBSD.org@localhost>
date:      Mon Dec 22 15:24:14 2014 +0000

description:
Move enough additional 'w' code into 'uptime' to keep the latter
from double-counting utmp users.

diffstat:

 usr.bin/w/w.c |  21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diffs (59 lines):

diff -r e26fed3de698 -r 891febee49f2 usr.bin/w/w.c
--- a/usr.bin/w/w.c     Mon Dec 22 11:21:08 2014 +0000
+++ b/usr.bin/w/w.c     Mon Dec 22 15:24:14 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: w.c,v 1.81 2014/12/03 06:12:19 mrg Exp $       */
+/*     $NetBSD: w.c,v 1.82 2014/12/22 15:24:14 dennis Exp $    */
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)w.c        8.6 (Berkeley) 6/30/94";
 #else
-__RCSID("$NetBSD: w.c,v 1.81 2014/12/03 06:12:19 mrg Exp $");
+__RCSID("$NetBSD: w.c,v 1.82 2014/12/22 15:24:14 dennis Exp $");
 #endif
 #endif /* not lint */
 
@@ -222,18 +222,26 @@
                        continue;
                ++nusers;
 
+#ifndef SUPPORT_UTMP
                if (wcmd == 0)
                        continue;
+#endif /* !SUPPORT_UTMP */
 
                if (sel_user &&
                    strncmp(utx->ut_name, sel_user, sizeof(utx->ut_name)) != 0)
                        continue;
                if ((ep = calloc(1, sizeof(struct entry))) == NULL)
                        err(1, NULL);
+               (void)memcpy(ep->line, utx->ut_line, sizeof(utx->ut_line));
+               ep->line[sizeof(utx->ut_line)] = '\0';
+               *nextp = ep;
+               nextp = &(ep->next);
+
+               if (wcmd == 0)
+                       continue;
+
                (void)memcpy(ep->name, utx->ut_name, sizeof(utx->ut_name));
-               (void)memcpy(ep->line, utx->ut_line, sizeof(utx->ut_line));
                ep->name[sizeof(utx->ut_name)] = '\0';
-               ep->line[sizeof(utx->ut_line)] = '\0';
                if (!nflag || getnameinfo((struct sockaddr *)&utx->ut_ss,
                    utx->ut_ss.ss_len, ep->host, sizeof(ep->host), NULL, 0,
                    NI_NUMERICHOST) != 0) {
@@ -245,10 +253,7 @@
                ep->type[0] = 'x';
                ep->tv = utx->ut_tv;
                ep->pid = utx->ut_pid;
-               *nextp = ep;
-               nextp = &(ep->next);
-               if (wcmd != 0)
-                       process(ep);
+               process(ep);
        }
 #endif
 



Home | Main Index | Thread Index | Old Index