top(1): filter fewer warnings; clean up

- remove WARNS?=6. It is default
- we no longer have cast-qual problems
- remove unused macros
- remove unneeded casts
- add include guard for loadavg.h
This commit is contained in:
eadler 2018-06-10 06:21:51 +00:00
parent 18f78f76b1
commit 4b53cf024a
5 changed files with 12 additions and 27 deletions

View File

@ -8,17 +8,15 @@ SRCS= commands.c display.c machine.c screen.c top.c \
CFLAGS+= -I ${.OBJDIR}
MAN= top.1
WARNS?= 6
.if ${COMPILER_TYPE} == "gcc"
.if ${COMPILER_VERSION} >= 50000
CFLAGS.gcc=-Wno-error=cast-align -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
NO_WERROR=
.endif
.endif
CFLAGS.clang=-Wno-error=incompatible-pointer-types-discards-qualifiers -Wno-error=cast-qual -Wno-error=cast-align
CFLAGS.clang=-Wno-error=incompatible-pointer-types-discards-qualifiers -Wno-error=cast-qual
LIBADD= ncursesw m kvm jail

View File

@ -14,12 +14,14 @@
* $FreeBSD$
*/
#define FIXED_LOADAVG FSCALE
#define FIXED_PCTCPU FSCALE
#ifndef LOADAVG_H
#define LOADAVG_H
#include <sys/param.h>
typedef long pctcpu;
#define pctdouble(p) ((double)(p) / FIXED_PCTCPU)
#define pctdouble(p) ((double)(p) / FSCALE)
typedef fixpt_t load_avg;
#define loaddouble(la) ((double)(la) / FIXED_LOADAVG)
#define intload(i) ((int)((i) * FIXED_LOADAVG))
#define loaddouble(la) ((double)(la) / FSCALE)
#endif /* LOADAVG_H */

View File

@ -643,8 +643,8 @@ _Static_assert(sizeof(command_chars) == CMD_toggletid + 2, "command chars size")
if (warnings)
{
fputs("....", stderr);
fflush(stderr); /* why must I do this? */
sleep((unsigned)(3 * warnings));
fflush(stderr);
sleep(3 * warnings);
fputc('\n', stderr);
}

View File

@ -23,10 +23,6 @@ extern int Header_lines; /* 7 */
/* maximum number we can have */
#define Largest 0x7fffffff
/*
* The entire display is based on these next numbers being defined as is.
*/
/* Exit code for system errors */
#define TOP_EX_SYS_ERROR 23
@ -43,7 +39,6 @@ extern int pcpu_stats;
extern int overstrike;
extern pid_t mypid;
extern const char * myname;
extern int (*compares[])(const void*, const void*);
@ -75,12 +70,4 @@ void quit(int);
*/
#define Nominal_TOPN 18
/*
* If the local system's getpwnam interface uses random access to retrieve
* a record (i.e.: 4.3 systems, Sun "yellow pages"), then defining
* RANDOM_PW will take advantage of that fact.
*/
#define RANDOM_PW 1
#endif /* TOP_H */

View File

@ -115,8 +115,6 @@ int enter_user(int uid, char name[], bool wecare)
/*
* Get a userid->name mapping from the system.
* If the passwd database is hashed (#define RANDOM_PW), we
* just handle this uid.
*/
int
@ -127,7 +125,7 @@ get_user(int uid)
/* no performance penalty for using getpwuid makes it easy */
if ((pwd = getpwuid(uid)) != NULL)
{
return(enter_user(pwd->pw_uid, pwd->pw_name, 1));
return(enter_user(pwd->pw_uid, pwd->pw_name, 1));
}
/* if we can't find the name at all, then use the uid as the name */