return value from humanize_number
Konstantin Belousov
kostikbel at gmail.com
Sat Mar 2 04:10:26 UTC 2013
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..
>
> 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)...
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20130302/b015e442/attachment.sig>
More information about the freebsd-arch
mailing list