From owner-svn-src-stable-10@freebsd.org Thu Mar 17 20:29:11 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 75A6CAD4EA6; Thu, 17 Mar 2016 20:29:11 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 50711955; Thu, 17 Mar 2016 20:29:11 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u2HKTAhW048382; Thu, 17 Mar 2016 20:29:10 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u2HKTAMN048380; Thu, 17 Mar 2016 20:29:10 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201603172029.u2HKTAMN048380@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Thu, 17 Mar 2016 20:29:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r296995 - stable/10/usr.sbin/iostat X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Mar 2016 20:29:11 -0000 Author: asomers Date: Thu Mar 17 20:29:10 2016 New Revision: 296995 URL: https://svnweb.freebsd.org/changeset/base/296995 Log: MFC r295900, r295768 to usr.sbin/iostat r295768 | asomers | 2016-02-18 13:08:01 -0700 (Thu, 18 Feb 2016) | 14 lines Fix compiler warnings in iostat Raise WARNS from 1 to 6 (the default) Fix warnings: * Use C99 designated initializers for structs, and initialize all fields * Mark global variables as static * Mark unused function arguments * Be careful about signed/unsigned comparisons r295900 | asomers | 2016-02-22 14:40:53 -0700 (Mon, 22 Feb 2016) | 10 lines Fix the usr.sbin/iostat build with GCC, broken by r295768 Renamed some local variables for compatibility with -Wshadow Modified: stable/10/usr.sbin/iostat/Makefile stable/10/usr.sbin/iostat/iostat.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/iostat/Makefile ============================================================================== --- stable/10/usr.sbin/iostat/Makefile Thu Mar 17 20:00:49 2016 (r296994) +++ stable/10/usr.sbin/iostat/Makefile Thu Mar 17 20:29:10 2016 (r296995) @@ -7,6 +7,4 @@ MAN= iostat.8 DPADD= ${LIBDEVSTAT} ${LIBKVM} ${LIBM} LDADD= -ldevstat -lkvm -lm -WARNS?= 1 - .include Modified: stable/10/usr.sbin/iostat/iostat.c ============================================================================== --- stable/10/usr.sbin/iostat/iostat.c Thu Mar 17 20:00:49 2016 (r296994) +++ stable/10/usr.sbin/iostat/iostat.c Thu Mar 17 20:29:10 2016 (r296995) @@ -117,30 +117,34 @@ #include #include -struct nlist namelist[] = { +static struct nlist namelist[] = { #define X_TK_NIN 0 - { "_tk_nin" }, + { .n_name = "_tk_nin", + .n_type = 0, .n_other = 0, .n_desc = 0, .n_value = 0 }, #define X_TK_NOUT 1 - { "_tk_nout" }, + { .n_name = "_tk_nout", + .n_type = 0, .n_other = 0, .n_desc = 0, .n_value = 0 }, #define X_BOOTTIME 2 - { "_boottime" }, + { .n_name = "_boottime", + .n_type = 0, .n_other = 0, .n_desc = 0, .n_value = 0 }, #define X_END 2 - { NULL }, + { .n_name = NULL, + .n_type = 0, .n_other = 0, .n_desc = 0, .n_value = 0 }, }; #define IOSTAT_DEFAULT_ROWS 20 /* Traditional default `wrows' */ -struct statinfo cur, last; -int num_devices; -struct device_selection *dev_select; -int maxshowdevs; -volatile sig_atomic_t headercount; -volatile sig_atomic_t wresized; /* Tty resized, when non-zero. */ -volatile sig_atomic_t alarm_rang; -volatile sig_atomic_t return_requested; -unsigned short wrows; /* Current number of tty rows. */ -int dflag = 0, Iflag = 0, Cflag = 0, Tflag = 0, oflag = 0, Kflag = 0; -int xflag = 0, zflag = 0; +static struct statinfo cur, last; +static int num_devices; +static struct device_selection *dev_select; +static int maxshowdevs; +static volatile sig_atomic_t headercount; +static volatile sig_atomic_t wresized; /* Tty resized, when non-zero. */ +static volatile sig_atomic_t alarm_rang; +static volatile sig_atomic_t return_requested; +static unsigned short wrows; /* Current number of tty rows. */ +static int dflag = 0, Iflag = 0, Cflag = 0, Tflag = 0, oflag = 0, Kflag = 0; +static int xflag = 0, zflag = 0; /* local function declarations */ static void usage(void); @@ -650,7 +654,7 @@ main(int argc, char **argv) * Force a header to be prepended to the next output. */ void -needhdr(int signo) +needhdr(int signo __unused) { headercount = 1; @@ -662,7 +666,7 @@ needhdr(int signo) * prepended to the next output. */ void -needresize(int signo) +needresize(int signo __unused) { wresized = 1; @@ -673,7 +677,7 @@ needresize(int signo) * Record the alarm so the main loop can break its sleep */ void -alarm_clock(int signo) +alarm_clock(int signo __unused) { alarm_rang = 1; } @@ -682,7 +686,7 @@ alarm_clock(int signo) * Request that the main loop exit soon */ void -needreturn(int signo) +needreturn(int signo __unused) { return_requested = 1; } @@ -791,7 +795,7 @@ devstats(int perf_select, long double et long double total_mb; long double blocks_per_second, ms_per_transaction, total_duration; int firstline = 1; - char *devname; + char *devicename; if (xflag > 0) { printf(" extended device statistics "); @@ -862,7 +866,7 @@ devstats(int perf_select, long double et } if (xflag > 0) { - if (asprintf(&devname, "%s%d", + if (asprintf(&devicename, "%s%d", cur.dinfo->devices[di].device_name, cur.dinfo->devices[di].unit_number) == -1) err(1, "asprintf"); @@ -876,7 +880,8 @@ devstats(int perf_select, long double et busy_pct > 0.5) { if (Iflag == 0) printf("%-8.8s %5.1Lf %5.1Lf %7.1Lf %7.1Lf %4" PRIu64 " %5.1Lf %3.0Lf ", - devname, transfers_per_second_read, + devicename, + transfers_per_second_read, transfers_per_second_write, mb_per_second_read * 1024, mb_per_second_write * 1024, @@ -886,7 +891,7 @@ devstats(int perf_select, long double et printf("%-8.8s %11.1Lf %11.1Lf " "%12.1Lf %12.1Lf %4" PRIu64 " %10.1Lf %9.1Lf ", - devname, + devicename, (long double)total_transfers_read, (long double)total_transfers_write, (long double) @@ -911,7 +916,7 @@ devstats(int perf_select, long double et } printf("\n"); } - free(devname); + free(devicename); } else if (oflag > 0) { int msdig = (ms_per_transaction < 100.0) ? 1 : 0; @@ -965,15 +970,15 @@ static void cpustats(void) { int state; - double time; + double cptime; - time = 0.0; + cptime = 0.0; for (state = 0; state < CPUSTATES; ++state) - time += cur.cp_time[state]; + cptime += cur.cp_time[state]; for (state = 0; state < CPUSTATES; ++state) printf(" %2.0f", - rint(100. * cur.cp_time[state] / (time ? time : 1))); + rint(100. * cur.cp_time[state] / (cptime ? cptime : 1))); } static int @@ -988,8 +993,7 @@ readvar(kvm_t *kd, const char *name, int warnx("kvm_read(%s): %s", namelist[nlid].n_name, kvm_geterr(kd)); return (1); - } - if (nbytes != len) { + } else if ((size_t)nbytes != len) { warnx("kvm_read(%s): expected %zu bytes, got %zd bytes", namelist[nlid].n_name, len, nbytes); return (1);