diff options
author | kn <kn@cvs.openbsd.org> | 2019-10-08 20:51:04 +0000 |
---|---|---|
committer | kn <kn@cvs.openbsd.org> | 2019-10-08 20:51:04 +0000 |
commit | b877879398fe17665b2a9000ce227c1e5407a0ac (patch) | |
tree | e4fbf37015597bd42a584e9602997c2876b1f71f /usr.bin/top/machine.c | |
parent | f3a87abdc8a4d4ed4a13885173f0a789790fb420 (diff) |
Simplify threads flag handling
Instead of always passing the threads flag which decides whether other
function arguments are used or not, make callers pass those arguments or
NULL depending on the threads flag.
This reflects better how thread IDs are shown in place of user names/IDs.
OK millert
Diffstat (limited to 'usr.bin/top/machine.c')
-rw-r--r-- | usr.bin/top/machine.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index af0e006e772..320a42e643f 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machine.c,v 1.99 2019/10/06 15:08:54 kn Exp $ */ +/* $OpenBSD: machine.c,v 1.100 2019/10/08 20:51:03 kn Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert <tholo@sigmasoft.com> @@ -237,15 +237,12 @@ machine_init(struct statics *statics) } char * -format_header(char *second_field, int show_threads) +format_header(char *second_field) { char *field_name, *thread_field = " TID"; char *ptr; - if (show_threads) - field_name = thread_field; - else - field_name = second_field; + field_name = second_field ? second_field : thread_field; ptr = header + UNAME_START; while (*field_name != '\0') @@ -547,7 +544,7 @@ format_comm(struct kinfo_proc *kp) char * format_next_process(struct handle *hndl, const char *(*get_userid)(uid_t, int), - pid_t *pid, int show_threads) + pid_t *pid) { char *p_wait; struct kinfo_proc *pp; @@ -569,7 +566,7 @@ format_next_process(struct handle *hndl, const char *(*get_userid)(uid_t, int), else p_wait = "-"; - if (show_threads) + if (get_userid == NULL) snprintf(buf, sizeof(buf), "%8d", pp->p_tid); else snprintf(buf, sizeof(buf), "%s", (*get_userid)(pp->p_ruid, 0)); |