From owner-svn-src-head@freebsd.org Sun May 20 02:14:29 2018 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 C3B86EEDEEA; Sun, 20 May 2018 02:14:29 +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 76B7F69ADE; Sun, 20 May 2018 02:14:29 +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 58C4F7F66; Sun, 20 May 2018 02:14:29 +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 w4K2ETu1002250; Sun, 20 May 2018 02:14:29 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4K2ESYM002245; Sun, 20 May 2018 02:14:28 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201805200214.w4K2ESYM002245@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sun, 20 May 2018 02:14:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333909 - 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: 333909 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 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, 20 May 2018 02:14:30 -0000 Author: eadler Date: Sun May 20 02:14:27 2018 New Revision: 333909 URL: https://svnweb.freebsd.org/changeset/base/333909 Log: top(1): Quiesce several warnings This is all warnings at level six (6) that are not char-subscripts, incompatible-pointer-types, sign-compare, switch, int-conversion, missing-variable-declarations, cast-qual, cast-align Some warnings that are fixed by this commit are: shadow, strict-prototypes, missing-prototypes, pointer-arith, unused-parameter, unused-const-variable, and several others Modified: head/usr.bin/top/commands.c head/usr.bin/top/machine.c head/usr.bin/top/top.c head/usr.bin/top/top.h head/usr.bin/top/utils.c head/usr.bin/top/utils.h Modified: head/usr.bin/top/commands.c ============================================================================== --- head/usr.bin/top/commands.c Sun May 20 01:32:27 2018 (r333908) +++ head/usr.bin/top/commands.c Sun May 20 02:14:27 2018 (r333909) @@ -1,6 +1,5 @@ /* * Top users/processes display for Unix - * Version 3 * * This program may be freely redistributed, * but this entire comment MUST remain intact. @@ -36,15 +35,20 @@ #include "utils.h" #include "machine.h" -extern int errno; - extern char *copyright; /* imported from screen.c */ extern int overstrike; -int err_compar(); -char *err_string(); +static int err_compar(const void *p1, const void *p2); + +struct errs /* structure for a system-call error */ +{ + int errnum; /* value of errno (that is, the actual error) */ + char *arg; /* argument that caused the error */ +}; + +char *err_string(void); static int str_adderr(char *str, int len, int err); static int str_addarg(char *str, int len, char *arg, int first); @@ -114,10 +118,8 @@ z - toggle the displaying of the system idle pro * Utility routines that help with some of the commands. */ -char *next_field(str) - -char *str; - +static char * +next_field(char *str) { if ((str = strchr(str, ' ')) == NULL) { @@ -131,7 +133,7 @@ char *str; return(*str == '\0' ? NULL : str); } -int +static int scanint(str, intp) char *str; @@ -178,12 +180,6 @@ int *intp; #define ERRMAX 20 -struct errs /* structure for a system-call error */ -{ - int errnum; /* value of errno (that is, the actual error) */ - char *arg; /* argument that caused the error */ -}; - static struct errs errs[ERRMAX]; static int errcnt; static char *err_toomany = " too many errors occurred"; @@ -212,7 +208,6 @@ static char *err_listem = #define STRMAX 80 char *err_string() - { struct errs *errp; int cnt = 0; @@ -282,7 +277,7 @@ int err; char *msg; int msglen; - msg = err == 0 ? "Not a number" : errmsg(err); + msg = err == 0 ? "Not a number" : strerror(err); msglen = strlen(msg) + 2; if (len <= msglen) { @@ -332,17 +327,18 @@ int first; * for sorting errors. */ -int -err_compar(p1, p2) - -struct errs *p1, *p2; - +static int +err_compar(const void *p1, const void *p2) { int result; + struct errs * g1 = (struct errs *)p1; + struct errs * g2 = (struct errs *)p2; - if ((result = p1->errnum - p2->errnum) == 0) + + + if ((result = g1->errnum - g2->errnum) == 0) { - return(strcmp(p1->arg, p2->arg)); + return(strcmp(g1->arg, g2->arg)); } return(result); } @@ -373,7 +369,7 @@ show_errors() while (cnt++ < errcnt) { printf("%5s: %s\n", errp->arg, - errp->errnum == 0 ? "Not a number" : errmsg(errp->errnum)); + errp->errnum == 0 ? "Not a number" : strerror(errp->errnum)); errp++; } } @@ -383,10 +379,8 @@ show_errors() * command does; invoked in response to 'k'. */ -char *kill_procs(str) - -char *str; - +char * +kill_procs(char *str) { char *nptr; int signum = SIGTERM; /* default */ @@ -473,10 +467,8 @@ char *str; * "renice" command does; invoked in response to 'r'. */ -char *renice_procs(str) - -char *str; - +char * +renice_procs(char *str) { char negate; int prio; Modified: head/usr.bin/top/machine.c ============================================================================== --- head/usr.bin/top/machine.c Sun May 20 01:32:27 2018 (r333908) +++ head/usr.bin/top/machine.c Sun May 20 02:14:27 2018 (r333909) @@ -1,20 +1,12 @@ /* * top - a top users display for Unix * - * SYNOPSIS: For FreeBSD-2.x and later - * * DESCRIPTION: * Originally written for BSD4.4 system by Christos Zoulas. * Ported to FreeBSD 2.x by Steven Wallace && Wolfram Schneider * Order support hacked in from top-3.5beta6/machine/m_aix41.c * by Monte Mitzelfelt (for latest top see http://www.groupsys.com/topinfo/) * - * This is the machine-dependent module for FreeBSD 2.2 - * Works for: - * FreeBSD 2.2.x, 3.x, 4.x, and probably FreeBSD 2.1.x - * - * LIBS: -lkvm - * * AUTHOR: Christos Zoulas * Steven Wallace * Wolfram Schneider @@ -580,7 +572,7 @@ get_system_info(struct system_info *si) arc_stats[3] = arc_stat >> 10; GETSYSCTL("kstat.zfs.misc.arcstats.hdr_size", arc_stat); GETSYSCTL("kstat.zfs.misc.arcstats.l2_hdr_size", arc_stat2); - arc_stats[4] = arc_stat + arc_stat2 >> 10; + arc_stats[4] = (arc_stat + arc_stat2) >> 10; GETSYSCTL("kstat.zfs.misc.arcstats.other_size", arc_stat); arc_stats[5] = arc_stat >> 10; si->arc = arc_stats; @@ -938,7 +930,7 @@ get_process_info(struct system_info *si, struct proces static char fmt[512]; /* static area where result is built */ char * -format_next_process(caddr_t handle, char *(*get_userid)(int), int flags) +format_next_process(caddr_t xhandle, char *(*get_userid)(int), int flags) { struct kinfo_proc *pp; const struct kinfo_proc *oldp; @@ -956,7 +948,7 @@ format_next_process(caddr_t handle, char *(*get_userid const int cmdlen = 128; /* find and remember the next proc structure */ - hp = (struct handle *)handle; + hp = (struct handle *)xhandle; pp = *(hp->next_proc++); hp->remaining--; @@ -1001,11 +993,8 @@ format_next_process(caddr_t handle, char *(*get_userid } /* fall through */ case SSLEEP: - if (pp->ki_wmesg != NULL) { - sprintf(status, "%.6s", pp->ki_wmesg); - break; - } - /* FALLTHROUGH */ + sprintf(status, "%.6s", pp->ki_wmesg); + break; default: if (state >= 0 && Modified: head/usr.bin/top/top.c ============================================================================== --- head/usr.bin/top/top.c Sun May 20 01:32:27 2018 (r333908) +++ head/usr.bin/top/top.c Sun May 20 02:14:27 2018 (r333909) @@ -83,9 +83,7 @@ int pcpu_stats = No; /* signal handling routines */ sigret_t leave(); sigret_t tstop(); -#ifdef SIGWINCH sigret_t top_winch(int); -#endif volatile sig_atomic_t leaveflag; volatile sig_atomic_t tstopflag; @@ -105,9 +103,6 @@ jmp_buf jmp_int; /* routines that don't return int */ char *username(); -char *ctime(); -char *kill_procs(); -char *renice_procs(); extern int (*compares[])(); time_t time(); @@ -282,12 +277,6 @@ char *argv[]; struct timeval timeout; char *order_name = NULL; int order_index = 0; -#ifndef FD_SET - /* FD_SET and friends are not present: fake it */ - typedef int fd_set; -#define FD_ZERO(x) (*(x) = 0) -#define FD_SET(f, x) (*(x) = 1< #include -int atoiwi(str) - -char *str; - +int +atoiwi(char *str) { int len; @@ -148,11 +146,8 @@ int val; * to the END of the string "to". */ -char *strecpy(to, from) - -char *to; -char *from; - +char * +strecpy(char *to, char *from) { while ((*to++ = *from++) != '\0'); return(--to); @@ -327,33 +322,6 @@ long *diffs; return(total_change); } -/* - * errmsg(errnum) - return an error message string appropriate to the - * error number "errnum". This is a substitute for the System V - * function "strerror". There appears to be no reliable way to - * determine if "strerror" exists at compile time, so I make do - * by providing something of similar functionality. For those - * systems that have strerror and NOT errlist, define - * -DHAVE_STRERROR in the module file and this function will - * use strerror. - */ - -/* externs referenced by errmsg */ - - -char *errmsg(errnum) - -int errnum; - -{ - char *msg = strerror(errnum); - if (msg != NULL) - { - return msg; - } - return("No error"); -} - /* format_time(seconds) - format number of seconds into a suitable * display that will fit within 6 characters. Note that this * routine builds its string in a static area. If it needs @@ -375,9 +343,6 @@ char *format_time(seconds) long seconds; { - int value; - int digit; - char *ptr; static char result[10]; /* sanity protection */ Modified: head/usr.bin/top/utils.h ============================================================================== --- head/usr.bin/top/utils.h Sun May 20 01:32:27 2018 (r333908) +++ head/usr.bin/top/utils.h Sun May 20 02:14:27 2018 (r333909) @@ -1,6 +1,7 @@ /* + * $FreeBSD$ + * * Top users/processes display for Unix - * Version 3 * * This program may be freely redistributed, * but this entire comment MUST remain intact. @@ -9,18 +10,15 @@ * Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University */ -/* prototypes for functions found in utils.c */ - -int atoiwi(); -char *itoa(); -char *itoa7(); -int digits(); -char *strecpy(); -char **argparse(); -long percentages(); -char *errmsg(); -char *format_time(); -char *format_k(); +int atoiwi(char *); +char *itoa(int); +char *itoa7(int); +int digits(int); +char *strecpy(char *, char *); +char **argparse(char *, int *); +long percentages(int, int *, long *, long *, long *); +char *format_time(long); +char *format_k(int); char *format_k2(unsigned long long); int string_index(char *string, char **array);