Author: eadler
Date: Sun May 20 23:19:09 2018
New Revision: 333945
URL: https://svnweb.freebsd.org/changeset/base/333945

Log:
  top(1): set max username length based on system constant
  
  This changes previous behavior of calculating it at startup based on
  the current max username length.
  
  This is done because:
  - it is in theory possible for the max length to change at run-time
    (e.g., a new user is added after top starts running)
  - on machines with many users this delays startup significantly
  
  PR:           20799
  PR:           89762
  Reported by:  o...@e-gitt.net
  Reported by:  w...@kavalan.csie.nctu.edu.tw
  Reported on:  2000-08-23 and 2005-11-30

Modified:
  head/usr.bin/top/machine.c
  head/usr.bin/top/machine.h
  head/usr.bin/top/top.c
  head/usr.bin/top/username.c

Modified: head/usr.bin/top/machine.c
==============================================================================
--- head/usr.bin/top/machine.c  Sun May 20 22:07:44 2018        (r333944)
+++ head/usr.bin/top/machine.c  Sun May 20 23:19:09 2018        (r333945)
@@ -314,7 +314,7 @@ update_layout(void)
 }
 
 int
-machine_init(struct statics *statics, char do_unames)
+machine_init(struct statics *statics)
 {
        int i, j, empty, pagesize;
        uint64_t arc_size;
@@ -340,12 +340,7 @@ machine_init(struct statics *statics, char do_unames)
            NULL, 0) == 0 && carc_en == 1)
                carc_enabled = 1;
 
-       if (do_unames) {
-           while ((pw = getpwent()) != NULL) {
-               if (strlen(pw->pw_name) > namelength)
-                       namelength = strlen(pw->pw_name);
-           }
-       }
+       namelength = MAXLOGNAME;
        if (smpmode && namelength > SMPUNAMELEN)
                namelength = SMPUNAMELEN;
        else if (namelength > UPUNAMELEN)

Modified: head/usr.bin/top/machine.h
==============================================================================
--- head/usr.bin/top/machine.h  Sun May 20 22:07:44 2018        (r333944)
+++ head/usr.bin/top/machine.h  Sun May 20 23:19:09 2018        (r333945)
@@ -85,7 +85,7 @@ char  *format_next_process(caddr_t handle, char *(*get_
            int flags);
 void    toggle_pcpustats(void);
 void    get_system_info(struct system_info *si);
-int     machine_init(struct statics *statics, char do_unames);
+int     machine_init(struct statics *statics);
 int     proc_owner(int pid);
 
 /* non-int routines typically used by the machine dependent module */

Modified: head/usr.bin/top/top.c
==============================================================================
--- head/usr.bin/top/top.c      Sun May 20 22:07:44 2018        (r333944)
+++ head/usr.bin/top/top.c      Sun May 20 23:19:09 2018        (r333945)
@@ -548,7 +548,7 @@ char *argv[];
     }
 
     /* initialize the kernel memory interface */
-    if (machine_init(&statics, do_unames) == -1)
+    if (machine_init(&statics) == -1)
     {
        exit(1);
     }
@@ -572,14 +572,6 @@ char *argv[];
            exit(1);
        }
     }
-
-#ifdef no_initialization_needed
-    /* initialize the hashing stuff */
-    if (do_unames)
-    {
-       init_hash();
-    }
-#endif
 
     /* initialize termcap */
     init_termcap(interactive);

Modified: head/usr.bin/top/username.c
==============================================================================
--- head/usr.bin/top/username.c Sun May 20 22:07:44 2018        (r333944)
+++ head/usr.bin/top/username.c Sun May 20 23:19:09 2018        (r333945)
@@ -60,17 +60,6 @@ struct hash_el {
 struct hash_el hash_table[Table_size];
 
 
-void
-init_hash()
-
-{
-    /*
-     *  There used to be some steps we had to take to initialize things.
-     *  We don't need to do that anymore, but we will leave this stub in
-     *  just in case future changes require initialization steps.
-     */
-}
-
 char *username(uid)
 
 int uid;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to