From owner-svn-src-head@freebsd.org Wed Jun 13 08:52:05 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6B39E101503F; Wed, 13 Jun 2018 08:52:05 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1A1A3751BA; Wed, 13 Jun 2018 08:52:05 +0000 (UTC) (envelope-from eadler@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D5BB6172CC; Wed, 13 Jun 2018 08:52:04 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5D8q4pK093534; Wed, 13 Jun 2018 08:52:04 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5D8q4l0093532; Wed, 13 Jun 2018 08:52:04 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201806130852.w5D8q4l0093532@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Wed, 13 Jun 2018 08:52:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335036 - head/usr.bin/vmstat X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/usr.bin/vmstat X-SVN-Commit-Revision: 335036 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 08:52:05 -0000 Author: eadler Date: Wed Jun 13 08:52:04 2018 New Revision: 335036 URL: https://svnweb.freebsd.org/changeset/base/335036 Log: vmstat(1): various nits Continue my parade on introspection tools by fixing: - failed to check for null after reallocf - avoid the comma operator - mark usage as dead - correct size of len Modified: head/usr.bin/vmstat/Makefile head/usr.bin/vmstat/vmstat.c Modified: head/usr.bin/vmstat/Makefile ============================================================================== --- head/usr.bin/vmstat/Makefile Wed Jun 13 08:50:43 2018 (r335035) +++ head/usr.bin/vmstat/Makefile Wed Jun 13 08:52:04 2018 (r335036) @@ -7,8 +7,6 @@ PROG= vmstat MAN= vmstat.8 LIBADD= devstat kvm memstat xo util -WARNS?= 6 - HAS_TESTS= SUBDIR.${MK_TESTS}+= tests Modified: head/usr.bin/vmstat/vmstat.c ============================================================================== --- head/usr.bin/vmstat/vmstat.c Wed Jun 13 08:50:43 2018 (r335035) +++ head/usr.bin/vmstat/vmstat.c Wed Jun 13 08:52:04 2018 (r335036) @@ -218,7 +218,8 @@ main(int argc, char *argv[]) { char *bp, *buf, *memf, *nlistf; float f; - int bufsize, c, len, reps, todo; + int bufsize, c, reps, todo; + size_t len; unsigned int interval; char errbuf[_POSIX2_LINE_MAX]; @@ -318,7 +319,8 @@ main(int argc, char *argv[]) retry_nlist: if (kd != NULL && (c = kvm_nlist(kd, namelist)) != 0) { if (c > 0) { - bufsize = 0, len = 0; + bufsize = 0; + len = 0; /* * 'cnt' was renamed to 'vm_cnt'. If 'vm_cnt' is not @@ -436,8 +438,11 @@ getdrivedata(char **argv) if (isdigit(**argv)) break; num_devices_specified++; - specified_devices = realloc(specified_devices, + specified_devices = reallocf(specified_devices, sizeof(char *) * num_devices_specified); + if (specified_devices == NULL) { + xo_errx(1, "%s", "reallocf (specified_devices)"); + } specified_devices[num_devices_specified - 1] = *argv; } dev_select = NULL; @@ -1206,7 +1211,7 @@ cpustats(void) total = 0; for (state = 0; state < CPUSTATES; ++state) total += cur.cp_time[state]; - if (total) + if (total > 0) lpct = 100.0 / total; else lpct = 0.0; @@ -1682,7 +1687,7 @@ kread(int nlx, void *addr, size_t size) kreado(nlx, addr, size, 0); } -static void +static void __dead2 usage(void) { xo_error("%s%s",