DragonFly submit List (threaded) for 2005-01
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Re: vmstat WARNS6 cleanup
> And I don't want to commit that part :)
> If you want to split out the rest of the cleanup, e.g. the statification,
> I can commit that.
Attached.
--
/ Peter Schuller, InfiDyne Technologies HB
PGP userID: 0xE9758B7D or 'Peter Schuller <peter.schuller@xxxxxxxxxxxx>'
Key retrieval: Send an E-Mail to getpgpkey@xxxxxxxxx
E-Mail: peter.schuller@xxxxxxxxxxxx Web: http://www.scode.org
--- usr.bin/vmstat/vmstat.c.orig 2005-01-08 13:11:34.000000000 +0000
+++ usr.bin/vmstat/vmstat.c 2005-01-08 13:13:47.000000000 +0000
@@ -133,13 +133,25 @@
#define VMSTAT 0x20
#define ZMEMSTAT 0x40
-void cpustats(), dointr(), domem(), dosum(), dozmem();
-void dovmstat(), kread(), usage();
+static void cpustats(void);
+static void dointr(void);
+static void domem(void);
+static void dosum(void);
+static void dozmem(void);
+static void dovmstat(u_int interval, int reps);
+static void kread(int nlx, void *addr, size_t size);
+static void usage(void);
+static char **getdrivedata(char **argv);
+static long getuptime(void);
+static void needhdr(int signo);
+static long pct(long top, long bot);
+
#ifdef notyet
-void dotimes(), doforkst();
+static void dotimes(void); /* Not implemented */
+static void doforkst(void);
#endif
-void printhdr(void);
-static void devstats();
+static void printhdr(void);
+static void devstats(void);
int
main(int argc, char **argv)
@@ -230,7 +242,8 @@
if (c > 0) {
warnx("undefined symbols:");
for (c = 0;
- c < sizeof(namelist)/sizeof(namelist[0]); c++)
+ c < (int)(sizeof(namelist)/sizeof(namelist[0]));
+ c++)
if (namelist[c].n_type == 0)
fprintf(stderr, " %s",
namelist[c].n_name);
@@ -241,7 +254,6 @@
}
if (todo & VMSTAT) {
- char **getdrivedata();
struct winsize winsize;
/*
@@ -297,7 +309,7 @@
exit(0);
}
-char **
+static char **
getdrivedata(char **argv)
{
if ((num_devices = getnumdevs()) < 0)
@@ -362,7 +374,7 @@
return(argv);
}
-long
+static long
getuptime(void)
{
static time_t now, boottime;
@@ -379,13 +391,12 @@
int hdrcnt;
-void
+static void
dovmstat(u_int interval, int reps)
{
struct vmtotal total;
time_t uptime, halfuptime;
struct devinfo *tmp_dinfo;
- void needhdr();
int vmm_size = sizeof(vmm);
int vms_size = sizeof(vms);
int vmt_size = sizeof(total);
@@ -500,7 +511,7 @@
}
}
-void
+static void
printhdr(void)
{
int i, num_shown;
@@ -526,14 +537,14 @@
/*
* Force a header to be prepended to the next output.
*/
-void
-needhdr(void)
+static void
+needhdr(__unused int signo)
{
hdrcnt = 1;
}
-long
+static long
pct(long top, long bot)
{
long ans;
@@ -546,7 +557,7 @@
#define PCT(top, bot) pct((long)(top), (long)(bot))
-void
+static void
dosum(void)
{
struct nchstats *nch_tmp, nchstats;
@@ -657,10 +668,9 @@
static void
devstats(void)
{
- int dn, state;
+ int dn;
long double transfers_per_second;
long double busy_seconds;
- long tmp;
diff_cp_time.cp_user = cp_time.cp_user - old_cp_time.cp_user;
diff_cp_time.cp_nice = cp_time.cp_nice - old_cp_time.cp_nice;
@@ -691,25 +701,28 @@
}
}
-void
+static void
cpustats(void)
{
uint64_t total;
- double pct;
+ double totusage;
total = diff_cp_time.cp_user + diff_cp_time.cp_nice +
diff_cp_time.cp_sys + diff_cp_time.cp_intr + diff_cp_time.cp_idle;
if (total)
- pct = 100.0 / total;
+ totusage = 100.0 / total;
else
- pct = 0;
- printf("%2.0f ", (diff_cp_time.cp_user + diff_cp_time.cp_nice) * pct);
- printf("%2.0f ", (diff_cp_time.cp_sys + diff_cp_time.cp_intr) * pct);
- printf("%2.0f", diff_cp_time.cp_idle * pct);
+ totusage = 0;
+ printf("%2.0f ",
+ (diff_cp_time.cp_user + diff_cp_time.cp_nice) * totusage);
+ printf("%2.0f ",
+ (diff_cp_time.cp_sys + diff_cp_time.cp_intr) * totusage);
+ printf("%2.0f",
+ diff_cp_time.cp_idle * totusage);
}
-void
+static void
dointr(void)
{
u_long *intrcnt, uptime;
@@ -756,7 +769,7 @@
return(ttl);
}
-void
+static void
domem(void)
{
struct malloc_type *ks;
@@ -774,7 +787,7 @@
if (sizeof(buf) != kvm_read(kd,
(u_long)kmemstats[nkms].ks_shortdesc, buf, sizeof(buf)))
err(1, "kvm_read(%p)",
- (void *)kmemstats[nkms].ks_shortdesc);
+ kmemstats[nkms].ks_shortdesc);
buf[sizeof(buf) - 1] = '\0';
kmemstats[nkms].ks_shortdesc = strdup(buf);
kmsp = kmemstats[nkms].ks_next;
@@ -818,7 +831,7 @@
(totuse + 1023) / 1024, (totfree + 1023) / 1024, totreq);
}
-void
+static void
dozmem(void)
{
char *buf;
@@ -843,7 +856,7 @@
/*
* kread reads something from the kernel, given its nlist index.
*/
-void
+static void
kread(int nlx, void *addr, size_t size)
{
const char *sym;
@@ -854,7 +867,7 @@
++sym;
errx(1, "symbol %s not defined", sym);
}
- if (kvm_read(kd, namelist[nlx].n_value, addr, size) != size) {
+ if (kvm_read(kd, namelist[nlx].n_value, addr, size) != (ssize_t)size) {
sym = namelist[nlx].n_name;
if (*sym == '_')
++sym;
@@ -862,7 +875,7 @@
}
}
-void
+static void
usage(void)
{
fprintf(stderr, "%s%s",
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]