Fix multiple warnings in usr.bin/top about discarded qualifiers from
both clang and gcc, by either constifying variables, or when that is not possible, using __DECONST. MFC after: 1 week
This commit is contained in:
parent
fb17e65b4c
commit
24a0b90e26
@ -7,14 +7,9 @@ SRCS= commands.c display.c machine.c screen.c top.c \
|
|||||||
username.c utils.c
|
username.c utils.c
|
||||||
MAN= top.1
|
MAN= top.1
|
||||||
|
|
||||||
.if ${COMPILER_TYPE} == "gcc"
|
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 50000
|
||||||
.if ${COMPILER_VERSION} >= 50000
|
|
||||||
CFLAGS.gcc=-Wno-error=discarded-qualifiers -Wno-error=incompatible-pointer-types
|
|
||||||
.else #base gcc
|
|
||||||
NO_WERROR=
|
NO_WERROR=
|
||||||
.endif
|
.endif
|
||||||
.endif
|
|
||||||
CFLAGS.clang=-Wno-error=incompatible-pointer-types-discards-qualifiers
|
|
||||||
|
|
||||||
LIBADD= ncursesw m kvm jail util sbuf
|
LIBADD= ncursesw m kvm jail util sbuf
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
@ -184,7 +184,7 @@ int
|
|||||||
display_init(struct statics * statics)
|
display_init(struct statics * statics)
|
||||||
{
|
{
|
||||||
int lines;
|
int lines;
|
||||||
char **pp;
|
const char * const *pp;
|
||||||
int *ip;
|
int *ip;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -516,8 +516,8 @@ void
|
|||||||
z_cpustates(void)
|
z_cpustates(void)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
const char **names;
|
const char * const *names;
|
||||||
char *thisname;
|
const char *thisname;
|
||||||
int cpu, value;
|
int cpu, value;
|
||||||
|
|
||||||
for (cpu = 0; cpu < num_cpus; cpu++) {
|
for (cpu = 0; cpu < num_cpus; cpu++) {
|
||||||
@ -751,7 +751,7 @@ static int header_length;
|
|||||||
* allocated area with the trimmed header.
|
* allocated area with the trimmed header.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char *
|
char *
|
||||||
trim_header(const char *text)
|
trim_header(const char *text)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
|
@ -27,7 +27,7 @@ void i_timeofday(time_t *tod);
|
|||||||
void i_uptime(struct timeval *bt, time_t *tod);
|
void i_uptime(struct timeval *bt, time_t *tod);
|
||||||
void new_message(int type, const char *msgfmt, ...);
|
void new_message(int type, const char *msgfmt, ...);
|
||||||
int readline(char *buffer, int size, int numeric);
|
int readline(char *buffer, int size, int numeric);
|
||||||
const char *trim_header(const char *text);
|
char *trim_header(const char *text);
|
||||||
void u_arc(int *stats);
|
void u_arc(int *stats);
|
||||||
void u_carc(int *stats);
|
void u_carc(int *stats);
|
||||||
void u_cpustates(int *states);
|
void u_cpustates(int *states);
|
||||||
|
@ -618,7 +618,7 @@ get_old_proc(struct kinfo_proc *pp)
|
|||||||
pp->ki_udata = NOPROC;
|
pp->ki_udata = NOPROC;
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
pp->ki_udata = oldp;
|
pp->ki_udata = __DECONST(void *, oldp);
|
||||||
return (oldp);
|
return (oldp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,7 +634,7 @@ get_io_stats(const struct kinfo_proc *pp, long *inp, long *oup, long *flp,
|
|||||||
static struct kinfo_proc dummy;
|
static struct kinfo_proc dummy;
|
||||||
long ret;
|
long ret;
|
||||||
|
|
||||||
oldp = get_old_proc(pp);
|
oldp = get_old_proc(__DECONST(struct kinfo_proc *, pp));
|
||||||
if (oldp == NULL) {
|
if (oldp == NULL) {
|
||||||
memset(&dummy, 0, sizeof(dummy));
|
memset(&dummy, 0, sizeof(dummy));
|
||||||
oldp = &dummy;
|
oldp = &dummy;
|
||||||
|
@ -219,7 +219,7 @@ handle_user(char *buf, size_t buflen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int active_procs;
|
int active_procs;
|
||||||
@ -306,7 +306,7 @@ main(int argc, char *argv[])
|
|||||||
optind = 1;
|
optind = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((i = getopt_long(ac, av, "CSIHPabijJ:nquvzs:d:U:m:o:p:Ttw", longopts, NULL)) != EOF)
|
while ((i = getopt_long(ac, __DECONST(char * const *, av), "CSIHPabijJ:nquvzs:d:U:m:o:p:Ttw", longopts, NULL)) != EOF)
|
||||||
{
|
{
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,7 @@ string_index(const char *string, const char * const *array)
|
|||||||
* squat about quotes.
|
* squat about quotes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char * const *
|
const char **
|
||||||
argparse(char *line, int *cntp)
|
argparse(char *line, int *cntp)
|
||||||
{
|
{
|
||||||
const char **ap;
|
const char **ap;
|
||||||
|
@ -16,7 +16,7 @@ int atoiwi(const char *);
|
|||||||
char *itoa(unsigned int);
|
char *itoa(unsigned int);
|
||||||
char *itoa7(int);
|
char *itoa7(int);
|
||||||
int digits(int);
|
int digits(int);
|
||||||
const char * const *argparse(char *, int *);
|
const char **argparse(char *, int *);
|
||||||
long percentages(int, int *, long *, long *, long *);
|
long percentages(int, int *, long *, long *, long *);
|
||||||
const char *format_time(long);
|
const char *format_time(long);
|
||||||
char *format_k(int64_t);
|
char *format_k(int64_t);
|
||||||
|
Loading…
Reference in New Issue
Block a user