diff options
author | Eitan Adler <eadler@FreeBSD.org> | 2018-06-13 00:45:38 +0000 |
---|---|---|
committer | Eitan Adler <eadler@FreeBSD.org> | 2018-06-13 00:45:38 +0000 |
commit | 59c50d827765047037b5e57a643890c74302ad4e (patch) | |
tree | 3ac2c810a8759b8bfa26578cd0d0c61be004ed44 /usr.bin/top/display.c | |
parent | c6a5ff7153f77a9bf1bacf0a93b3bfb8db83944d (diff) | |
download | src-59c50d827765047037b5e57a643890c74302ad4e.tar.gz src-59c50d827765047037b5e57a643890c74302ad4e.zip |
top(1): several small bugfixes and nits
- initialize all maybe uninitialized vars with bogus values. This shuts
up the compiler, and causes crashes if it changes later.
- mark noreturn as noreturn
- removed unused macro
- handle x_procstate as runtime rather than pre-processor
- avoid using void functions in condtionals
Tested with clang, gcc 7, gcc 9
Notes
Notes:
svn path=/head/; revision=335024
Diffstat (limited to 'usr.bin/top/display.c')
-rw-r--r-- | usr.bin/top/display.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/usr.bin/top/display.c b/usr.bin/top/display.c index 5ec4ea37cc08..7465066e8184 100644 --- a/usr.bin/top/display.c +++ b/usr.bin/top/display.c @@ -377,12 +377,13 @@ u_procstates(int total, int *brkdn) if (ltotal != total) { /* move and overwrite */ -#if (x_procstate == 0) +if (x_procstate == 0) { Move_to(x_procstate, y_procstate); -#else +} +else { /* cursor is already there...no motion needed */ - /* assert(lastline == 1); */ -#endif + assert(lastline == 1); +} printf("%d", total); /* if number of digits differs, rewrite the label */ @@ -955,11 +956,14 @@ new_message(int type, const char *msgfmt, ...) i = strlen(next_msg); if ((type & MT_delayed) == 0) { - type & MT_standout ? top_standout(next_msg) : - fputs(next_msg, stdout); - (void) clear_eol(msglen - i); - msglen = i; - next_msg[0] = '\0'; + if (type & MT_standout) { + top_standout(next_msg); + } else { + fputs(next_msg, stdout); + } + clear_eol(msglen - i); + msglen = i; + next_msg[0] = '\0'; } } } @@ -967,7 +971,11 @@ new_message(int type, const char *msgfmt, ...) { if ((type & MT_delayed) == 0) { - type & MT_standout ? top_standout(next_msg) : fputs(next_msg, stdout); + if (type & MT_standout) { + top_standout(next_msg); + } else { + fputs(next_msg, stdout); + } msglen = strlen(next_msg); next_msg[0] = '\0'; } |