Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Sep 2001 22:58:14 +0400
From:      "Sergey A. Osokin" <osa@freebsd.org.ru>
To:        audit@FreeBSD.org
Subject:   iostat(8) WARNS=2 cleanup
Message-ID:  <20010927225814.A46080@freebsd.org.ru>

next in thread | raw e-mail | index | archive | help

--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

Hello.
Please review patch.
Thanks.
-- 

Rgdz,                                /"\ 
Sergey Osokin aka oZZ,               \ /  ASCII RIBBON CAMPAIGN
osa@freebsd.org.ru                    X     AGAINST HTML MAIL
http://freebsd.org.ru/~osa/          / \

--vkogqOf2sHV7VnPd
Content-Type: text/plain; charset=koi8-r
Content-Disposition: attachment; filename=patch-iostat
Content-Transfer-Encoding: 8bit

diff -ruN iostat.orig/Makefile iostat/Makefile
--- iostat.orig/Makefile	Mon Sep 24 13:20:34 2001
+++ iostat/Makefile	Mon Sep 24 12:58:56 2001
@@ -8,4 +8,6 @@
 LDADD=	-lkvm -ldevstat -lm
 MAN=	iostat.8
 
+WARNS?=	2
+
 .include <bsd.prog.mk>
diff -ruN iostat.orig/iostat.c iostat/iostat.c
--- iostat.orig/iostat.c	Mon Sep 24 13:20:34 2001
+++ iostat/iostat.c	Mon Sep 24 13:19:01 2001
@@ -118,19 +118,13 @@
 #include <devstat.h>
 #include <math.h>
 
-struct nlist namelist[] = {
 #define X_TK_NIN	0
-	{ "_tk_nin" },
 #define X_TK_NOUT	1
-	{ "_tk_nout" },
 #define X_CP_TIME	2
-	{ "_cp_time" },
 #define X_BOOTTIME	3
-	{ "_boottime" },
 #define X_END		3
-	{ NULL },
-};
 
+struct nlist namelist[5];
 struct statinfo cur, last;
 int num_devices;
 struct device_selection *dev_select;
@@ -141,7 +135,7 @@
 /* local function declarations */
 static void usage(void);
 static void phdr(int signo);
-static void do_phdr();
+static void do_phdr(void);
 static void devstats(int perf_select, long double etime, int havelast);
 static void cpustats(void);
 static int readvar(kvm_t *kd, const char *name, int nlid, void *ptr,
@@ -185,6 +179,12 @@
 	matches = NULL;
 	maxshowdevs = 3;
 
+	(const char *)namelist[X_TK_NIN].n_name = "_tk_nin";
+	(const char *)namelist[X_TK_NOUT].n_name = "_tk_nout";
+	(const char *)namelist[X_CP_TIME].n_name = "_cp_time";
+	(const char *)namelist[X_BOOTTIME].n_name = "_boottime";
+	namelist[4].n_name = NULL;
+
 	while ((c = getopt(argc, argv, "c:CdhIKM:n:N:ot:Tw:?")) != -1) {
 		switch(c) {
 			case 'c':
@@ -580,12 +580,12 @@
 static void
 phdr(int signo)
 {
-
-	phdr_flag = 1;	
+	if (signo == SIGCONT)
+		phdr_flag = 1;	
 }
 
 static void
-do_phdr() 
+do_phdr(void) 
 {
 	register int i;
 	int printed;
@@ -722,22 +722,22 @@
 cpustats(void)
 {
 	register int state;
-	double time;
+	double ttime;
 
-	time = 0.0;
+	ttime = 0.0;
 
 	for (state = 0; state < CPUSTATES; ++state)
-		time += cur.cp_time[state];
+		ttime += cur.cp_time[state];
 	for (state = 0; state < CPUSTATES; ++state)
 		printf("%3.0f",
-		       rint(100. * cur.cp_time[state] / (time ? time : 1)));
+		       rint(100. * cur.cp_time[state] / (ttime ? ttime : 1)));
 }
 
 static int
 readvar(kvm_t *kd, const char *name, int nlid, void *ptr, size_t len)
 {
 	if (kd != NULL) {
-		ssize_t nbytes;
+		size_t nbytes;
 
 		nbytes = kvm_read(kd, nlid, ptr, len);
 

--vkogqOf2sHV7VnPd--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010927225814.A46080>