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
This commit is contained in:
Eitan Adler 2018-05-20 02:14:27 +00:00
parent 98c299e062
commit b3c88c289c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=333909
6 changed files with 54 additions and 126 deletions

View File

@ -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 process\n\
* 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;

View File

@ -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 <christos@ee.cornell.edu>
* Steven Wallace <swallace@freebsd.org>
* Wolfram Schneider <wosch@FreeBSD.org>
@ -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 process_select *sel,
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)(int), int flags)
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)(int), int flags)
}
/* 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 &&

View File

@ -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<<f)
#endif
fd_set readfds;
static char command_chars[] = "\f qh?en#sdkriIutHmSCajzPJwo";
@ -662,9 +651,7 @@ char *argv[];
(void) signal(SIGINT, leave);
(void) signal(SIGQUIT, leave);
(void) signal(SIGTSTP, tstop);
#ifdef SIGWINCH
(void) signal(SIGWINCH, top_winch);
#endif
#ifdef SIGRELSE
sigrelse(SIGINT);
sigrelse(SIGQUIT);
@ -1258,25 +1245,22 @@ reset_display()
*/
sigret_t leave() /* exit under normal conditions -- INT handler */
{
leaveflag = 1;
}
sigret_t tstop(i) /* SIGTSTP handler */
int i;
sigret_t tstop(int i __unused) /* SIGTSTP handler */
{
tstopflag = 1;
}
#ifdef SIGWINCH
sigret_t top_winch(int i) /* SIGWINCH handler */
sigret_t top_winch(int i __unused) /* SIGWINCH handler */
{
winchflag = 1;
}
#endif
void quit(status) /* exit under duress */

View File

@ -22,9 +22,6 @@ extern int Header_lines; /* 7 */
/* Log base 2 of 1024 is 10 (2^10 == 1024) */
#define LOG1024 10
char *itoa();
char *itoa7();
/* Special atoi routine returns either a non-negative number or one of: */
#define Infinity -1
#define Invalid -2
@ -49,4 +46,7 @@ extern enum displaymodes displaymode;
extern int pcpu_stats;
char* kill_procs(char *);
char* renice_procs(char *);
#endif /* TOP_H */

View File

@ -21,10 +21,8 @@
#include <stdio.h>
#include <string.h>
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 */

View File

@ -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);