From owner-freebsd-arch@FreeBSD.ORG Sat Mar 2 01:18:39 2013 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id ABD372BA for ; Sat, 2 Mar 2013 01:18:39 +0000 (UTC) (envelope-from jmg@h2.funkthat.com) Received: from h2.funkthat.com (gate2.funkthat.com [208.87.223.18]) by mx1.freebsd.org (Postfix) with ESMTP id 6FA24F7 for ; Sat, 2 Mar 2013 01:18:39 +0000 (UTC) Received: from h2.funkthat.com (localhost [127.0.0.1]) by h2.funkthat.com (8.14.3/8.14.3) with ESMTP id r221IXq7049309 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 1 Mar 2013 17:18:33 -0800 (PST) (envelope-from jmg@h2.funkthat.com) Received: (from jmg@localhost) by h2.funkthat.com (8.14.3/8.14.3/Submit) id r221IX3X049308 for freebsd-arch@FreeBSD.org; Fri, 1 Mar 2013 17:18:33 -0800 (PST) (envelope-from jmg) Date: Fri, 1 Mar 2013 17:18:33 -0800 From: John-Mark Gurney To: freebsd-arch@FreeBSD.org Subject: return value from humanize_number Message-ID: <20130302011833.GM55866@funkthat.com> Mail-Followup-To: freebsd-arch@FreeBSD.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD 7.2-RELEASE i386 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.2.2 (h2.funkthat.com [127.0.0.1]); Fri, 01 Mar 2013 17:18:33 -0800 (PST) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Mar 2013 01:18:39 -0000 I picked up the work to fix up humanize_number, but now I have a problem.. Currently, if a number is too big to fit, we write what we can, and return the number of bytes we would of written if len allowed us.. The problem is that isn't what the man page says: The humanize_number() function returns the number of characters stored in buf (excluding the terminating NUL) upon success, or -1 upon failure. If HN_GETSCALE is specified, the prefix index number will be returned instead. It can return 21 even when len is 4, and we only store 3 characters in buf... So, the question is, do we fix the code to return an error if we attempt to write more than len - 1 characters, or do we change the man page to say that we return what we would like to have written, but only write out what we can (snprintf style, which is what we use)... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."