summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2006-03-13 19:29:26 +0000
committerotto <otto@openbsd.org>2006-03-13 19:29:26 +0000
commit19c5012cfdd9688cff913ebd352f493c8362e348 (patch)
tree34969a789b2abc65bf44bfb394382901155dc70a
parentCleanup and plug a fe memleaks and; from Davif Hill with a twist from (diff)
downloadwireguard-openbsd-19c5012cfdd9688cff913ebd352f493c8362e348.tar.xz
wireguard-openbsd-19c5012cfdd9688cff913ebd352f493c8362e348.zip
delint; from David Hill
-rw-r--r--usr.bin/vmstat/dkstats.c8
-rw-r--r--usr.bin/vmstat/vmstat.c26
-rw-r--r--usr.sbin/iostat/iostat.c27
3 files changed, 30 insertions, 31 deletions
diff --git a/usr.bin/vmstat/dkstats.c b/usr.bin/vmstat/dkstats.c
index 3ad4b138489..c2d80435ce5 100644
--- a/usr.bin/vmstat/dkstats.c
+++ b/usr.bin/vmstat/dkstats.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dkstats.c,v 1.27 2005/10/17 19:04:20 otto Exp $ */
+/* $OpenBSD: dkstats.c,v 1.28 2006/03/13 19:29:26 otto Exp $ */
/* $NetBSD: dkstats.c,v 1.1 1996/05/10 23:19:27 thorpej Exp $ */
/*
@@ -396,7 +396,7 @@ dkreadstats(void)
* track disk statistics.
*/
int
-dkinit(int select)
+dkinit(int sel)
{
#if !defined(NOKVM)
struct disklist_head disk_head;
@@ -513,7 +513,7 @@ dkinit(int select)
bufpp = disknames;
for (i = 0; i < dk_ndrive && (name = strsep(&bufpp, ",")) != NULL; i++) {
cur.dk_name[i] = name;
- cur.dk_select[i] = select;
+ cur.dk_select[i] = sel;
}
} else {
#if !defined(NOKVM)
@@ -526,7 +526,7 @@ dkinit(int select)
cur.dk_name[i] = strdup(buf);
if (!cur.dk_name[i])
errx(1, "Memory allocation failure.");
- cur.dk_select[i] = select;
+ cur.dk_select[i] = sel;
p = TAILQ_NEXT(&cur_disk, dk_link);
}
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index b469e1b018a..2b51c8ddc02 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -1,5 +1,5 @@
/* $NetBSD: vmstat.c,v 1.29.4.1 1996/06/05 00:21:05 cgd Exp $ */
-/* $OpenBSD: vmstat.c,v 1.100 2006/02/23 06:32:11 martin Exp $ */
+/* $OpenBSD: vmstat.c,v 1.101 2006/03/13 19:29:26 otto Exp $ */
/*
* Copyright (c) 1980, 1986, 1991, 1993
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)vmstat.c 8.1 (Berkeley) 6/6/93";
#else
-static const char rcsid[] = "$OpenBSD: vmstat.c,v 1.100 2006/02/23 06:32:11 martin Exp $";
+static const char rcsid[] = "$OpenBSD: vmstat.c,v 1.101 2006/03/13 19:29:26 otto Exp $";
#endif
#endif /* not lint */
@@ -120,6 +120,7 @@ kvm_t *kd;
#define VMSTAT 0x20
void cpustats(void);
+time_t getuptime(void);
void dkstats(void);
void dointr(void);
void domem(void);
@@ -131,6 +132,8 @@ int kreado(struct nlist *, void *, size_t);
void usage(void);
void dotimes(void);
void doforkst(void);
+void needhdr(int);
+int pct(long, long);
void printhdr(void);
char **choosedrives(char **);
@@ -148,8 +151,6 @@ int ncpu;
int
main(int argc, char *argv[])
{
- extern int optind;
- extern char *optarg;
int mib[2];
size_t size;
int c, todo;
@@ -367,7 +368,6 @@ dovmstat(u_int interval, int reps)
{
struct vmtotal total;
time_t uptime, halfuptime;
- void needhdr(int);
int mib[2];
struct clockinfo clkinfo;
size_t size;
@@ -692,18 +692,18 @@ void
cpustats(void)
{
int state;
- double pct, total;
+ double percent, total;
total = 0;
for (state = 0; state < CPUSTATES; ++state)
total += cur.cp_time[state];
if (total)
- pct = 100 / total;
+ percent = 100 / total;
else
- pct = 0;
- (void)printf("%2.0f ", (cur.cp_time[CP_USER] + cur.cp_time[CP_NICE]) * pct);
- (void)printf("%2.0f ", (cur.cp_time[CP_SYS] + cur.cp_time[CP_INTR]) * pct);
- (void)printf("%2.0f", cur.cp_time[CP_IDLE] * pct);
+ percent = 0;
+ (void)printf("%2.0f ", (cur.cp_time[CP_USER] + cur.cp_time[CP_NICE]) * percent);
+ (void)printf("%2.0f ", (cur.cp_time[CP_SYS] + cur.cp_time[CP_INTR]) * percent);
+ (void)printf("%2.0f", cur.cp_time[CP_IDLE] * percent);
}
void
@@ -786,7 +786,7 @@ dointr(void)
/*
* These names are defined in <sys/malloc.h>.
*/
-char *kmemnames[] = INITKMEMNAMES;
+const char *kmemnames[] = INITKMEMNAMES;
void
domem(void)
@@ -797,7 +797,7 @@ domem(void)
int len, size, first;
u_long totuse = 0, totfree = 0;
quad_t totreq = 0;
- char *name;
+ const char *name;
struct kmemstats kmemstats[M_LAST];
struct kmembuckets buckets[MINBUCKET + 16];
int mib[4];
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index 4e922e8b509..e5570a7a29e 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iostat.c,v 1.22 2005/04/01 03:32:47 deraadt Exp $ */
+/* $OpenBSD: iostat.c,v 1.23 2006/03/13 19:31:07 otto Exp $ */
/* $NetBSD: iostat.c,v 1.10 1996/10/25 18:21:58 scottr Exp $ */
/*
@@ -118,7 +118,7 @@ static void sigheader(int);
static void header(void);
static void usage(void);
static void display(void);
-static void selectdrives(int, char **);
+static void selectdrives(char **);
void dkswap(void);
void dkreadstats(void);
@@ -173,7 +173,7 @@ main(int argc, char *argv[])
dkinit(0);
dkreadstats();
- selectdrives(argc, argv);
+ selectdrives(argv);
tv.tv_sec = interval;
tv.tv_usec = 0;
@@ -237,17 +237,17 @@ header(void)
if (ISSET(todo, SHOW_STATS_1))
for (i = 0; i < dk_ndrive; i++)
- if (cur.dk_select[i])
+ if (cur.dk_select[i]) {
if (ISSET(todo, SHOW_TOTALS))
(void)printf(" KB/t xfr MB ");
else
(void)printf(" KB/t t/s MB/s ");
-
+ }
if (ISSET(todo, SHOW_STATS_2))
for (i = 0; i < dk_ndrive; i++)
- if (cur.dk_select[i])
+ if (cur.dk_select[i]) {
(void)printf(" KB xfr time ");
-
+ }
if (ISSET(todo, SHOW_CPU))
(void)printf(" us ni sy in id");
printf("\n");
@@ -319,16 +319,15 @@ static void
cpustats(void)
{
int state;
- double time;
+ double t = 0;
- time = 0;
for (state = 0; state < CPUSTATES; ++state)
- time += cur.cp_time[state];
- if (!time)
- time = 1.0;
+ t += cur.cp_time[state];
+ if (!t)
+ t = 1.0;
/* States are generally never 100% and can use %3.0f. */
for (state = 0; state < CPUSTATES; ++state)
- printf("%3.0f", 100. * cur.cp_time[state] / time);
+ printf("%3.0f", 100. * cur.cp_time[state] / t);
}
static void
@@ -378,7 +377,7 @@ display(void)
}
static void
-selectdrives(int argc, char *argv[])
+selectdrives(char *argv[])
{
int i, ndrives;