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
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=335024
@ -9,8 +9,7 @@ MAN= top.1
|
|||||||
|
|
||||||
.if ${COMPILER_TYPE} == "gcc"
|
.if ${COMPILER_TYPE} == "gcc"
|
||||||
.if ${COMPILER_VERSION} >= 50000
|
.if ${COMPILER_VERSION} >= 50000
|
||||||
CFLAGS.gcc=-Wno-error=cast-qual -Wno-error=discarded-qualifiers -Wno-error=incompatible-pointer-types \
|
CFLAGS.gcc=-Wno-error=cast-qual -Wno-error=discarded-qualifiers -Wno-error=incompatible-pointer-types
|
||||||
-Wno-error=maybe-uninitialized
|
|
||||||
.else #base gcc
|
.else #base gcc
|
||||||
NO_WERROR=
|
NO_WERROR=
|
||||||
.endif
|
.endif
|
||||||
|
@ -377,12 +377,13 @@ u_procstates(int total, int *brkdn)
|
|||||||
if (ltotal != total)
|
if (ltotal != total)
|
||||||
{
|
{
|
||||||
/* move and overwrite */
|
/* move and overwrite */
|
||||||
#if (x_procstate == 0)
|
if (x_procstate == 0) {
|
||||||
Move_to(x_procstate, y_procstate);
|
Move_to(x_procstate, y_procstate);
|
||||||
#else
|
}
|
||||||
|
else {
|
||||||
/* cursor is already there...no motion needed */
|
/* cursor is already there...no motion needed */
|
||||||
/* assert(lastline == 1); */
|
assert(lastline == 1);
|
||||||
#endif
|
}
|
||||||
printf("%d", total);
|
printf("%d", total);
|
||||||
|
|
||||||
/* if number of digits differs, rewrite the label */
|
/* if number of digits differs, rewrite the label */
|
||||||
@ -955,11 +956,14 @@ new_message(int type, const char *msgfmt, ...)
|
|||||||
i = strlen(next_msg);
|
i = strlen(next_msg);
|
||||||
if ((type & MT_delayed) == 0)
|
if ((type & MT_delayed) == 0)
|
||||||
{
|
{
|
||||||
type & MT_standout ? top_standout(next_msg) :
|
if (type & MT_standout) {
|
||||||
fputs(next_msg, stdout);
|
top_standout(next_msg);
|
||||||
(void) clear_eol(msglen - i);
|
} else {
|
||||||
msglen = i;
|
fputs(next_msg, stdout);
|
||||||
next_msg[0] = '\0';
|
}
|
||||||
|
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)
|
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);
|
msglen = strlen(next_msg);
|
||||||
next_msg[0] = '\0';
|
next_msg[0] = '\0';
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,6 @@ struct handle {
|
|||||||
#define PROCSIZE(pp) ((pp)->ki_size / 1024)
|
#define PROCSIZE(pp) ((pp)->ki_size / 1024)
|
||||||
|
|
||||||
#define RU(pp) (&(pp)->ki_rusage)
|
#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])
|
#define PCTCPU(pp) (pcpu[pp - pbase])
|
||||||
|
|
||||||
|
@ -245,8 +245,8 @@ main(int argc, char *argv[])
|
|||||||
char *env_top;
|
char *env_top;
|
||||||
const char **preset_argv;
|
const char **preset_argv;
|
||||||
int preset_argc = 0;
|
int preset_argc = 0;
|
||||||
const char **av;
|
const char **av = NULL;
|
||||||
int ac;
|
int ac = -1;
|
||||||
bool dostates = false;
|
bool dostates = false;
|
||||||
bool do_unames = true;
|
bool do_unames = true;
|
||||||
char interactive = 2;
|
char interactive = 2;
|
||||||
@ -1230,7 +1230,7 @@ top_winch(int i __unused) /* SIGWINCH handler */
|
|||||||
winchflag = 1;
|
winchflag = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void __dead2
|
||||||
quit(int status) /* exit under duress */
|
quit(int status) /* exit under duress */
|
||||||
{
|
{
|
||||||
end_screen();
|
end_screen();
|
||||||
|
Loading…
Reference in New Issue
Block a user