From owner-svn-src-head@freebsd.org Sun Feb 10 13:31:11 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5BC2B14C752A; Sun, 10 Feb 2019 13:31:11 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F1DD577923; Sun, 10 Feb 2019 13:31:10 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DB306191AB; Sun, 10 Feb 2019 13:31:10 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x1ADVARq003829; Sun, 10 Feb 2019 13:31:10 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x1ADV9LX003822; Sun, 10 Feb 2019 13:31:09 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201902101331.x1ADV9LX003822@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 10 Feb 2019 13:31:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r343957 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: dim X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 343957 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: F1DD577923 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.98)[-0.975,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Feb 2019 13:31:11 -0000 Author: dim Date: Sun Feb 10 13:31:08 2019 New Revision: 343957 URL: https://svnweb.freebsd.org/changeset/base/343957 Log: 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 Modified: head/usr.bin/top/Makefile head/usr.bin/top/display.c head/usr.bin/top/display.h head/usr.bin/top/machine.c head/usr.bin/top/top.c head/usr.bin/top/utils.c head/usr.bin/top/utils.h Modified: head/usr.bin/top/Makefile ============================================================================== --- head/usr.bin/top/Makefile Sun Feb 10 12:49:34 2019 (r343956) +++ head/usr.bin/top/Makefile Sun Feb 10 13:31:08 2019 (r343957) @@ -7,14 +7,9 @@ SRCS= commands.c display.c machine.c screen.c top.c \ username.c utils.c MAN= top.1 -.if ${COMPILER_TYPE} == "gcc" -.if ${COMPILER_VERSION} >= 50000 -CFLAGS.gcc=-Wno-error=discarded-qualifiers -Wno-error=incompatible-pointer-types -.else #base gcc +.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 50000 NO_WERROR= .endif -.endif -CFLAGS.clang=-Wno-error=incompatible-pointer-types-discards-qualifiers LIBADD= ncursesw m kvm jail util sbuf .include Modified: head/usr.bin/top/display.c ============================================================================== --- head/usr.bin/top/display.c Sun Feb 10 12:49:34 2019 (r343956) +++ head/usr.bin/top/display.c Sun Feb 10 13:31:08 2019 (r343957) @@ -184,7 +184,7 @@ int display_init(struct statics * statics) { int lines; - char **pp; + const char * const *pp; int *ip; int i; @@ -516,8 +516,8 @@ void z_cpustates(void) { int i = 0; - const char **names; - char *thisname; + const char * const *names; + const char *thisname; int cpu, value; for (cpu = 0; cpu < num_cpus; cpu++) { @@ -751,7 +751,7 @@ static int header_length; * allocated area with the trimmed header. */ -const char * +char * trim_header(const char *text) { char *s; Modified: head/usr.bin/top/display.h ============================================================================== --- head/usr.bin/top/display.h Sun Feb 10 12:49:34 2019 (r343956) +++ head/usr.bin/top/display.h Sun Feb 10 13:31:08 2019 (r343957) @@ -27,7 +27,7 @@ void i_timeofday(time_t *tod); void i_uptime(struct timeval *bt, time_t *tod); void new_message(int type, const char *msgfmt, ...); 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_carc(int *stats); void u_cpustates(int *states); Modified: head/usr.bin/top/machine.c ============================================================================== --- head/usr.bin/top/machine.c Sun Feb 10 12:49:34 2019 (r343956) +++ head/usr.bin/top/machine.c Sun Feb 10 13:31:08 2019 (r343957) @@ -618,7 +618,7 @@ get_old_proc(struct kinfo_proc *pp) pp->ki_udata = NOPROC; return (NULL); } - pp->ki_udata = oldp; + pp->ki_udata = __DECONST(void *, oldp); return (oldp); } @@ -634,7 +634,7 @@ get_io_stats(const struct kinfo_proc *pp, long *inp, l static struct kinfo_proc dummy; long ret; - oldp = get_old_proc(pp); + oldp = get_old_proc(__DECONST(struct kinfo_proc *, pp)); if (oldp == NULL) { memset(&dummy, 0, sizeof(dummy)); oldp = &dummy; Modified: head/usr.bin/top/top.c ============================================================================== --- head/usr.bin/top/top.c Sun Feb 10 12:49:34 2019 (r343956) +++ head/usr.bin/top/top.c Sun Feb 10 13:31:08 2019 (r343957) @@ -219,7 +219,7 @@ end: } int -main(int argc, char *argv[]) +main(int argc, const char *argv[]) { int i; int active_procs; @@ -306,7 +306,7 @@ main(int argc, char *argv[]) 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) { Modified: head/usr.bin/top/utils.c ============================================================================== --- head/usr.bin/top/utils.c Sun Feb 10 12:49:34 2019 (r343956) +++ head/usr.bin/top/utils.c Sun Feb 10 13:31:08 2019 (r343957) @@ -146,7 +146,7 @@ string_index(const char *string, const char * const *a * squat about quotes. */ -const char * const * +const char ** argparse(char *line, int *cntp) { const char **ap; Modified: head/usr.bin/top/utils.h ============================================================================== --- head/usr.bin/top/utils.h Sun Feb 10 12:49:34 2019 (r343956) +++ head/usr.bin/top/utils.h Sun Feb 10 13:31:08 2019 (r343957) @@ -16,7 +16,7 @@ int atoiwi(const char *); char *itoa(unsigned int); char *itoa7(int); int digits(int); -const char * const *argparse(char *, int *); +const char **argparse(char *, int *); long percentages(int, int *, long *, long *, long *); const char *format_time(long); char *format_k(int64_t);