From owner-freebsd-arch@FreeBSD.ORG Sat Mar 2 04:10:26 2013 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CB375F9F for ; Sat, 2 Mar 2013 04:10:26 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 4612B859 for ; Sat, 2 Mar 2013 04:10:26 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.6/8.14.6) with ESMTP id r224AHuK040000 for ; Sat, 2 Mar 2013 06:10:17 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.0 kib.kiev.ua r224AHuK040000 Received: (from kostik@localhost) by tom.home (8.14.6/8.14.6/Submit) id r224AHJE039998 for freebsd-arch@FreeBSD.org; Sat, 2 Mar 2013 06:10:17 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 2 Mar 2013 06:10:17 +0200 From: Konstantin Belousov To: freebsd-arch@FreeBSD.org Subject: Re: return value from humanize_number Message-ID: <20130302041017.GH2930@kib.kiev.ua> References: <20130302011833.GM55866@funkthat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="NzX0AQGjRQPusK/O" Content-Disposition: inline In-Reply-To: <20130302011833.GM55866@funkthat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home 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 04:10:26 -0000 --NzX0AQGjRQPusK/O Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 01, 2013 at 05:18:33PM -0800, John-Mark Gurney wrote: > 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.. >=20 > The problem is that isn't what the man page says: > The humanize_number() function returns the number of characters stor= ed in > buf (excluding the terminating NUL) upon success, or -1 upon failure= =2E If > HN_GETSCALE is specified, the prefix index number will be returned > instead. >=20 > It can return 21 even when len is 4, and we only store 3 characters in > buf... >=20 > 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)... I would say that the real solution is to finally make the libutil versioned and put the old version with old ABI under FBSD_1.2 version, making all the changes you consider worth it, for FBSD_1.3. --NzX0AQGjRQPusK/O Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQIcBAEBAgAGBQJRMXuoAAoJEJDCuSvBvK1Blp4P/3fJXsRSYgsQdGAgFJ47zctH hwYfjVkc3oGUxzVNXklzyF2CdzIDIWSyRJCgkzZV60eoOvs78cWI21zj7IPHyYU8 y10fWlSK3vcbB5phj5sNTd74RNPTmGOB8VUU3t0gNc9twIxSIfJzC1dWuz5Jdr0N x5PIOgAQ+xhmO4Hz65Bao2F0NhiZaMf1JBL+VssDT/Ih9xDm3OETtXsHbHx53JD9 T/PAWrqLUWo5ln7YqtTtx1UsedpiaubBb7K73Hp6Zf5XHoDz7GuFR/PpqEgLZBmT /2zW91z6342zeWNrdTRtM9nBQgqo2n03oQRofdKUkrF8ESyKUP+Zu7hzDw/unBH7 rKDqN8oee81acH3XH1bX9NWBv9As1t9grO+69sHsk5Y/AwfwRQd1h186ys1VZHoL q+mKTQkKkHs46Udk3nCZPjcsk8/q92n3/pYm/zh6qr0H7rAUUNj9LXg4+a/bhJpn xQF2m+peR8ikWARWPGam/TtzrMuq7su1tCTV+u4mgUOXg4zNR5qKqDqRp26vHyMa o2ubnW6XKLJzshPs5yhWZaRwTAIJIzGSWtdNiQZ9fYYeHN/R4HPm2crl1jaWpCz6 ig6DROcIjMxtEi/cxCRDFLldKOlm5Icz6zof+VtaNToIsDkw/8fmZWkY82aIv/ao 1AAP+10L58ng1qCt914c =m68S -----END PGP SIGNATURE----- --NzX0AQGjRQPusK/O--