Module Name:    src
Committed By:   dennis
Date:           Mon Dec 22 15:24:14 UTC 2014

Modified Files:
        src/usr.bin/w: w.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/usr.bin/w/w.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/w/w.c
diff -u src/usr.bin/w/w.c:1.81 src/usr.bin/w/w.c:1.82
--- src/usr.bin/w/w.c:1.81	Wed Dec  3 06:12:19 2014
+++ src/usr.bin/w/w.c	Mon Dec 22 15:24:14 2014
@@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #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 @@ main(int argc, char **argv)
 			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->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';
+		*nextp = ep;
+		nextp = &(ep->next);
+
+		if (wcmd == 0)
+			continue;
+
+		(void)memcpy(ep->name, utx->ut_name, sizeof(utx->ut_name));
+		ep->name[sizeof(utx->ut_name)] = '\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 @@ main(int argc, char **argv)
 		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
 

Reply via email to