From owner-svn-src-all@FreeBSD.ORG Sun Aug 22 21:21:39 2010 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 AF0431065697; Sun, 22 Aug 2010 21:21:39 +0000 (UTC) (envelope-from dimitry@andric.com) Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net [IPv6:2001:7b8:2ff:146::2]) by mx1.freebsd.org (Postfix) with ESMTP id 18BED8FC08; Sun, 22 Aug 2010 21:21:39 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:adf2:d748:7256:efad] (unknown [IPv6:2001:7b8:3a7:0:adf2:d748:7256:efad]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 477A65C59; Sun, 22 Aug 2010 23:21:37 +0200 (CEST) Message-ID: <4C7194E6.6080708@andric.com> Date: Sun, 22 Aug 2010 23:21:42 +0200 From: Dimitry Andric User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.9pre) Gecko/20100814 Lanikai/3.1.3pre MIME-Version: 1.0 To: =?UTF-8?B?RGFnLUVybGluZyBTbcO4cmdyYXY=?= References: <201008141434.o7EEYaSA030301@svn.freebsd.org> <20100815205724.00007e0f@unknown> <86wrrraqk8.fsf@ds4.des.no> In-Reply-To: <86wrrraqk8.fsf@ds4.des.no> Content-Type: multipart/mixed; boundary="------------040200060404010907090506" Cc: Bruce Cran , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r211304 - head/lib/libutil 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: Sun, 22 Aug 2010 21:21:39 -0000 This is a multi-part message in MIME format. --------------040200060404010907090506 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 2010-08-16 10:51, Dag-Erling Sm=C3=B8rgrav wrote: > Bruce Cran writes: >> Somewhat related, there are overflow bugs in humanize_number - for >> example df(1) fails to display space from a 100PB filesystem >> correctly. >=20 > Patch? :) Attached. This makes humanize_number() work properly for all possible int64_t values. It has one significant behaviour change, though: with the original version of humanize_number(), if you used a fixed scale parameter, and the number was larger than the buffer could contain, it would simply stomp over the end of the buffer. With this fix, it will return -1 instead. I hope you agree that is better. :) --------------040200060404010907090506 Content-Type: text/plain; name="humanize-overflow-fix.diff" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="humanize-overflow-fix.diff" ZGlmZiAtLWdpdCBhL2xpYi9saWJ1dGlsL2h1bWFuaXplX251bWJlci5jIGIvbGliL2xpYnV0 aWwvaHVtYW5pemVfbnVtYmVyLmMKaW5kZXggZGU5ODU4Ny4uYTMwNDEzNyAxMDA2NDQKLS0t IGEvbGliL2xpYnV0aWwvaHVtYW5pemVfbnVtYmVyLmMKKysrIGIvbGliL2xpYnV0aWwvaHVt YW5pemVfbnVtYmVyLmMKQEAgLTQyLDEzICs0MiwzNCBAQCBfX0ZCU0RJRCgiJEZyZWVCU0Qk Iik7CiAjaW5jbHVkZSA8bG9jYWxlLmg+CiAjaW5jbHVkZSA8bGlidXRpbC5oPgogCitzdGF0 aWMgaW5saW5lIHZvaWQKK2RpdmlkZShpbnQ2NF90IG51bSwgaW50NjRfdCBkZW4sIGludDY0 X3QgKnF1b3RwLCBpbnQ2NF90ICpxdW90cnAsIGludCAqZnJhY3JwKQoreworCWludCBmcmFj OworCisJaWYgKGRlbiA9PSAxKSB7CisJCSpxdW90cCA9ICpxdW90cnAgPSBudW07CisJCSpm cmFjcnAgPSAwOworCX0gZWxzZSB7CisJCSpxdW90cCA9ICpxdW90cnAgPSBudW0gLyBkZW47 CisJCWZyYWMgPSAoNSAqIChudW0gJSBkZW4pKSA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