From owner-svn-src-all@freebsd.org Mon May 21 09:18:04 2018 Return-Path: Delivered-To: svn-src-all@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 01698EEA7D0; Mon, 21 May 2018 09:18:04 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A749A75582; Mon, 21 May 2018 09:18:03 +0000 (UTC) (envelope-from eadler@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 8427622F4B; Mon, 21 May 2018 09:18:03 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4L9I3tY043216; Mon, 21 May 2018 09:18:03 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4L9I1G1043208; Mon, 21 May 2018 09:18:01 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201805210918.w4L9I1G1043208@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Mon, 21 May 2018 09:18:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333969 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 333969 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2018 09:18:04 -0000 Author: eadler Date: Mon May 21 09:18:01 2018 New Revision: 333969 URL: https://svnweb.freebsd.org/changeset/base/333969 Log: top(1): modernize a bit; reduce warnings - Replace caddr_t with "void *". This reduces the number of warnings at WARNS=6 - use "static" where possible - sprinkle const where possible This leaves at WARNS=6: 35 warnings in top.c 72 warnings in machine.c 5 warnings in commands.c all of which are either "incompatible-pointer-types-discards-qualifiers" or "cast-qual" Modified: head/usr.bin/top/Makefile head/usr.bin/top/commands.c head/usr.bin/top/display.c head/usr.bin/top/machine.c head/usr.bin/top/machine.h head/usr.bin/top/screen.c head/usr.bin/top/top.c head/usr.bin/top/top.h head/usr.bin/top/username.c Modified: head/usr.bin/top/Makefile ============================================================================== --- head/usr.bin/top/Makefile Mon May 21 08:34:10 2018 (r333968) +++ head/usr.bin/top/Makefile Mon May 21 09:18:01 2018 (r333969) @@ -7,7 +7,7 @@ SRCS+= sigdesc.h top.local.h CFLAGS+= -I ${.OBJDIR} MAN= top.1 -WARNS?= 3 +WARNS?= 6 LIBADD= ncursesw m kvm jail Modified: head/usr.bin/top/commands.c ============================================================================== --- head/usr.bin/top/commands.c Mon May 21 08:34:10 2018 (r333968) +++ head/usr.bin/top/commands.c Mon May 21 09:18:01 2018 (r333969) @@ -177,8 +177,8 @@ int *intp; static struct errs errs[ERRMAX]; static int errcnt; -static char *err_toomany = " too many errors occurred"; -static char *err_listem = +static char err_toomany[] = " too many errors occurred"; +static char err_listem[] = " Many errors occurred. Press `e' to display the list of errors."; /* These macros get used to reset and log the errors */ Modified: head/usr.bin/top/display.c ============================================================================== --- head/usr.bin/top/display.c Mon May 21 08:34:10 2018 (r333968) +++ head/usr.bin/top/display.c Mon May 21 09:18:01 2018 (r333969) @@ -588,13 +588,10 @@ for (cpu = 0; cpu < num_cpus; cpu++) { * for i_memory ONLY: cursor is on the previous line */ -char memory_buffer[MAX_COLS]; +static char memory_buffer[MAX_COLS]; void -i_memory(stats) - -int *stats; - +i_memory(int *stats) { fputs("\nMem: ", stdout); lastline++; @@ -605,10 +602,7 @@ int *stats; } void -u_memory(stats) - -int *stats; - +u_memory(int *stats) { static char new[MAX_COLS]; Modified: head/usr.bin/top/machine.c ============================================================================== --- head/usr.bin/top/machine.c Mon May 21 08:34:10 2018 (r333968) +++ head/usr.bin/top/machine.c Mon May 21 09:18:01 2018 (r333969) @@ -53,7 +53,6 @@ #define SMPUNAMELEN 13 #define UPUNAMELEN 15 -extern struct process_select ps; extern struct timeval timeout; static int smpmode; enum displaymodes displaymode; @@ -229,7 +228,7 @@ static int pageshift; /* log base 2 of the pagesize * /* * Sorting orders. The first element is the default. */ -char *ordernames[] = { +static const char *ordernames[] = { "cpu", "size", "res", "time", "pri", "threads", "total", "read", "write", "fault", "vcsw", "ivcsw", "jid", "swap", "pid", NULL @@ -743,7 +742,7 @@ get_io_total(struct kinfo_proc *pp) static struct handle handle; -caddr_t +void * get_process_info(struct system_info *si, struct process_select *sel, int (*compare)(const void *, const void *)) { @@ -910,13 +909,13 @@ get_process_info(struct system_info *si, struct proces /* pass back a handle */ handle.next_proc = pref; handle.remaining = active_procs; - return ((caddr_t)&handle); + return (&handle); } static char fmt[512]; /* static area where result is built */ char * -format_next_process(caddr_t xhandle, char *(*get_userid)(int), int flags) +format_next_process(void * xhandle, char *(*get_userid)(int), int flags) { struct kinfo_proc *pp; const struct kinfo_proc *oldp; Modified: head/usr.bin/top/machine.h ============================================================================== --- head/usr.bin/top/machine.h Mon May 21 08:34:10 2018 (r333968) +++ head/usr.bin/top/machine.h Mon May 21 09:18:01 2018 (r333969) @@ -75,17 +75,18 @@ struct process_select /* routines defined by the machine dependent module */ char *format_header(char *uname_field); -char *format_next_process(caddr_t handle, char *(*get_userid)(int), +char *format_next_process(void * handle, char *(*get_userid)(int), int flags); void toggle_pcpustats(void); void get_system_info(struct system_info *si); int machine_init(struct statics *statics); int proc_owner(int pid); +extern struct process_select ps; /* non-int routines typically used by the machine dependent module */ char *printable(char *string); -caddr_t +void * get_process_info(struct system_info *si, struct process_select *sel, int (*compare)(const void *, const void *)); Modified: head/usr.bin/top/screen.c ============================================================================== --- head/usr.bin/top/screen.c Mon May 21 08:34:10 2018 (r333968) +++ head/usr.bin/top/screen.c Mon May 21 09:18:01 2018 (r333969) @@ -39,18 +39,18 @@ char ch_erase; char ch_kill; char smart_terminal; char PC; -char termcap_buf[1024]; -char string_buffer[1024]; -char home[15]; -char lower_left[15]; +static char termcap_buf[1024]; +static char string_buffer[1024]; +static char home[15]; +static char lower_left[15]; char *clear_line; -char *clear_screen; +static char *clear_screen; char *clear_to_end; char *cursor_motion; -char *start_standout; -char *end_standout; -char *terminal_init; -char *terminal_end; +static char *start_standout; +static char *end_standout; +static char *terminal_init; +static char *terminal_end; static struct termios old_settings; static struct termios new_settings; Modified: head/usr.bin/top/top.c ============================================================================== --- head/usr.bin/top/top.c Mon May 21 08:34:10 2018 (r333968) +++ head/usr.bin/top/top.c Mon May 21 09:18:01 2018 (r333969) @@ -40,7 +40,7 @@ /* Size of the stdio buffer given to stdout */ #define Buffersize 2048 -char *copyright = +char copyright[] = "Copyright (c) 1984 through 1996, William LeFebvre"; typedef void sigret_t; @@ -211,7 +211,7 @@ char *argv[]; struct system_info system_info; struct statics statics; - caddr_t processes; + void * processes; static char tempbuf1[50]; static char tempbuf2[50]; Modified: head/usr.bin/top/top.h ============================================================================== --- head/usr.bin/top/top.h Mon May 21 08:34:10 2018 (r333968) +++ head/usr.bin/top/top.h Mon May 21 09:18:01 2018 (r333969) @@ -53,7 +53,7 @@ extern int (*compares[])(const void*, const void*); char* kill_procs(char *); char* renice_procs(char *); -extern char *copyright; +extern char copyright[]; /* internal routines */ void quit(int); Modified: head/usr.bin/top/username.c ============================================================================== --- head/usr.bin/top/username.c Mon May 21 08:34:10 2018 (r333968) +++ head/usr.bin/top/username.c Mon May 21 09:18:01 2018 (r333969) @@ -56,7 +56,7 @@ struct hash_el { /* K&R requires that statically declared tables be initialized to zero. */ /* We depend on that for hash_table and YOUR compiler had BETTER do it! */ -struct hash_el hash_table[Table_size]; +static struct hash_el hash_table[Table_size]; char *username(uid)