Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/w redo the previous; avoid a bunch of processing whe...



details:   https://anonhg.NetBSD.org/src/rev/cef89d1c48a2
branches:  trunk
changeset: 804864:cef89d1c48a2
user:      mrg <mrg%NetBSD.org@localhost>
date:      Wed Dec 03 06:12:19 2014 +0000

description:
redo the previous; avoid a bunch of processing when running as "uptime",
and as a side effect, avoid any name lookups.

diffstat:

 usr.bin/w/w.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (58 lines):

diff -r 24f6e5b50c8b -r cef89d1c48a2 usr.bin/w/w.c
--- a/usr.bin/w/w.c     Wed Dec 03 03:44:45 2014 +0000
+++ b/usr.bin/w/w.c     Wed Dec 03 06:12:19 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: w.c,v 1.80 2014/12/02 22:19:19 christos Exp $  */
+/*     $NetBSD: w.c,v 1.81 2014/12/03 06:12:19 mrg 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.80 2014/12/02 22:19:19 christos Exp $");
+__RCSID("$NetBSD: w.c,v 1.81 2014/12/03 06:12:19 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -156,7 +156,6 @@
        if (*progname == 'u') {
                wcmd = 0;
                options = "";
-               nflag = 1;
        } else {
                wcmd = 1;
                options = "hiM:N:nw";
@@ -222,6 +221,10 @@
                if (utx->ut_type != USER_PROCESS)
                        continue;
                ++nusers;
+
+               if (wcmd == 0)
+                       continue;
+
                if (sel_user &&
                    strncmp(utx->ut_name, sel_user, sizeof(utx->ut_name)) != 0)
                        continue;
@@ -268,6 +271,10 @@
                        continue;
 
                ++nusers;
+
+               if (wcmd == 0)
+                       continue;
+
                if ((ep = calloc(1, sizeof(struct entry))) == NULL)
                        err(1, NULL);
                (void)memcpy(ep->name, ut->ut_name, sizeof(ut->ut_name));
@@ -280,8 +287,7 @@
                ep->tv.tv_sec = ut->ut_time;
                *nextp = ep;
                nextp = &(ep->next);
-               if (wcmd != 0)
-                       process(ep);
+               process(ep);
        }
 #endif
 



Home | Main Index | Thread Index | Old Index