diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 66ecf5afb39f..fbea363da3c2 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -914,7 +914,7 @@ get_process_info(struct system_info *si, struct process_select *sel, 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; diff --git a/usr.bin/top/machine.h b/usr.bin/top/machine.h index 0e8e2f2c6eb6..20d6e0faec16 100644 --- a/usr.bin/top/machine.h +++ b/usr.bin/top/machine.h @@ -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); diff --git a/usr.bin/top/screen.c b/usr.bin/top/screen.c index a564a5cfb265..22cf7b93d32f 100644 --- a/usr.bin/top/screen.c +++ b/usr.bin/top/screen.c @@ -25,7 +25,6 @@ #include #include #include -#define TERMIOS #include #include #include diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index e03178dd2801..d44dd9898810 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -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; diff --git a/usr.bin/top/username.c b/usr.bin/top/username.c index 74eaf9b4fc32..c962751090ad 100644 --- a/usr.bin/top/username.c +++ b/usr.bin/top/username.c @@ -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; diff --git a/usr.bin/top/username.h b/usr.bin/top/username.h index b06a227890fc..2975a9ee9480 100644 --- a/usr.bin/top/username.h +++ b/usr.bin/top/username.h @@ -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 diff --git a/usr.bin/top/utils.c b/usr.bin/top/utils.c index 2f51da76e516..4a8a0d8817d4 100644 --- a/usr.bin/top/utils.c +++ b/usr.bin/top/utils.c @@ -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 */ diff --git a/usr.bin/top/utils.h b/usr.bin/top/utils.h index de993d0208e9..d04645dd8a17 100644 --- a/usr.bin/top/utils.h +++ b/usr.bin/top/utils.h @@ -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 *);