From owner-svn-src-head@freebsd.org Sat Jun 2 03:54:52 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 C1EE8EF79E9; Sat, 2 Jun 2018 03:54:52 +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 6944869058; Sat, 2 Jun 2018 03:54:52 +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 4B8DA24CD; Sat, 2 Jun 2018 03:54:52 +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 w523sqT3063890; Sat, 2 Jun 2018 03:54:52 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w523sogU063882; Sat, 2 Jun 2018 03:54:50 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201806020354.w523sogU063882@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sat, 2 Jun 2018 03:54:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334517 - 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: 334517 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: Sat, 02 Jun 2018 03:54:53 -0000 Author: eadler Date: Sat Jun 2 03:54:50 2018 New Revision: 334517 URL: https://svnweb.freebsd.org/changeset/base/334517 Log: top(1): Use uid_t for uid rather than 'int' Remove unneeded define while here. Modified: head/usr.bin/top/machine.c head/usr.bin/top/machine.h head/usr.bin/top/screen.c head/usr.bin/top/top.c head/usr.bin/top/username.c head/usr.bin/top/username.h head/usr.bin/top/utils.c head/usr.bin/top/utils.h Modified: head/usr.bin/top/machine.c ============================================================================== --- head/usr.bin/top/machine.c Sat Jun 2 03:33:02 2018 (r334516) +++ head/usr.bin/top/machine.c Sat Jun 2 03:54:50 2018 (r334517) @@ -914,7 +914,7 @@ get_process_info(struct system_info *si, struct proces static char fmt[512]; /* static area where result is built */ char * -format_next_process(caddr_t xhandle, char *(*get_userid)(int), int flags) +format_next_process(caddr_t xhandle, char *(*get_userid)(uid_t), int flags) { struct kinfo_proc *pp; const struct kinfo_proc *oldp; Modified: head/usr.bin/top/machine.h ============================================================================== --- head/usr.bin/top/machine.h Sat Jun 2 03:33:02 2018 (r334516) +++ head/usr.bin/top/machine.h Sat Jun 2 03:54:50 2018 (r334517) @@ -75,7 +75,7 @@ struct process_select /* routines defined by the machine dependent module */ char *format_header(char *uname_field); -char *format_next_process(caddr_t handle, char *(*get_userid)(int), +char *format_next_process(caddr_t handle, char *(*get_userid)(uid_t), int flags); void toggle_pcpustats(void); void get_system_info(struct system_info *si); Modified: head/usr.bin/top/screen.c ============================================================================== --- head/usr.bin/top/screen.c Sat Jun 2 03:33:02 2018 (r334516) +++ head/usr.bin/top/screen.c Sat Jun 2 03:54:50 2018 (r334517) @@ -25,7 +25,6 @@ #include #include #include -#define TERMIOS #include #include #include Modified: head/usr.bin/top/top.c ============================================================================== --- head/usr.bin/top/top.c Sat Jun 2 03:33:02 2018 (r334516) +++ head/usr.bin/top/top.c Sat Jun 2 03:54:50 2018 (r334517) @@ -206,7 +206,7 @@ main(int argc, char *argv[]) int displays = 0; /* indicates unspecified */ int sel_ret = 0; time_t curr_time; - char *(*get_userid)(int) = username; + char *(*get_userid)(uid_t) = username; char *uname_field = "USERNAME"; char *header_text; char *env_top; Modified: head/usr.bin/top/username.c ============================================================================== --- head/usr.bin/top/username.c Sat Jun 2 03:33:02 2018 (r334516) +++ head/usr.bin/top/username.c Sat Jun 2 03:54:50 2018 (r334517) @@ -37,29 +37,27 @@ #include #include #include +#include #include "utils.h" #include "username.h" struct hash_el { - int uid; + uid_t uid; char name[MAXLOGNAME]; }; #define is_empty_hash(x) (hash_table[x].name[0] == 0) /* simple minded hashing function */ -/* Uid "nobody" is -2 results in hashit(-2) = -2 which is out of bounds for - the hash_table. Applied abs() function to fix. 2/16/96 tpugh -*/ -#define hashit(i) (abs(i) % Table_size) +#define hashit(i) (i % Table_size) /* K&R requires that statically declared tables be initialized to zero. */ /* We depend on that for hash_table and YOUR compiler had BETTER do it! */ static struct hash_el hash_table[Table_size]; -char *username(int uid) +char *username(uid_t uid) { int hashindex; @@ -72,7 +70,7 @@ char *username(int uid) return(hash_table[hashindex].name); } -int userid(char username[]) +uid_t userid(char username[]) { struct passwd *pwd; @@ -93,7 +91,7 @@ int userid(char username[]) } /* wecare 1 = enter it always, 0 = nice to have */ -int enter_user(int uid, char name[], bool wecare) +int enter_user(uid_t uid, char name[], bool wecare) { int hashindex; @@ -124,7 +122,7 @@ int enter_user(int uid, char name[], bool wecare) */ int -get_user(int uid) +get_user(uid_t uid) { struct passwd *pwd; Modified: head/usr.bin/top/username.h ============================================================================== --- head/usr.bin/top/username.h Sat Jun 2 03:33:02 2018 (r334516) +++ head/usr.bin/top/username.h Sat Jun 2 03:54:50 2018 (r334517) @@ -12,12 +12,13 @@ #define USERNAME_H #include +#include -int enter_user(int uid, char *name, bool wecare); -int get_user(int uid); +int enter_user(uid_t uid, char *name, bool wecare); +int get_user(uid_t uid); void init_hash(void); -char *username(int uid); -int userid(char *username); +char *username(uid_t uid); +uid_t userid(char *username); /* * "Table_size" defines the size of the hash tables used to map uid to Modified: head/usr.bin/top/utils.c ============================================================================== --- head/usr.bin/top/utils.c Sat Jun 2 03:33:02 2018 (r334516) +++ head/usr.bin/top/utils.c Sat Jun 2 03:54:50 2018 (r334517) @@ -59,7 +59,7 @@ atoiwi(char *str) */ _Static_assert(sizeof(int) <= 4, "buffer too small for this sized int"); -char *itoa(int val) +char *itoa(unsigned int val) { char *ptr; static char buffer[16]; /* result is built here */ @@ -87,7 +87,7 @@ char *itoa(int val) * a front end to a more general routine for efficiency. */ -char *itoa7(int val) +char *itoa7(unsigned int val) { char *ptr; static char buffer[16]; /* result is built here */ Modified: head/usr.bin/top/utils.h ============================================================================== --- head/usr.bin/top/utils.h Sat Jun 2 03:33:02 2018 (r334516) +++ head/usr.bin/top/utils.h Sat Jun 2 03:54:50 2018 (r334517) @@ -11,8 +11,8 @@ */ int atoiwi(char *); -char *itoa(int); -char *itoa7(int); +char *itoa(unsigned int); +char *itoa7(unsigned int); int digits(int); char *strecpy(char *, char *); char **argparse(char *, int *);