From owner-svn-src-all@FreeBSD.ORG Sat Aug 22 09:09:44 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DFF4A106568B; Sat, 22 Aug 2009 09:09:44 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CFB038FC0C; Sat, 22 Aug 2009 09:09:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n7M99iAO049379; Sat, 22 Aug 2009 09:09:44 GMT (envelope-from stas@svn.freebsd.org) Received: (from stas@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n7M99iad049377; Sat, 22 Aug 2009 09:09:44 GMT (envelope-from stas@svn.freebsd.org) Message-Id: <200908220909.n7M99iad049377@svn.freebsd.org> From: Stanislav Sedov Date: Sat, 22 Aug 2009 09:09:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r196430 - stable/7/usr.sbin/pstat X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Aug 2009 09:09:45 -0000 Author: stas Date: Sat Aug 22 09:09:44 2009 New Revision: 196430 URL: http://svn.freebsd.org/changeset/base/196430 Log: - MFC r196244: - Avoid overflowing the swap size counters in human-readable mode by introducing the new CONVERT_BLOCKS macro which operates on sizes already converted to number of blocks. With this macro it is not longer needed to perform needless multiplication by blocksize just to divide on it later in CONVERT macro. Modified: stable/7/usr.sbin/pstat/ (props changed) stable/7/usr.sbin/pstat/pstat.c Modified: stable/7/usr.sbin/pstat/pstat.c ============================================================================== --- stable/7/usr.sbin/pstat/pstat.c Sat Aug 22 00:56:47 2009 (r196429) +++ stable/7/usr.sbin/pstat/pstat.c Sat Aug 22 09:09:44 2009 (r196430) @@ -479,6 +479,7 @@ getfiles(char **abuf, size_t *alen) */ #define CONVERT(v) ((int64_t)(v) * pagesize / blocksize) +#define CONVERT_BLOCKS(v) ((int64_t)(v) * pagesize) static struct kvm_swap swtot; static int nswdev; @@ -511,10 +512,10 @@ print_swap_line(const char *devname, int printf("%-15s %*jd ", devname, hlen, CONVERT(nblks)); if (humanflag) { humanize_number(usedbuf, sizeof(usedbuf), - CONVERT(blocksize * bused), "", + CONVERT_BLOCKS(bused), "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); humanize_number(availbuf, sizeof(availbuf), - CONVERT(blocksize * bavail), "", + CONVERT_BLOCKS(bavail), "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); printf("%8s %8s %5.0f%%\n", usedbuf, availbuf, bpercent); } else {