diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-06-15 16:24:45 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-06-15 16:24:45 +0000 |
commit | 16f2fb7e4ecb3476a3bd28b631e5378ee6a103ae (patch) | |
tree | 0b35a1decba01534abd9b339922b360716e957e3 /usr.bin | |
parent | eac3b9622068e1035c7d1974494a272c26427fe7 (diff) |
use uid_t and fix some sign compare warnings; OK krw@ and deraadt@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/top/commands.c | 8 | ||||
-rw-r--r-- | usr.bin/top/machine.c | 12 | ||||
-rw-r--r-- | usr.bin/top/machine.h | 6 | ||||
-rw-r--r-- | usr.bin/top/top.c | 13 | ||||
-rw-r--r-- | usr.bin/top/username.c | 12 |
5 files changed, 27 insertions, 24 deletions
diff --git a/usr.bin/top/commands.c b/usr.bin/top/commands.c index 777ed5b02c0..e88892c6359 100644 --- a/usr.bin/top/commands.c +++ b/usr.bin/top/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.9 2003/06/13 21:52:24 deraadt Exp $ */ +/* $OpenBSD: commands.c,v 1.10 2003/06/15 16:24:44 millert Exp $ */ /* * Top users/processes display for Unix @@ -317,8 +317,9 @@ show_errors(void) char * kill_procs(char *str) { - int signum = SIGTERM, procnum, uid; + int signum = SIGTERM, procnum; struct sigdesc *sigp; + uid_t uid; char *nptr; /* reset error array */ @@ -381,8 +382,9 @@ kill_procs(char *str) char * renice_procs(char *str) { - int prio, procnum, uid; + uid_t uid; char negate; + int prio, procnum; ERR_RESET; uid = getuid(); diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 442123114f6..46b4673b049 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machine.c,v 1.32 2003/06/14 20:23:41 avsm Exp $ */ +/* $OpenBSD: machine.c,v 1.33 2003/06/15 16:24:44 millert Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert <tholo@sigmasoft.com> @@ -144,7 +144,7 @@ static int pageshift; /* log base 2 of the pagesize */ /* define pagetok in terms of pageshift */ #define pagetok(size) ((size) << pageshift) -int maxslp; +unsigned int maxslp; int getstathz(void) @@ -311,7 +311,7 @@ caddr_t get_process_info(struct system_info *si, struct process_select *sel, int (*compare) (const void *, const void *)) { - int show_idle, show_system, show_uid, show_command; + int show_idle, show_system, show_uid; int total_procs, active_procs, i; struct kinfo_proc **prefp, *pp; @@ -332,7 +332,7 @@ get_process_info(struct system_info *si, struct process_select *sel, /* set up flags which define what we are going to select */ show_idle = sel->idle; show_system = sel->system; - show_uid = sel->uid != -1; + show_uid = sel->uid != (uid_t)-1; /* count up process states and get pointers to interesting procs */ total_procs = 0; @@ -353,7 +353,7 @@ get_process_info(struct system_info *si, struct process_select *sel, if ((PP(pp, p_stat) != SZOMB) && (show_idle || (PP(pp, p_pctcpu) != 0) || (PP(pp, p_stat) == SRUN)) && - (!show_uid || EP(pp, e_pcred.p_ruid) == (uid_t) sel->uid)) { + (!show_uid || EP(pp, e_pcred.p_ruid) == sel->uid)) { *prefp++ = pp; active_procs++; } @@ -610,7 +610,7 @@ int (*proc_compares[])(const void *, const void *) = { * security problem. It validates requests for the "kill" * and "renice" commands. */ -int +uid_t proc_owner(pid_t pid) { struct kinfo_proc **prefp, *pp; diff --git a/usr.bin/top/machine.h b/usr.bin/top/machine.h index 5fea2eaede4..040c761604f 100644 --- a/usr.bin/top/machine.h +++ b/usr.bin/top/machine.h @@ -1,4 +1,4 @@ -/* $OpenBSD: machine.h,v 1.7 2003/06/13 21:52:25 deraadt Exp $ */ +/* $OpenBSD: machine.h,v 1.8 2003/06/15 16:24:44 millert Exp $ */ /* * Top users/processes display for Unix @@ -72,7 +72,7 @@ struct system_info { struct process_select { int idle; /* show idle processes */ int system; /* show system processes */ - int uid; /* only this uid (unless uid == -1) */ + uid_t uid; /* only this uid (unless uid == -1) */ char *command;/* only this command (unless == NULL) */ }; @@ -88,4 +88,4 @@ get_process_info(struct system_info *, struct process_select *, int (*) (const void *, const void *)); extern char *format_next_process(caddr_t, char *(*) ()); extern int proc_compate(const void *, const void *); -extern int proc_owner(pid_t); +extern uid_t proc_owner(pid_t); diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index 8bde67d651d..77f56bef058 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -1,4 +1,4 @@ -/* $OpenBSD: top.c,v 1.20 2003/06/13 21:52:25 deraadt Exp $ */ +/* $OpenBSD: top.c,v 1.21 2003/06/15 16:24:44 millert Exp $ */ /* * Top users/processes display for Unix @@ -155,7 +155,7 @@ parseargs(int ac, char **av) break; case 'U': /* display only username's processes */ - if ((ps.uid = userid(optarg)) == -1) { + if ((ps.uid = userid(optarg)) == (uid_t)-1) { fprintf(stderr, "%s: unknown user\n", optarg); exit(1); } @@ -266,7 +266,7 @@ main(int argc, char *argv[]) /* initialize some selection options */ ps.idle = Yes; ps.system = No; - ps.uid = -1; + ps.uid = (uid_t)-1; ps.command = NULL; /* get preset options from the environment */ @@ -512,6 +512,7 @@ rundisplay(void) sigset_t mask; char ch, *iptr; int change, i; + uid_t uid; static char command_chars[] = "\f qh?en#sdkriIuSo"; /* @@ -757,13 +758,13 @@ rundisplay(void) if (readline(tempbuf2, sizeof(tempbuf2), No) > 0) { if (tempbuf2[0] == '+' && tempbuf2[1] == '\0') { - ps.uid = -1; - } else if ((i = userid(tempbuf2)) == -1) { + ps.uid = (uid_t)-1; + } else if ((uid = userid(tempbuf2)) == (uid_t)-1) { new_message(MT_standout, " %s: unknown user", tempbuf2); no_command = Yes; } else - ps.uid = i; + ps.uid = uid; if (putchar('\r') == EOF) exit(1); } else diff --git a/usr.bin/top/username.c b/usr.bin/top/username.c index 5c854167abc..42cdd37c780 100644 --- a/usr.bin/top/username.c +++ b/usr.bin/top/username.c @@ -1,4 +1,4 @@ -/* $OpenBSD: username.c,v 1.10 2003/06/13 21:52:25 deraadt Exp $ */ +/* $OpenBSD: username.c,v 1.11 2003/06/15 16:24:44 millert Exp $ */ /* * Top users/processes display for Unix @@ -56,21 +56,21 @@ #include "utils.h" struct hash_el { - uid_t uid; - char name[9]; + uid_t uid; + char name[9]; }; static int enter_user(uid_t, char *, int); static int get_user(uid_t); -#define is_empty_hash(x) (hash_table[x].name[0] == 0) +#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) (abs(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! */ @@ -99,7 +99,7 @@ userid(char *username) * for now we just do it simply and remember just the result. */ if ((pwd = getpwnam(username)) == NULL) - return (-1); + return ((uid_t)-1); /* enter the result in the hash table */ enter_user(pwd->pw_uid, username, 1); |