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
This commit is contained in:
parent
c6a5ff7153
commit
59c50d8277
@ -9,8 +9,7 @@ MAN= top.1
|
||||
|
||||
.if ${COMPILER_TYPE} == "gcc"
|
||||
.if ${COMPILER_VERSION} >= 50000
|
||||
CFLAGS.gcc=-Wno-error=cast-qual -Wno-error=discarded-qualifiers -Wno-error=incompatible-pointer-types \
|
||||
-Wno-error=maybe-uninitialized
|
||||
CFLAGS.gcc=-Wno-error=cast-qual -Wno-error=discarded-qualifiers -Wno-error=incompatible-pointer-types
|
||||
.else #base gcc
|
||||
NO_WERROR=
|
||||
.endif
|
||||
|
@ -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';
|
||||
}
|
||||
|
@ -79,8 +79,6 @@ struct handle {
|
||||
#define PROCSIZE(pp) ((pp)->ki_size / 1024)
|
||||
|
||||
#define RU(pp) (&(pp)->ki_rusage)
|
||||
#define RUTOT(pp) \
|
||||
(RU(pp)->ru_inblock + RU(pp)->ru_oublock + RU(pp)->ru_majflt)
|
||||
|
||||
#define PCTCPU(pp) (pcpu[pp - pbase])
|
||||
|
||||
|
@ -245,8 +245,8 @@ main(int argc, char *argv[])
|
||||
char *env_top;
|
||||
const char **preset_argv;
|
||||
int preset_argc = 0;
|
||||
const char **av;
|
||||
int ac;
|
||||
const char **av = NULL;
|
||||
int ac = -1;
|
||||
bool dostates = false;
|
||||
bool do_unames = true;
|
||||
char interactive = 2;
|
||||
@ -1230,7 +1230,7 @@ top_winch(int i __unused) /* SIGWINCH handler */
|
||||
winchflag = 1;
|
||||
}
|
||||
|
||||
void
|
||||
void __dead2
|
||||
quit(int status) /* exit under duress */
|
||||
{
|
||||
end_screen();
|
||||
|
Loading…
x
Reference in New Issue
Block a user