From owner-svn-src-head@freebsd.org Sun May 20 23:19:10 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9FAFEEF376B; Sun, 20 May 2018 23:19:10 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ECDA75F96; Sun, 20 May 2018 23:19:10 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2B6F51CE4B; Sun, 20 May 2018 23:19:10 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4KNJAeI038456; Sun, 20 May 2018 23:19:10 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4KNJ9hj038452; Sun, 20 May 2018 23:19:09 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201805202319.w4KNJ9hj038452@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sun, 20 May 2018 23:19:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333945 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 333945 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 May 2018 23:19:10 -0000 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: ob@e-Gitt.NET Reported by: wkwu@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;