From owner-freebsd-audit Thu Sep 27 11:58:41 2001 Delivered-To: freebsd-audit@freebsd.org Received: from freebsd.org.ru (sweet.etrust.ru [194.84.67.5]) by hub.freebsd.org (Postfix) with ESMTP id 51DE537B419 for ; Thu, 27 Sep 2001 11:58:22 -0700 (PDT) Received: by freebsd.org.ru (Postfix, from userid 1000) id B7DC6269; Thu, 27 Sep 2001 22:58:14 +0400 (MSD) Date: Thu, 27 Sep 2001 22:58:14 +0400 From: "Sergey A. Osokin" To: audit@FreeBSD.org Subject: iostat(8) WARNS=2 cleanup Message-ID: <20010927225814.A46080@freebsd.org.ru> Reply-To: osa@FreeBSD.org.ru Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="vkogqOf2sHV7VnPd" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.3.22.1i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --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 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 #include -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