Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Mar 2013 06:10:17 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        freebsd-arch@FreeBSD.org
Subject:   Re: return value from humanize_number
Message-ID:  <20130302041017.GH2930@kib.kiev.ua>
In-Reply-To: <20130302011833.GM55866@funkthat.com>
References:  <20130302011833.GM55866@funkthat.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130302041017.GH2930>