From owner-svn-src-head@freebsd.org Mon Jun 22 21:53:16 2020 Return-Path: <owner-svn-src-head@freebsd.org> Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2D43D33D1FE; Mon, 22 Jun 2020 21:53:16 +0000 (UTC) (envelope-from pstef@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49rNSr08Qtz4SvZ; Mon, 22 Jun 2020 21:53:16 +0000 (UTC) (envelope-from pstef@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1403) id E0DED19339; Mon, 22 Jun 2020 21:53:15 +0000 (UTC) Date: Mon, 22 Jun 2020 23:53:15 +0200 From: "Piotr P. Stefaniak" <pstef@freebsd.org> To: "Christian S.J. Peron" <csjp@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r358181 - head/usr.sbin/pstat Message-ID: <20200622215315.GC28243@freefall.freebsd.org> References: <202002202112.01KLCAKx000852@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <202002202112.01KLCAKx000852@repo.freebsd.org> X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current <svn-src-head.freebsd.org> List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-head>, <mailto:svn-src-head-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head/> List-Post: <mailto:svn-src-head@freebsd.org> List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help> List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-head>, <mailto:svn-src-head-request@freebsd.org?subject=subscribe> X-List-Received-Date: Mon, 22 Jun 2020 21:53:16 -0000 On 2020-02-20 21:12:10, Christian S.J. Peron wrote: >Author: csjp >Date: Thu Feb 20 21:12:10 2020 >New Revision: 358181 >URL: https://svnweb.freebsd.org/changeset/base/358181 > >Log: > - Implement -h (human readable) for the size of the underlying block disk. > Currently, the size of the swap device is unconditionally reported using > blocks, even if -h has been used. > - While here, switch to CONVERT_BLOCKS() instead of CONVERT() which will > avoid overflowing size counters (in human readable form see: r196244) > - Update the column headers to reflect that a size is being reported instead > of the block size units being used > > Before: > > $ swapinfo > Device 1K-blocks Used Avail Capacity > /dev/gpt/swapfs 1048576 0 1048576 0% In the above, the "1K-blocks" and "1048576" line up because both the header and the value have field width of hlen which is always set by getbsize(&hlen, &blocksize). In other words, the header name sets the width for the column. It is especially apparent when you compare output with BLOCKSIZE=1000000000 and BLOCKSIZE=1K. > After: > > $ swapinfo -h > Device Size Used Avail Capacity > /dev/gpt/swapfs 1.0G 0B 1.0G 0% Here the width for the header is sizeof "Size" and the width for values of the size is 8, so the header and the values don't make up a column. Since field width for all values of Size, Used, and Avail are hardcoded to 8 as well as the column headers, I think the best suggestion I can give is to change it like this: @@ -475,7 +475,7 @@ print_swap_header(void) if (humanflag) { header = SIZEHDR; - hlen = sizeof(SIZEHDR); + hlen = 8; /* as the hardcoded field width of values */ } else { header = getbsize(&hlen, &blocksize); } Although 8 seems to me a bit high. And too bad that humanize_number() is locale-agnostic. > Differential Revision: https://reviews.freebsd.org/D23758 > Reviewed by: kevans > MFC after: 3 weeks > >Modified: > head/usr.sbin/pstat/pstat.c