summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2001-12-12 00:13:37 +0000
committermarkm <markm@FreeBSD.org>2001-12-12 00:13:37 +0000
commitfa1f2b928010b69e6b1c78b220d8285e3145eeeb (patch)
treea352417aa710eb05cee72263260d54de2d5b2a8e /usr.bin
parenta5ca913bde3c80eb417acabe27efbd1e9046d38b (diff)
downloadFreeBSD-src-fa1f2b928010b69e6b1c78b220d8285e3145eeeb.zip
FreeBSD-src-fa1f2b928010b69e6b1c78b220d8285e3145eeeb.tar.gz
WARNS=2 fixes with NO_WERROR set, as there are some header issues
with namelists. use __FBSDID().
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/systat/Makefile1
-rw-r--r--usr.bin/systat/cmds.c79
-rw-r--r--usr.bin/systat/cmdtab.c16
-rw-r--r--usr.bin/systat/devs.c67
-rw-r--r--usr.bin/systat/devs.h2
-rw-r--r--usr.bin/systat/extern.h18
-rw-r--r--usr.bin/systat/fetch.c25
-rw-r--r--usr.bin/systat/icmp.c16
-rw-r--r--usr.bin/systat/iostat.c88
-rw-r--r--usr.bin/systat/ip.c17
-rw-r--r--usr.bin/systat/keyboard.c10
-rw-r--r--usr.bin/systat/main.c40
-rw-r--r--usr.bin/systat/mbufs.c31
-rw-r--r--usr.bin/systat/mode.c8
-rw-r--r--usr.bin/systat/mode.h2
-rw-r--r--usr.bin/systat/netcmds.c52
-rw-r--r--usr.bin/systat/netstat.c77
-rw-r--r--usr.bin/systat/pigs.c45
-rw-r--r--usr.bin/systat/swap.c26
-rw-r--r--usr.bin/systat/systat.h4
-rw-r--r--usr.bin/systat/tcp.c14
-rw-r--r--usr.bin/systat/vmstat.c203
22 files changed, 437 insertions, 404 deletions
diff --git a/usr.bin/systat/Makefile b/usr.bin/systat/Makefile
index 80f7bc3..e3fe0c9 100644
--- a/usr.bin/systat/Makefile
+++ b/usr.bin/systat/Makefile
@@ -5,6 +5,7 @@ PROG= systat
SRCS= cmds.c cmdtab.c devs.c fetch.c iostat.c keyboard.c main.c \
mbufs.c netcmds.c netstat.c pigs.c swap.c icmp.c mode.c ip.c tcp.c \
vmstat.c
+NO_WERROR=yes
DPADD= ${LIBCURSES} ${LIBM} ${LIBKVM} ${LIBDEVSTAT}
LDADD= -lcurses -lm -lkvm -ldevstat
diff --git a/usr.bin/systat/cmds.c b/usr.bin/systat/cmds.c
index e15d7e2..0bdc2dd 100644
--- a/usr.bin/systat/cmds.c
+++ b/usr.bin/systat/cmds.c
@@ -31,69 +31,71 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 4/29/95";
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)cmds.c 8.2 (Berkeley) 4/29/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-#include <stdlib.h>
-#include <unistd.h>
-#include <signal.h>
#include <ctype.h>
+#include <signal.h>
+#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+
#include "systat.h"
#include "extern.h"
void
command(cmd)
- char *cmd;
+ const char *cmd;
{
- register struct cmdtab *p;
- register char *cp;
+ struct cmdtab *p;
+ char *cp, *tmpstr, *tmpstr1;
int interval, omask;
+ tmpstr = tmpstr1 = strdup(cmd);
omask = sigblock(sigmask(SIGALRM));
- for (cp = cmd; *cp && !isspace(*cp); cp++)
+ for (cp = tmpstr1; *cp && !isspace(*cp); cp++)
;
if (*cp)
*cp++ = '\0';
- if (*cmd == '\0')
+ if (*tmpstr1 == '\0')
return;
for (; *cp && isspace(*cp); cp++)
;
- if (strcmp(cmd, "quit") == 0 || strcmp(cmd, "q") == 0)
+ if (strcmp(tmpstr1, "quit") == 0 || strcmp(tmpstr1, "q") == 0)
die(0);
- if (strcmp(cmd, "load") == 0) {
+ if (strcmp(tmpstr1, "load") == 0) {
load();
goto done;
}
- if (strcmp(cmd, "stop") == 0) {
+ if (strcmp(tmpstr1, "stop") == 0) {
alarm(0);
mvaddstr(CMDLINE, 0, "Refresh disabled.");
clrtoeol();
goto done;
}
- if (strcmp(cmd, "help") == 0) {
- int col, len;
+ if (strcmp(tmpstr1, "help") == 0) {
+ int _col, _len;
- move(CMDLINE, col = 0);
+ move(CMDLINE, _col = 0);
for (p = cmdtab; p->c_name; p++) {
- len = strlen(p->c_name);
- if (col + len > COLS)
+ _len = strlen(p->c_name);
+ if (_col + _len > COLS)
break;
- addstr(p->c_name); col += len;
- if (col + 1 < COLS)
+ addstr(p->c_name); _col += _len;
+ if (_col + 1 < COLS)
addch(' ');
}
clrtoeol();
goto done;
}
- interval = atoi(cmd);
+ interval = atoi(tmpstr1);
if (interval <= 0 &&
- (strcmp(cmd, "start") == 0 || strcmp(cmd, "interval") == 0)) {
+ (strcmp(tmpstr1, "start") == 0 || strcmp(tmpstr1, "interval") == 0)) {
interval = *cp ? atoi(cp) : naptime;
if (interval <= 0) {
error("%d: bad interval.", interval);
@@ -107,9 +109,9 @@ command(cmd)
status();
goto done;
}
- p = lookup(cmd);
+ p = lookup(tmpstr1);
if (p == (struct cmdtab *)-1) {
- error("%s: Ambiguous command.", cmd);
+ error("%s: Ambiguous command.", tmpstr1);
goto done;
}
if (p) {
@@ -139,32 +141,33 @@ command(cmd)
status();
goto done;
}
- if (curcmd->c_cmd == 0 || !(*curcmd->c_cmd)(cmd, cp))
- error("%s: Unknown command.", cmd);
+ if (curcmd->c_cmd == 0 || !(*curcmd->c_cmd)(tmpstr1, cp))
+ error("%s: Unknown command.", tmpstr1);
done:
sigsetmask(omask);
+ free(tmpstr);
}
struct cmdtab *
lookup(name)
- register char *name;
+ const char *name;
{
- register char *p, *q;
- register struct cmdtab *c, *found;
- register int nmatches, longest;
+ const char *p, *q;
+ struct cmdtab *ct, *found;
+ int nmatches, longest;
longest = 0;
nmatches = 0;
found = (struct cmdtab *) 0;
- for (c = cmdtab; p = c->c_name; c++) {
+ for (ct = cmdtab; (p = ct->c_name); ct++) {
for (q = name; *q == *p++; q++)
if (*q == 0) /* exact match? */
- return (c);
+ return (ct);
if (!*q) { /* the name was a prefix */
if (q - name > longest) {
longest = q - name;
nmatches = 1;
- found = c;
+ found = ct;
} else if (q - name == longest)
nmatches++;
}
@@ -184,7 +187,7 @@ status()
int
prefix(s1, s2)
- register char *s1, *s2;
+ const char *s1, *s2;
{
while (*s1 == *s2) {
diff --git a/usr.bin/systat/cmdtab.c b/usr.bin/systat/cmdtab.c
index 466a647..63685e0 100644
--- a/usr.bin/systat/cmdtab.c
+++ b/usr.bin/systat/cmdtab.c
@@ -31,13 +31,13 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-/*
-static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
-*/
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
+#endif
#include "systat.h"
#include "extern.h"
@@ -71,6 +71,6 @@ struct cmdtab cmdtab[] = {
{ "tcp", showtcp, fetchtcp, labeltcp,
inittcp, opentcp, closetcp, cmdmode,
resettcp, 0 },
- { 0 }
+ { NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0 }
};
struct cmdtab *curcmd = &cmdtab[0];
diff --git a/usr.bin/systat/devs.c b/usr.bin/systat/devs.c
index 1f2ee87..f472d8f 100644
--- a/usr.bin/systat/devs.c
+++ b/usr.bin/systat/devs.c
@@ -24,12 +24,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-/*
- * Some code and ideas taken from the old disks.c.
- * static char sccsid[] = "@(#)disks.c 8.1 (Berkeley) 6/6/93";
*/
/*-
* Copyright (c) 1980, 1992, 1993
@@ -64,15 +58,24 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)disks.c 8.1 (Berkeley) 6/6/93";
+#endif
+
#include <sys/types.h>
#include <sys/devicestat.h>
#include <sys/dkstat.h>
-#include <string.h>
-#include <devstat.h>
-#include <stdlib.h>
#include <ctype.h>
+#include <devstat.h>
#include <err.h>
+#include <stdlib.h>
+#include <string.h>
+
#include "systat.h"
#include "extern.h"
#include "devs.h"
@@ -94,14 +97,14 @@ int num_matches = 0;
char **specified_devices;
int num_devices_specified = 0;
-static int dsmatchselect(char *args, devstat_select_mode select_mode,
+static int dsmatchselect(const char *args, devstat_select_mode select_mode,
int maxshowdevs, struct statinfo *s1);
-static int dsselect(char *args, devstat_select_mode select_mode,
+static int dsselect(const char *args, devstat_select_mode select_mode,
int maxshowdevs, struct statinfo *s1);
int
-dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2,
- struct statinfo *s3)
+dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2 __unused,
+ struct statinfo *s3 __unused)
{
/*
@@ -141,7 +144,7 @@ dsinit(int maxshowdevs, struct statinfo *s1, struct statinfo *s2,
}
int
-dscmd(char *cmd, char *args, int maxshowdevs, struct statinfo *s1)
+dscmd(const char *cmd, const char *args, int maxshowdevs, struct statinfo *s1)
{
int retval;
@@ -183,25 +186,27 @@ dscmd(char *cmd, char *args, int maxshowdevs, struct statinfo *s1)
}
static int
-dsmatchselect(char *args, devstat_select_mode select_mode, int maxshowdevs,
+dsmatchselect(const char *args, devstat_select_mode select_mode, int maxshowdevs,
struct statinfo *s1)
{
- char **tempstr;
+ char **tempstr, *tmpstr, *tmpstr1;
char *tstr[100];
int num_args = 0;
- register int i;
+ int i;
int retval = 0;
/*
* Break the (pipe delimited) input string out into separate
* strings.
*/
+ tmpstr = tmpstr1 = strdup(args);
for (tempstr = tstr, num_args = 0;
- (*tempstr = strsep(&args, "|")) != NULL && (num_args < 100);
+ (*tempstr = strsep(&tmpstr1, "|")) != NULL && (num_args < 100);
num_args++)
if (**tempstr != '\0')
if (++tempstr >= &tstr[100])
break;
+ free(tmpstr);
if (num_args > 99) {
warnx("dsmatchselect: too many match arguments");
@@ -241,13 +246,12 @@ dsmatchselect(char *args, devstat_select_mode select_mode, int maxshowdevs,
}
static int
-dsselect(char *args, devstat_select_mode select_mode, int maxshowdevs,
+dsselect(const char *args, devstat_select_mode select_mode, int maxshowdevs,
struct statinfo *s1)
{
- register char *cp;
- register int i;
+ char *cp, *tmpstr, *tmpstr1, *buffer;
+ int i;
int retval = 0;
- char *index();
/*
* If we've gone through this code before, free previously
@@ -264,13 +268,14 @@ dsselect(char *args, devstat_select_mode select_mode, int maxshowdevs,
/* do an initial malloc */
specified_devices = (char **)malloc(sizeof(char *));
- cp = index(args, '\n');
+ tmpstr = tmpstr1 = strdup(args);
+ cp = index(tmpstr1, '\n');
if (cp)
*cp = '\0';
for (;;) {
- for (cp = args; *cp && isspace(*cp); cp++)
+ for (cp = tmpstr1; *cp && isspace(*cp); cp++)
;
- args = cp;
+ tmpstr1 = cp;
for (; *cp && !isspace(*cp); cp++)
;
if (*cp)
@@ -278,11 +283,9 @@ dsselect(char *args, devstat_select_mode select_mode, int maxshowdevs,
if (cp - args == 0)
break;
for (i = 0; i < num_devices; i++) {
- char tmpstr[80];
-
- sprintf(tmpstr, "%s%d", dev_select[i].device_name,
+ asprintf(&buffer, "%s%d", dev_select[i].device_name,
dev_select[i].unit_number);
- if (strcmp(args, tmpstr) == 0) {
+ if (strcmp(buffer, tmpstr1) == 0) {
num_devices_specified++;
@@ -291,15 +294,19 @@ dsselect(char *args, devstat_select_mode select_mode, int maxshowdevs,
sizeof(char *) *
num_devices_specified);
specified_devices[num_devices_specified -1]=
- strdup(args);
+ strdup(tmpstr1);
+ free(buffer);
break;
}
+ else
+ free(buffer);
}
if (i >= num_devices)
error("%s: unknown drive", args);
args = cp;
}
+ free(tmpstr);
if (num_devices_specified > 0) {
last_type = DS_MATCHTYPE_SPEC;
diff --git a/usr.bin/systat/devs.h b/usr.bin/systat/devs.h
index ec65654..9217008 100644
--- a/usr.bin/systat/devs.h
+++ b/usr.bin/systat/devs.h
@@ -27,4 +27,4 @@
*/
int dsinit(int, struct statinfo *, struct statinfo *, struct statinfo *);
-int dscmd(char *, char *, int, struct statinfo *);
+int dscmd(const char *, const char *, int, struct statinfo *);
diff --git a/usr.bin/systat/extern.h b/usr.bin/systat/extern.h
index 81b660a..d47d843 100644
--- a/usr.bin/systat/extern.h
+++ b/usr.bin/systat/extern.h
@@ -81,11 +81,11 @@ void closenetstat __P((WINDOW *));
void closepigs __P((WINDOW *));
void closeswap __P((WINDOW *));
void closetcp __P((WINDOW *));
-int cmdiostat __P((char *, char *));
-int cmdkre __P((char *, char *));
-int cmdnetstat __P((char *, char *));
-struct cmdtab *lookup __P((char *));
-void command __P((char *));
+int cmdiostat __P((const char *, const char *));
+int cmdkre __P((const char *, const char *));
+int cmdnetstat __P((const char *, const char *));
+struct cmdtab *lookup __P((const char *));
+void command __P((const char *));
void die __P((int));
void display __P((int));
int dkinit __P((void));
@@ -100,7 +100,7 @@ void fetchnetstat __P((void));
void fetchpigs __P((void));
void fetchswap __P((void));
void fetchtcp __P((void));
-void getsysctl __P((char *, void *, size_t));
+void getsysctl __P((const char *, void *, size_t));
int initicmp __P((void));
int initip __P((void));
int initiostat __P((void));
@@ -123,7 +123,7 @@ void labels __P((void));
void labelswap __P((void));
void labeltcp __P((void));
void load __P((void));
-int netcmd __P((char *, char *));
+int netcmd __P((const char *, const char *));
void nlisterr __P((struct nlist []));
WINDOW *openicmp __P((void));
WINDOW *openip __P((void));
@@ -134,7 +134,7 @@ WINDOW *opennetstat __P((void));
WINDOW *openpigs __P((void));
WINDOW *openswap __P((void));
WINDOW *opentcp __P((void));
-int prefix __P((char *, char *));
+int prefix __P((const char *, const char *));
void reseticmp __P((void));
void resetip __P((void));
void resettcp __P((void));
@@ -149,4 +149,4 @@ void showswap __P((void));
void showtcp __P((void));
void status __P((void));
void suspend __P((int));
-char *sysctl_dynread __P((char *, size_t *));
+char *sysctl_dynread __P((const char *, size_t *));
diff --git a/usr.bin/systat/fetch.c b/usr.bin/systat/fetch.c
index e583911..1a22bbe 100644
--- a/usr.bin/systat/fetch.c
+++ b/usr.bin/systat/fetch.c
@@ -29,21 +29,23 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static char sccsid[] = "@(#)fetch.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)fetch.c 8.1 (Berkeley) 6/6/93";
+#endif
#include <sys/types.h>
#include <sys/sysctl.h>
-#include <errno.h>
#include <err.h>
-#include <string.h>
+#include <errno.h>
#include <stdlib.h>
+#include <string.h>
#include "systat.h"
#include "extern.h"
@@ -55,7 +57,7 @@ kvm_ckread(a, b, l)
{
if (kvm_read(kd, (u_long)a, b, l) != l) {
if (verbose)
- error("error reading kmem at %x", a);
+ error("error reading kmem at %p", a);
return (0);
}
else
@@ -63,13 +65,12 @@ kvm_ckread(a, b, l)
}
void getsysctl(name, ptr, len)
- char *name;
+ const char *name;
void *ptr;
size_t len;
{
- int err;
size_t nlen = len;
- if ((err = sysctlbyname(name, ptr, &nlen, NULL, 0)) != 0) {
+ if (sysctlbyname(name, ptr, &nlen, NULL, 0) != 0) {
error("sysctl(%s...) failed: %s", name,
strerror(errno));
}
@@ -103,7 +104,7 @@ void getsysctl(name, ptr, len)
char *
sysctl_dynread(n, szp)
- char *n;
+ const char *n;
size_t *szp;
{
char *rv = NULL;
diff --git a/usr.bin/systat/icmp.c b/usr.bin/systat/icmp.c
index 3b5b829..487a3ba 100644
--- a/usr.bin/systat/icmp.c
+++ b/usr.bin/systat/icmp.c
@@ -31,15 +31,17 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-/* From:
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
static char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93";
-static const char rcsid[] =
- "Id: mbufs.c,v 1.5 1997/02/24 20:59:03 wollman Exp";
+#endif
+
+/* From:
+ "Id: mbufs.c,v 1.5 1997/02/24 20:59:03 wollman Exp"
*/
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include <sys/param.h>
#include <sys/types.h>
diff --git a/usr.bin/systat/iostat.c b/usr.bin/systat/iostat.c
index 0e3c1d6..b9acec1 100644
--- a/usr.bin/systat/iostat.c
+++ b/usr.bin/systat/iostat.c
@@ -24,8 +24,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
* Copyright (c) 1980, 1992, 1993
@@ -60,20 +58,25 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char sccsid[] = "@(#)iostat.c 8.1 (Berkeley) 6/6/93";
-#endif not lint
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)iostat.c 8.1 (Berkeley) 6/6/93";
+#endif
#include <sys/param.h>
#include <sys/dkstat.h>
#include <sys/sysctl.h>
-#include <string.h>
-#include <stdlib.h>
-#include <nlist.h>
-#include <paths.h>
#include <devstat.h>
#include <err.h>
+#include <nlist.h>
+#include <paths.h>
+#include <stdlib.h>
+#include <string.h>
+
#include "systat.h"
#include "extern.h"
#include "devs.h"
@@ -134,11 +137,10 @@ fetchiostat()
{
struct devinfo *tmp_dinfo;
size_t len;
- int err;
len = sizeof(cur.cp_time);
- err = sysctlbyname("kern.cp_time", &cur.cp_time, &len, NULL, 0);
- if (err || len != sizeof(cur.cp_time)) {
+ if (sysctlbyname("kern.cp_time", &cur.cp_time, &len, NULL, 0)
+ || len != sizeof(cur.cp_time)) {
perror("kern.cp_time");
exit (1);
}
@@ -196,7 +198,7 @@ static int
numlabels(row)
int row;
{
- int i, col, regions, ndrives;
+ int i, _col, regions, ndrives;
char tmpstr[10];
#define COLWIDTH 17
@@ -215,21 +217,21 @@ numlabels(row)
*/
if (linesperregion < 3)
linesperregion = 3;
- col = INSET;
+ _col = INSET;
for (i = 0; i < num_devices; i++)
if (dev_select[i].selected) {
- if (col + COLWIDTH >= wnd->_maxx - INSET) {
- col = INSET, row += linesperregion + 1;
+ if (_col + COLWIDTH >= wnd->_maxx - INSET) {
+ _col = INSET, row += linesperregion + 1;
if (row > wnd->_maxy - (linesperregion + 1))
break;
}
sprintf(tmpstr, "%s%d", dev_select[i].device_name,
dev_select[i].unit_number);
- mvwaddstr(wnd, row, col + 4, tmpstr);
- mvwaddstr(wnd, row + 1, col, " KB/t tps MB/s ");
- col += COLWIDTH;
+ mvwaddstr(wnd, row, _col + 4, tmpstr);
+ mvwaddstr(wnd, row + 1, _col, " KB/t tps MB/s ");
+ _col += COLWIDTH;
}
- if (col)
+ if (_col)
row += linesperregion + 1;
return (row);
}
@@ -263,8 +265,8 @@ barlabels(row)
void
showiostat()
{
- register long t;
- register int i, row, col;
+ long t;
+ int i, row, _col;
#define X(fld) t = cur.fld[i]; cur.fld[i] -= last.fld[i]; last.fld[i] = t
etime = 0;
@@ -288,15 +290,15 @@ showiostat()
}
return;
}
- col = INSET;
+ _col = INSET;
wmove(wnd, row + linesperregion, 0);
wdeleteln(wnd);
wmove(wnd, row + 3, 0);
winsertln(wnd);
for (i = 0; i < num_devices; i++)
if (dev_select[i].selected) {
- if (col + COLWIDTH >= wnd->_maxx - INSET) {
- col = INSET, row += linesperregion + 1;
+ if (_col + COLWIDTH >= wnd->_maxx - INSET) {
+ _col = INSET, row += linesperregion + 1;
if (row > wnd->_maxy - (linesperregion + 1))
break;
wmove(wnd, row + linesperregion, 0);
@@ -304,14 +306,14 @@ showiostat()
wmove(wnd, row + 3, 0);
winsertln(wnd);
}
- (void) devstats(row + 3, col, i);
- col += COLWIDTH;
+ (void) devstats(row + 3, _col, i);
+ _col += COLWIDTH;
}
}
static int
-devstats(row, col, dn)
- int row, col, dn;
+devstats(row, _col, dn)
+ int row, _col, dn;
{
long double transfers_per_second;
long double kb_per_transfer, mb_per_second;
@@ -330,17 +332,17 @@ devstats(row, col, dn)
errx(1, "%s", devstat_errbuf);
if (numbers) {
- mvwprintw(wnd, row, col, " %5.2Lf %3.0Lf %5.2Lf ",
+ mvwprintw(wnd, row, _col, " %5.2Lf %3.0Lf %5.2Lf ",
kb_per_transfer, transfers_per_second,
mb_per_second);
return(row);
}
- wmove(wnd, row++, col);
+ wmove(wnd, row++, _col);
histogram(mb_per_second, 50, .5);
- wmove(wnd, row++, col);
+ wmove(wnd, row++, _col);
histogram(transfers_per_second, 50, .5);
if (kbpt) {
- wmove(wnd, row++, col);
+ wmove(wnd, row++, _col);
histogram(kb_per_transfer, 50, .5);
}
@@ -352,17 +354,17 @@ static void
stat1(row, o)
int row, o;
{
- register int i;
- double time;
+ int i;
+ double dtime;
- time = 0;
+ dtime = 0.0;
for (i = 0; i < CPUSTATES; i++)
- time += cur.cp_time[i];
- if (time == 0.0)
- time = 1.0;
+ dtime += cur.cp_time[i];
+ if (dtime == 0.0)
+ dtime = 1.0;
wmove(wnd, row, INSET);
#define CPUSCALE 0.5
- histogram(100.0 * cur.cp_time[o] / time, 50, CPUSCALE);
+ histogram(100.0 * cur.cp_time[o] / dtime, 50, CPUSCALE);
}
static void
@@ -372,8 +374,8 @@ histogram(val, colwidth, scale)
double scale;
{
char buf[10];
- register int k;
- register int v = (int)(val * scale) + 0.5;
+ int k;
+ int v = (int)(val * scale) + 0.5;
k = MIN(v, colwidth);
if (v > colwidth) {
@@ -391,7 +393,7 @@ histogram(val, colwidth, scale)
int
cmdiostat(cmd, args)
- char *cmd, *args;
+ const char *cmd, *args;
{
if (prefix(cmd, "kbpt"))
diff --git a/usr.bin/systat/ip.c b/usr.bin/systat/ip.c
index 6616b2a..1462ab1 100644
--- a/usr.bin/systat/ip.c
+++ b/usr.bin/systat/ip.c
@@ -31,15 +31,17 @@
* SUCH DAMAGE.
*/
-#ifndef lint
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93";
+#endif
+
/* From:
-static char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93";
-static const char rcsid[] =
- "Id: mbufs.c,v 1.5 1997/02/24 20:59:03 wollman Exp";
+ "Id: mbufs.c,v 1.5 1997/02/24 20:59:03 wollman Exp"
*/
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include <sys/param.h>
#include <sys/types.h>
@@ -56,6 +58,7 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <paths.h>
+
#include "systat.h"
#include "extern.h"
#include "mode.h"
diff --git a/usr.bin/systat/keyboard.c b/usr.bin/systat/keyboard.c
index ae4feb5..b563266 100644
--- a/usr.bin/systat/keyboard.c
+++ b/usr.bin/systat/keyboard.c
@@ -31,9 +31,13 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char sccsid[] = "@(#)keyboard.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)keyboard.c 8.1 (Berkeley) 6/6/93";
+#endif
#include <ctype.h>
#include <signal.h>
diff --git a/usr.bin/systat/main.c b/usr.bin/systat/main.c
index 97e5885..81b846b 100644
--- a/usr.bin/systat/main.c
+++ b/usr.bin/systat/main.c
@@ -31,19 +31,19 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
+#endif
+
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1980, 1992, 1993\n\
The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
@@ -58,6 +58,7 @@ static const char rcsid[] =
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+
#include "systat.h"
#include "extern.h"
@@ -87,7 +88,6 @@ main(argc, argv)
{
char errbuf[_POSIX2_LINE_MAX], dummy;
size_t size;
- int err;
(void) setlocale(LC_TIME, "");
@@ -159,8 +159,8 @@ main(argc, argv)
}
gethostname(hostname, sizeof (hostname));
size = sizeof(clkinfo);
- err = sysctlbyname("kern.clockrate", &clkinfo, &size, NULL, 0);
- if (err != 0 || size != sizeof(clkinfo)) {
+ if (sysctlbyname("kern.clockrate", &clkinfo, &size, NULL, 0)
+ || size != sizeof(clkinfo)) {
error("kern.clockrate");
die(0);
}
@@ -198,9 +198,9 @@ labels()
void
display(signo)
- int signo;
+ int signo __unused;
{
- register int i, j;
+ int i, j;
/* Get the load average over the last minute. */
(void) getloadavg(avenrun, sizeof(avenrun) / sizeof(avenrun[0]));
@@ -244,7 +244,7 @@ load()
void
die(signo)
- int signo;
+ int signo __unused;
{
move(CMDLINE, 0);
clrtoeol();
@@ -295,8 +295,8 @@ error(fmt, va_alist)
}
void
-nlisterr(namelist)
- struct nlist namelist[];
+nlisterr(n_list)
+ struct nlist n_list[];
{
int i, n;
@@ -304,9 +304,9 @@ nlisterr(namelist)
clear();
mvprintw(2, 10, "systat: nlist: can't find following symbols:");
for (i = 0;
- namelist[i].n_name != NULL && *namelist[i].n_name != '\0'; i++)
- if (namelist[i].n_value == 0)
- mvprintw(2 + ++n, 10, "%s", namelist[i].n_name);
+ n_list[i].n_name != NULL && *n_list[i].n_name != '\0'; i++)
+ if (n_list[i].n_value == 0)
+ mvprintw(2 + ++n, 10, "%s", n_list[i].n_name);
move(CMDLINE, 0);
clrtoeol();
refresh();
diff --git a/usr.bin/systat/mbufs.c b/usr.bin/systat/mbufs.c
index 5dee078..e1b665b2 100644
--- a/usr.bin/systat/mbufs.c
+++ b/usr.bin/systat/mbufs.c
@@ -31,11 +31,13 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93";
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93";
+#endif
#include <sys/param.h>
#include <sys/types.h>
@@ -46,6 +48,7 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <paths.h>
+
#include "systat.h"
#include "extern.h"
@@ -58,7 +61,7 @@ static short nmbtypes;
static struct mtnames {
short mt_type;
- char *mt_name;
+ const char *mt_name;
} mtnames[] = {
{ MT_DATA, "data"},
{ MT_HEADER, "headers"},
@@ -97,10 +100,10 @@ labelmbufs()
void
showmbufs()
{
- int i, j, max, index;
+ int i, j, max, idx;
u_long totfree;
char buf[10];
- char *mtname;
+ const char *mtname;
totfree = mbpstat[GENLST]->mb_mbfree;
for (i = 1; i < nmbtypes; i++)
@@ -117,7 +120,7 @@ showmbufs()
* Print totals for different mbuf types.
*/
for (j = 0; j < wnd->_maxy; j++) {
- max = 0, index = -1;
+ max = 0, idx = -1;
for (i = 0; i < wnd->_maxy; i++) {
if (i == MT_NOTMBUF)
continue;
@@ -125,18 +128,18 @@ showmbufs()
break;
if (m_mbtypes[i] > max) {
max = m_mbtypes[i];
- index = i;
+ idx = i;
}
}
if (max == 0)
break;
mtname = NULL;
- for (i = 0; i < NNAMES; i++)
- if (mtnames[i].mt_type == index)
+ for (i = 0; i < (int)NNAMES; i++)
+ if (mtnames[i].mt_type == idx)
mtname = mtnames[i].mt_name;
if (mtname == NULL)
- mvwprintw(wnd, 1+j, 0, "%10d", index);
+ mvwprintw(wnd, 1+j, 0, "%10d", idx);
else
mvwprintw(wnd, 1+j, 0, "%-10.10s", mtname);
wmove(wnd, 1 + j, 10);
@@ -150,7 +153,7 @@ showmbufs()
while (max--)
waddch(wnd, 'X');
wclrtoeol(wnd);
- m_mbtypes[index] = 0;
+ m_mbtypes[idx] = 0;
}
/*
diff --git a/usr.bin/systat/mode.c b/usr.bin/systat/mode.c
index 3eb85c0..5f64e3e 100644
--- a/usr.bin/systat/mode.c
+++ b/usr.bin/systat/mode.c
@@ -25,8 +25,6 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
/*
@@ -58,6 +56,10 @@
* mode in the command line.
*/
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
#include <sys/types.h>
#include "systat.h"
@@ -69,7 +71,7 @@ enum mode currentmode = display_RATE;
static const char *const modes[] = { "rate", "delta", "since", "absolute" };
int
-cmdmode(char *cmd, char *args)
+cmdmode(const char *cmd, const char *args)
{
if (prefix(cmd, "mode")) {
if (args[0] == '\0') {
diff --git a/usr.bin/systat/mode.h b/usr.bin/systat/mode.h
index caa6bae..9fc0fea 100644
--- a/usr.bin/systat/mode.h
+++ b/usr.bin/systat/mode.h
@@ -38,7 +38,7 @@
enum mode { display_RATE, display_DELTA, display_SINCE, display_ABS };
-extern int cmdmode(char *cmd, char *args);
+extern int cmdmode(const char *cmd, const char *args);
extern enum mode currentmode;
#endif /* MODE_H */
diff --git a/usr.bin/systat/netcmds.c b/usr.bin/systat/netcmds.c
index 80a3213..e0df715 100644
--- a/usr.bin/systat/netcmds.c
+++ b/usr.bin/systat/netcmds.c
@@ -31,13 +31,13 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-/*
-static char sccsid[] = "@(#)netcmds.c 8.1 (Berkeley) 6/6/93";
-*/
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)netcmds.c 8.1 (Berkeley) 6/6/93";
+#endif
/*
* Common network command support routines.
@@ -55,10 +55,11 @@ static const char rcsid[] =
#include <netinet/in_pcb.h>
#include <arpa/inet.h>
+#include <ctype.h>
#include <netdb.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
+
#include "systat.h"
#include "extern.h"
@@ -71,8 +72,8 @@ static struct hitem {
int nports, nhosts, protos;
-static void changeitems __P((char *, int));
-static int selectproto __P((char *));
+static void changeitems __P((const char *, int));
+static int selectproto __P((const char *));
static void showprotos __P((void));
static int selectport __P((long, int));
static void showports __P((void));
@@ -81,7 +82,7 @@ static void showhosts __P((void));
int
netcmd(cmd, args)
- char *cmd, *args;
+ const char *cmd, *args;
{
if (prefix(cmd, "proto")) {
@@ -128,50 +129,51 @@ netcmd(cmd, args)
static void
changeitems(args, onoff)
- char *args;
+ const char *args;
int onoff;
{
- register char *cp;
+ char *cp, *tmpstr, *tmpstr1;
struct servent *sp;
struct hostent *hp;
struct in_addr in;
- char *index();
- cp = index(args, '\n');
+ tmpstr = tmpstr1 = strdup(args);
+ cp = index(tmpstr1, '\n');
if (cp)
*cp = '\0';
- for (;;args = cp) {
- for (cp = args; *cp && isspace(*cp); cp++)
+ for (;;tmpstr1 = cp) {
+ for (cp = tmpstr1; *cp && isspace(*cp); cp++)
;
- args = cp;
+ tmpstr1 = cp;
for (; *cp && !isspace(*cp); cp++)
;
if (*cp)
*cp++ = '\0';
- if (cp - args == 0)
+ if (cp - tmpstr1 == 0)
break;
- sp = getservbyname(args,
+ sp = getservbyname(tmpstr1,
protos == TCP ? "tcp" : protos == UDP ? "udp" : 0);
if (sp) {
selectport(sp->s_port, onoff);
continue;
}
- hp = gethostbyname(args);
+ hp = gethostbyname(tmpstr1);
if (hp == 0) {
- in.s_addr = inet_addr(args);
- if (in.s_addr == -1) {
- error("%s: unknown host or port", args);
+ in.s_addr = inet_addr(tmpstr1);
+ if ((int)in.s_addr == -1) {
+ error("%s: unknown host or port", tmpstr1);
continue;
}
} else
in = *(struct in_addr *)hp->h_addr;
selecthost(&in, onoff);
}
+ free(tmpstr);
}
static int
selectproto(proto)
- char *proto;
+ const char *proto;
{
if (proto == 0 || streq(proto, "all"))
diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c
index 723f853..3d01502 100644
--- a/usr.bin/systat/netstat.c
+++ b/usr.bin/systat/netstat.c
@@ -31,13 +31,13 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-/*
-static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93";
-*/
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93";
+#endif
/*
* netstat
@@ -70,20 +70,21 @@ static const char rcsid[] =
#include <netinet/udp_var.h>
#include <netdb.h>
-#include <stdlib.h>
-#include <string.h>
#include <nlist.h>
#include <paths.h>
+#include <stdlib.h>
+#include <string.h>
+
#include "systat.h"
#include "extern.h"
-static struct netinfo *enter __P((struct inpcb *, int, char *));
-static void enter_kvm __P((struct inpcb *, struct socket *, int, char *));
-static void enter_sysctl __P((struct inpcb *, struct xsocket *, int, char *));
+static struct netinfo *enter __P((struct inpcb *, int, const char *));
+static void enter_kvm __P((struct inpcb *, struct socket *, int, const char *));
+static void enter_sysctl __P((struct inpcb *, struct xsocket *, int, const char *));
static void fetchnetstat_kvm __P((void));
static void fetchnetstat_sysctl __P((void));
static char *inetname __P((struct in_addr));
-static void inetprint __P((struct in_addr *, int, char *));
+static void inetprint __P((struct in_addr *, int, const char *));
#define streq(a,b) (strcmp(a,b)==0)
#define YMAX(w) ((w)->_maxy-1)
@@ -104,7 +105,7 @@ struct netinfo {
#define NIF_LACHG 0x1 /* local address changed */
#define NIF_FACHG 0x2 /* foreign address changed */
short ni_state; /* tcp state */
- char *ni_proto; /* protocol */
+ const char *ni_proto; /* protocol */
struct in_addr ni_laddr; /* local address */
long ni_lport; /* local port */
struct in_addr ni_faddr; /* foreign address */
@@ -118,13 +119,12 @@ TAILQ_HEAD(netinfohead, netinfo) netcb = TAILQ_HEAD_INITIALIZER(netcb);
static int aflag = 0;
static int nflag = 0;
static int lastrow = 1;
-static char *inetname();
void
closenetstat(w)
WINDOW *w;
{
- register struct netinfo *p;
+ struct netinfo *p;
endhostent();
endnetent();
@@ -140,7 +140,7 @@ closenetstat(w)
}
}
-static char *miblist[] = {
+static const char *miblist[] = {
"net.inet.tcp.pcblist",
"net.inet.udp.pcblist"
};
@@ -172,8 +172,8 @@ fetchnetstat()
static void
fetchnetstat_kvm()
{
- register struct inpcb *next;
- register struct netinfo *p;
+ struct inpcb *next;
+ struct netinfo *p;
struct inpcbhead head;
struct inpcb inpcb;
struct socket sockb;
@@ -225,7 +225,7 @@ again:
static void
fetchnetstat_sysctl()
{
- register struct netinfo *p;
+ struct netinfo *p;
int idx;
struct xinpgen *inpg;
char *cur, *end;
@@ -301,12 +301,12 @@ fetchnetstat_sysctl()
static void
enter_kvm(inp, so, state, proto)
- register struct inpcb *inp;
- register struct socket *so;
+ struct inpcb *inp;
+ struct socket *so;
int state;
- char *proto;
+ const char *proto;
{
- register struct netinfo *p;
+ struct netinfo *p;
if ((p = enter(inp, state, proto)) != NULL) {
p->ni_rcvcc = so->so_rcv.sb_cc;
@@ -316,12 +316,12 @@ enter_kvm(inp, so, state, proto)
static void
enter_sysctl(inp, so, state, proto)
- register struct inpcb *inp;
- register struct xsocket *so;
+ struct inpcb *inp;
+ struct xsocket *so;
int state;
- char *proto;
+ const char *proto;
{
- register struct netinfo *p;
+ struct netinfo *p;
if ((p = enter(inp, state, proto)) != NULL) {
p->ni_rcvcc = so->so_rcv.sb_cc;
@@ -332,11 +332,11 @@ enter_sysctl(inp, so, state, proto)
static struct netinfo *
enter(inp, state, proto)
- register struct inpcb *inp;
+ struct inpcb *inp;
int state;
- char *proto;
+ const char *proto;
{
- register struct netinfo *p;
+ struct netinfo *p;
/*
* Only take exact matches, any sockets with
@@ -366,7 +366,7 @@ enter(inp, state, proto)
p->ni_lport = inp->inp_lport;
p->ni_faddr = inp->inp_faddr;
p->ni_fport = inp->inp_fport;
- p->ni_proto = proto;
+ p->ni_proto = strdup(proto);
p->ni_flags = NIF_LACHG|NIF_FACHG;
}
p->ni_state = state;
@@ -400,7 +400,7 @@ labelnetstat()
void
shownetstat()
{
- register struct netinfo *p, *q;
+ struct netinfo *p, *q;
/*
* First, delete any connections that have gone
@@ -452,13 +452,14 @@ shownetstat()
mvwaddstr(wnd, p->ni_line, PROTO, p->ni_proto);
mvwprintw(wnd, p->ni_line, RCVCC, "%6d", p->ni_rcvcc);
mvwprintw(wnd, p->ni_line, SNDCC, "%6d", p->ni_sndcc);
- if (streq(p->ni_proto, "tcp"))
+ if (streq(p->ni_proto, "tcp")) {
if (p->ni_state < 0 || p->ni_state >= TCP_NSTATES)
mvwprintw(wnd, p->ni_line, STATE, "%d",
p->ni_state);
else
mvwaddstr(wnd, p->ni_line, STATE,
tcpstates[p->ni_state]);
+ }
wclrtoeol(wnd);
}
if (lastrow < YMAX(wnd)) {
@@ -473,12 +474,12 @@ shownetstat()
*/
static void
inetprint(in, port, proto)
- register struct in_addr *in;
+ struct in_addr *in;
int port;
- char *proto;
+ const char *proto;
{
struct servent *sp = 0;
- char line[80], *cp, *index();
+ char line[80], *cp;
snprintf(line, sizeof(line), "%.*s.", 16, inetname(*in));
cp = index(line, '\0');
@@ -542,7 +543,7 @@ inetname(in)
int
cmdnetstat(cmd, args)
- char *cmd, *args;
+ const char *cmd, *args;
{
if (prefix(cmd, "all")) {
aflag = !aflag;
diff --git a/usr.bin/systat/pigs.c b/usr.bin/systat/pigs.c
index 03a9e94..491d3d3 100644
--- a/usr.bin/systat/pigs.c
+++ b/usr.bin/systat/pigs.c
@@ -29,13 +29,15 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static char sccsid[] = "@(#)pigs.c 8.2 (Berkeley) 9/23/93";
-#endif /* not lint */
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)pigs.c 8.2 (Berkeley) 9/23/93";
+#endif
/*
* Pigs display from Bill Reeves at Lucasfilm
@@ -92,7 +94,8 @@ showpigs()
register int i, j, y, k;
float total;
int factor;
- char *uname, *pname, pidname[30];
+ const char *uname, *pname;
+ char pidname[30];
if (pt == NULL)
return;
@@ -170,11 +173,11 @@ initpigs()
void
fetchpigs()
{
- register int i;
- register float time;
- register float *pctp;
+ int i;
+ float ftime;
+ float *pctp;
struct kinfo_proc *kpp;
- long ctime[CPUSTATES];
+ long c_time[CPUSTATES];
double t;
static int lastnproc = 0;
size_t len;
@@ -201,31 +204,31 @@ fetchpigs()
for (i = 0; i < nproc; i++) {
pt[i].pt_kp = &kpp[i];
pctp = &pt[i].pt_pctcpu;
- time = kpp[i].ki_swtime;
- if (time == 0 || (kpp[i].ki_sflag & PS_INMEM) == 0)
+ ftime = kpp[i].ki_swtime;
+ if (ftime == 0 || (kpp[i].ki_sflag & PS_INMEM) == 0)
*pctp = 0;
else
*pctp = ((double) kpp[i].ki_pctcpu /
- fscale) / (1.0 - exp(time * lccpu));
+ fscale) / (1.0 - exp(ftime * lccpu));
}
/*
* and for the imaginary "idle" process
*/
- len = sizeof(ctime);
- err = sysctlbyname("kern.cp_time", &ctime, &len, NULL, 0);
- if (err || len != sizeof(ctime)) {
+ len = sizeof(c_time);
+ err = sysctlbyname("kern.cp_time", &c_time, &len, NULL, 0);
+ if (err || len != sizeof(c_time)) {
perror("kern.cp_time");
return;
}
t = 0;
for (i = 0; i < CPUSTATES; i++)
- t += ctime[i] - stime[i];
+ t += c_time[i] - stime[i];
if (t == 0.0)
t = 1.0;
pt[nproc].pt_kp = NULL;
- pt[nproc].pt_pctcpu = (ctime[CP_IDLE] - stime[CP_IDLE]) / t;
+ pt[nproc].pt_pctcpu = (c_time[CP_IDLE] - stime[CP_IDLE]) / t;
for (i = 0; i < CPUSTATES; i++)
- stime[i] = ctime[i];
+ stime[i] = c_time[i];
}
void
@@ -241,6 +244,6 @@ int
compar(a, b)
const void *a, *b;
{
- return (((struct p_times *) a)->pt_pctcpu >
- ((struct p_times *) b)->pt_pctcpu)? -1: 1;
+ return (((const struct p_times *) a)->pt_pctcpu >
+ ((const struct p_times *) b)->pt_pctcpu)? -1: 1;
}
diff --git a/usr.bin/systat/swap.c b/usr.bin/systat/swap.c
index 18aa032..6ba1bf4 100644
--- a/usr.bin/systat/swap.c
+++ b/usr.bin/systat/swap.c
@@ -31,13 +31,13 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)swap.c 8.3 (Berkeley) 4/29/95";
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)swap.c 8.3 (Berkeley) 4/29/95";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
/*
* swapinfo - based on a program of the same name by Kevin Lahey
@@ -147,7 +147,7 @@ showswap()
#define CONVERT(v) ((int)((quad_t)(v) * pagesize / blocksize))
for (i = 0; i <= kvnsw; ++i) {
- int col = 5;
+ int lcol = 5;
int count;
if (i == kvnsw) {
@@ -156,17 +156,17 @@ showswap()
mvwprintw(
wnd,
i + 1,
- col,
+ lcol,
"%-5s",
"Total"
);
- col += 5;
+ lcol += 5;
}
if (kvmsw[i].ksw_total == 0) {
mvwprintw(
wnd,
i + 1,
- col + 5,
+ lcol + 5,
"(swap not configured)"
);
continue;
@@ -175,17 +175,17 @@ showswap()
mvwprintw(
wnd,
i + 1,
- col,
+ lcol,
"%*d",
hlen,
CONVERT(kvmsw[i].ksw_total)
);
- col += hlen;
+ lcol += hlen;
mvwprintw(
wnd,
i + 1,
- col,
+ lcol,
"%9d ",
CONVERT(kvmsw[i].ksw_used)
);
diff --git a/usr.bin/systat/systat.h b/usr.bin/systat/systat.h
index 187c6ba6..f37a04c 100644
--- a/usr.bin/systat/systat.h
+++ b/usr.bin/systat/systat.h
@@ -37,14 +37,14 @@
#include <curses.h>
struct cmdtab {
- char *c_name; /* command name */
+ const char *c_name; /* command name */
void (*c_refresh)(void); /* display refresh */
void (*c_fetch)(void); /* sets up data structures */
void (*c_label)(void); /* label display */
int (*c_init)(void); /* initialize namelist, etc. */
WINDOW *(*c_open)(void); /* open display */
void (*c_close)(WINDOW *); /* close display */
- int (*c_cmd)(char *, char *); /* display command interpreter */
+ int (*c_cmd)(const char *, const char *); /* display command interpreter */
void (*c_reset)(void); /* reset ``mode since'' display */
char c_flags; /* see below */
};
diff --git a/usr.bin/systat/tcp.c b/usr.bin/systat/tcp.c
index 622d8bb..bd9e2f9 100644
--- a/usr.bin/systat/tcp.c
+++ b/usr.bin/systat/tcp.c
@@ -31,15 +31,14 @@
* SUCH DAMAGE.
*/
-#ifndef lint
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
/* From:
-static char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93";
-static const char rcsid[] =
- "Id: mbufs.c,v 1.5 1997/02/24 20:59:03 wollman Exp";
+ "@(#)mbufs.c 8.1 (Berkeley) 6/6/93"
+ "Id: mbufs.c,v 1.5 1997/02/24 20:59:03 wollman Exp"
*/
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
#include <sys/param.h>
#include <sys/types.h>
@@ -60,6 +59,7 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <paths.h>
+
#include "systat.h"
#include "extern.h"
#include "mode.h"
diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c
index 315723f..2242fd7 100644
--- a/usr.bin/systat/vmstat.c
+++ b/usr.bin/systat/vmstat.c
@@ -31,13 +31,13 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94";
+#include <sys/cdefs.h>
+
+__FBSDID("$FreeBSD$");
+
+#ifdef lint
+static const char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94";
#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
/*
* Cursed vmstat -- from Robert Elz.
@@ -134,7 +134,7 @@ static void allocinfo __P((struct Info *));
static void copyinfo __P((struct Info *, struct Info *));
static float cputime __P((int));
static void dinfo __P((int, int, struct statinfo *, struct statinfo *));
-static void getinfo __P((struct Info *, enum state));
+static void getinfo __P((struct Info *));
static void putint __P((int, int, int, int));
static void putfloat __P((double, int, int, int, int, int));
static void putlongdouble __P((long double, int, int, int, int, int));
@@ -258,7 +258,7 @@ initkre()
allocinfo(&s2);
allocinfo(&z);
}
- getinfo(&s2, RUN);
+ getinfo(&s2);
copyinfo(&s2, &s1);
return(1);
}
@@ -277,13 +277,13 @@ fetchkre()
tp = localtime(&now);
(void) strftime(buf, sizeof(buf),
d_first ? "%e %b %R" : "%b %e %R", tp);
- getinfo(&s, state);
+ getinfo(&s);
}
void
labelkre()
{
- register int i, j;
+ int i, j;
clear();
mvprintw(STATROW, STATCOL + 4, "users Load");
@@ -394,7 +394,7 @@ showkre()
{
float f1, f2;
int psiz, inttotal;
- int i, j, k, l, c;
+ int i, j, k, l, lc;
static int failcnt = 0;
char intrbuffer[10];
@@ -429,7 +429,7 @@ showkre()
continue;
intrloc[i] = nextintsrow++;
k = 0;
- for (j = 0; j < sizeof(intrbuffer); j++) {
+ for (j = 0; j < (int)sizeof(intrbuffer); j++) {
if (strncmp(&intrname[i][j], "irq", 3) == 0)
j += 3;
intrbuffer[k++] = intrname[i][j];
@@ -453,18 +453,18 @@ showkre()
psiz = 0;
f2 = 0.0;
- for (c = 0; c < CPUSTATES; c++) {
- i = cpuorder[c];
+ for (lc = 0; lc < CPUSTATES; lc++) {
+ i = cpuorder[lc];
f1 = cputime(i);
f2 += f1;
l = (int) ((f2 + 1.0) / 2.0) - psiz;
if (f1 > 99.9)
f1 = 99.9; /* no room to display 100.0 */
- putfloat(f1, GRAPHROW, GRAPHCOL + 10 * c, 4, 1, 0);
+ putfloat(f1, GRAPHROW, GRAPHCOL + 10 * lc, 4, 1, 0);
move(GRAPHROW + 2, psiz);
psiz += l;
while (l-- > 0)
- addch(cpuchar[c]);
+ addch(cpuchar[lc]);
}
putint(ucount(), STATROW, STATCOL, 3);
@@ -538,22 +538,22 @@ showkre()
PUTRATE(v_soft, GENSTATROW + 1, GENSTATCOL + 20, 5);
PUTRATE(v_vm_faults, GENSTATROW + 1, GENSTATCOL + 25, 5);
mvprintw(DISKROW, DISKCOL + 5, " ");
- for (i = 0, c = 0; i < num_devices && c < MAXDRIVES; i++)
+ for (i = 0, lc = 0; i < num_devices && lc < MAXDRIVES; i++)
if (dev_select[i].selected) {
char tmpstr[80];
sprintf(tmpstr, "%s%d", dev_select[i].device_name,
dev_select[i].unit_number);
- mvprintw(DISKROW, DISKCOL + 5 + 6 * c,
+ mvprintw(DISKROW, DISKCOL + 5 + 6 * lc,
" %5.5s", tmpstr);
switch(state) {
case TIME:
- dinfo(i, ++c, &cur, &last);
+ dinfo(i, ++lc, &cur, &last);
break;
case RUN:
- dinfo(i, ++c, &cur, &run);
+ dinfo(i, ++lc, &cur, &run);
break;
case BOOT:
- dinfo(i, ++c, &cur, NULL);
+ dinfo(i, ++lc, &cur, NULL);
break;
}
}
@@ -572,7 +572,7 @@ showkre()
int
cmdkre(cmd, args)
- char *cmd, *args;
+ const char *cmd, *args;
{
int retval;
@@ -608,7 +608,7 @@ cmdkre(cmd, args)
if (prefix(cmd, "zero")) {
retval = 1;
if (state == RUN) {
- getinfo(&s1, RUN);
+ getinfo(&s1);
switch (devstat_getdevs(NULL, &run)) {
case -1:
errx(1, "%s", devstat_errbuf);
@@ -638,7 +638,7 @@ cmdkre(cmd, args)
static int
ucount()
{
- register int nusers = 0;
+ int nusers = 0;
if (ut < 0)
return (0);
@@ -654,31 +654,31 @@ static float
cputime(indx)
int indx;
{
- double t;
- register int i;
+ double lt;
+ int i;
- t = 0;
+ lt = 0;
for (i = 0; i < CPUSTATES; i++)
- t += s.time[i];
- if (t == 0.0)
- t = 1.0;
- return (s.time[indx] * 100.0 / t);
+ lt += s.time[i];
+ if (lt == 0.0)
+ lt = 1.0;
+ return (s.time[indx] * 100.0 / lt);
}
static void
-putint(n, l, c, w)
- int n, l, c, w;
+putint(n, l, lc, w)
+ int n, l, lc, w;
{
char b[128];
- move(l, c);
+ move(l, lc);
if (n == 0) {
while (w-- > 0)
addch(' ');
return;
}
snprintf(b, sizeof(b), "%*d", w, n);
- if (strlen(b) > w) {
+ if ((int)strlen(b) > w) {
while (w-- > 0)
addch('*');
return;
@@ -687,22 +687,22 @@ putint(n, l, c, w)
}
static void
-putfloat(f, l, c, w, d, nz)
+putfloat(f, l, lc, w, d, nz)
double f;
- int l, c, w, d, nz;
+ int l, lc, w, d, nz;
{
char b[128];
- move(l, c);
+ move(l, lc);
if (nz && f == 0.0) {
while (--w >= 0)
addch(' ');
return;
}
snprintf(b, sizeof(b), "%*.*f", w, d, f);
- if (strlen(b) > w)
+ if ((int)strlen(b) > w)
snprintf(b, sizeof(b), "%*.0f", w, f);
- if (strlen(b) > w) {
+ if ((int)strlen(b) > w) {
while (--w >= 0)
addch('*');
return;
@@ -711,22 +711,22 @@ putfloat(f, l, c, w, d, nz)
}
static void
-putlongdouble(f, l, c, w, d, nz)
+putlongdouble(f, l, lc, w, d, nz)
long double f;
- int l, c, w, d, nz;
+ int l, lc, w, d, nz;
{
char b[128];
- move(l, c);
+ move(l, lc);
if (nz && f == 0.0) {
while (--w >= 0)
addch(' ');
return;
}
sprintf(b, "%*.*Lf", w, d, f);
- if (strlen(b) > w)
+ if ((int)strlen(b) > w)
sprintf(b, "%*.0Lf", w, f);
- if (strlen(b) > w) {
+ if ((int)strlen(b) > w) {
while (--w >= 0)
addch('*');
return;
@@ -735,60 +735,59 @@ putlongdouble(f, l, c, w, d, nz)
}
static void
-getinfo(s, st)
- struct Info *s;
- enum state st;
+getinfo(ls)
+ struct Info *ls;
{
struct devinfo *tmp_dinfo;
size_t size;
int mib[2];
- GETSYSCTL("kern.cp_time", s->time);
+ GETSYSCTL("kern.cp_time", ls->time);
GETSYSCTL("kern.cp_time", cur.cp_time);
- GETSYSCTL("vm.stats.sys.v_swtch", s->v_swtch);
- GETSYSCTL("vm.stats.sys.v_trap", s->v_trap);
- GETSYSCTL("vm.stats.sys.v_syscall", s->v_syscall);
- GETSYSCTL("vm.stats.sys.v_intr", s->v_intr);
- GETSYSCTL("vm.stats.sys.v_soft", s->v_soft);
- GETSYSCTL("vm.stats.vm.v_vm_faults", s->v_vm_faults);
- GETSYSCTL("vm.stats.vm.v_cow_faults", s->v_cow_faults);
- GETSYSCTL("vm.stats.vm.v_zfod", s->v_zfod);
- GETSYSCTL("vm.stats.vm.v_ozfod", s->v_ozfod);
- GETSYSCTL("vm.stats.vm.v_swapin", s->v_swapin);
- GETSYSCTL("vm.stats.vm.v_swapout", s->v_swapout);
- GETSYSCTL("vm.stats.vm.v_swappgsin", s->v_swappgsin);
- GETSYSCTL("vm.stats.vm.v_swappgsout", s->v_swappgsout);
- GETSYSCTL("vm.stats.vm.v_vnodein", s->v_vnodein);
- GETSYSCTL("vm.stats.vm.v_vnodeout", s->v_vnodeout);
- GETSYSCTL("vm.stats.vm.v_vnodepgsin", s->v_vnodepgsin);
- GETSYSCTL("vm.stats.vm.v_vnodepgsout", s->v_vnodepgsout);
- GETSYSCTL("vm.stats.vm.v_intrans", s->v_intrans);
- GETSYSCTL("vm.stats.vm.v_reactivated", s->v_reactivated);
- GETSYSCTL("vm.stats.vm.v_pdwakeups", s->v_pdwakeups);
- GETSYSCTL("vm.stats.vm.v_pdpages", s->v_pdpages);
- GETSYSCTL("vm.stats.vm.v_dfree", s->v_dfree);
- GETSYSCTL("vm.stats.vm.v_pfree", s->v_pfree);
- GETSYSCTL("vm.stats.vm.v_tfree", s->v_tfree);
- GETSYSCTL("vm.stats.vm.v_page_size", s->v_page_size);
- GETSYSCTL("vm.stats.vm.v_free_count", s->v_free_count);
- GETSYSCTL("vm.stats.vm.v_wire_count", s->v_wire_count);
- GETSYSCTL("vm.stats.vm.v_active_count", s->v_active_count);
- GETSYSCTL("vm.stats.vm.v_inactive_count", s->v_inactive_count);
- GETSYSCTL("vm.stats.vm.v_cache_count", s->v_cache_count);
- GETSYSCTL("vfs.bufspace", s->bufspace);
- GETSYSCTL("kern.maxvnodes", s->desiredvnodes);
- GETSYSCTL("debug.numvnodes", s->numvnodes);
- GETSYSCTL("debug.freevnodes", s->freevnodes);
- GETSYSCTL("vfs.cache.nchstats", s->nchstats);
- GETSYSCTL("vfs.numdirtybuffers", s->numdirtybuffers);
- getsysctl("hw.intrcnt", s->intrcnt, nintr * sizeof(u_long));
-
- size = sizeof(s->Total);
+ GETSYSCTL("vm.stats.sys.v_swtch", ls->v_swtch);
+ GETSYSCTL("vm.stats.sys.v_trap", ls->v_trap);
+ GETSYSCTL("vm.stats.sys.v_syscall", ls->v_syscall);
+ GETSYSCTL("vm.stats.sys.v_intr", ls->v_intr);
+ GETSYSCTL("vm.stats.sys.v_soft", ls->v_soft);
+ GETSYSCTL("vm.stats.vm.v_vm_faults", ls->v_vm_faults);
+ GETSYSCTL("vm.stats.vm.v_cow_faults", ls->v_cow_faults);
+ GETSYSCTL("vm.stats.vm.v_zfod", ls->v_zfod);
+ GETSYSCTL("vm.stats.vm.v_ozfod", ls->v_ozfod);
+ GETSYSCTL("vm.stats.vm.v_swapin", ls->v_swapin);
+ GETSYSCTL("vm.stats.vm.v_swapout", ls->v_swapout);
+ GETSYSCTL("vm.stats.vm.v_swappgsin", ls->v_swappgsin);
+ GETSYSCTL("vm.stats.vm.v_swappgsout", ls->v_swappgsout);
+ GETSYSCTL("vm.stats.vm.v_vnodein", ls->v_vnodein);
+ GETSYSCTL("vm.stats.vm.v_vnodeout", ls->v_vnodeout);
+ GETSYSCTL("vm.stats.vm.v_vnodepgsin", ls->v_vnodepgsin);
+ GETSYSCTL("vm.stats.vm.v_vnodepgsout", ls->v_vnodepgsout);
+ GETSYSCTL("vm.stats.vm.v_intrans", ls->v_intrans);
+ GETSYSCTL("vm.stats.vm.v_reactivated", ls->v_reactivated);
+ GETSYSCTL("vm.stats.vm.v_pdwakeups", ls->v_pdwakeups);
+ GETSYSCTL("vm.stats.vm.v_pdpages", ls->v_pdpages);
+ GETSYSCTL("vm.stats.vm.v_dfree", ls->v_dfree);
+ GETSYSCTL("vm.stats.vm.v_pfree", ls->v_pfree);
+ GETSYSCTL("vm.stats.vm.v_tfree", ls->v_tfree);
+ GETSYSCTL("vm.stats.vm.v_page_size", ls->v_page_size);
+ GETSYSCTL("vm.stats.vm.v_free_count", ls->v_free_count);
+ GETSYSCTL("vm.stats.vm.v_wire_count", ls->v_wire_count);
+ GETSYSCTL("vm.stats.vm.v_active_count", ls->v_active_count);
+ GETSYSCTL("vm.stats.vm.v_inactive_count", ls->v_inactive_count);
+ GETSYSCTL("vm.stats.vm.v_cache_count", ls->v_cache_count);
+ GETSYSCTL("vfs.bufspace", ls->bufspace);
+ GETSYSCTL("kern.maxvnodes", ls->desiredvnodes);
+ GETSYSCTL("debug.numvnodes", ls->numvnodes);
+ GETSYSCTL("debug.freevnodes", ls->freevnodes);
+ GETSYSCTL("vfs.cache.nchstats", ls->nchstats);
+ GETSYSCTL("vfs.numdirtybuffers", ls->numdirtybuffers);
+ getsysctl("hw.intrcnt", ls->intrcnt, nintr * sizeof(u_long));
+
+ size = sizeof(ls->Total);
mib[0] = CTL_VM;
mib[1] = VM_METER;
- if (sysctl(mib, 2, &s->Total, &size, NULL, 0) < 0) {
+ if (sysctl(mib, 2, &ls->Total, &size, NULL, 0) < 0) {
error("Can't get kernel info: %s\n", strerror(errno));
- bzero(&s->Total, sizeof(s->Total));
+ bzero(&ls->Total, sizeof(ls->Total));
}
size = sizeof(ncpu);
if (sysctlbyname("hw.ncpu", &ncpu, &size, NULL, 0) < 0 ||
@@ -815,18 +814,18 @@ getinfo(s, st)
}
static void
-allocinfo(s)
- struct Info *s;
+allocinfo(ls)
+ struct Info *ls;
{
- s->intrcnt = (long *) calloc(nintr, sizeof(long));
- if (s->intrcnt == NULL)
+ ls->intrcnt = (long *) calloc(nintr, sizeof(long));
+ if (ls->intrcnt == NULL)
errx(2, "out of memory");
}
static void
copyinfo(from, to)
- register struct Info *from, *to;
+ struct Info *from, *to;
{
long *intrcnt;
@@ -842,8 +841,8 @@ copyinfo(from, to)
}
static void
-dinfo(dn, c, now, then)
- int dn, c;
+dinfo(dn, lc, now, then)
+ int dn, lc;
struct statinfo *now, *then;
{
long double transfers_per_second;
@@ -877,9 +876,9 @@ dinfo(dn, c, now, then)
* where the device has been 100% busy, correct it */
device_busy = elapsed_time;
- c = DISKCOL + c * 6;
- putlongdouble(kb_per_transfer, DISKROW + 1, c, 5, 2, 0);
- putlongdouble(transfers_per_second, DISKROW + 2, c, 5, 0, 0);
- putlongdouble(mb_per_second, DISKROW + 3, c, 5, 2, 0);
- putlongdouble(device_busy * 100 / elapsed_time, DISKROW + 4, c, 5, 0, 0);
+ lc = DISKCOL + lc * 6;
+ putlongdouble(kb_per_transfer, DISKROW + 1, lc, 5, 2, 0);
+ putlongdouble(transfers_per_second, DISKROW + 2, lc, 5, 0, 0);
+ putlongdouble(mb_per_second, DISKROW + 3, lc, 5, 2, 0);
+ putlongdouble(device_busy * 100 / elapsed_time, DISKROW + 4, lc, 5, 0, 0);
}
OpenPOWER on IntegriCloud