NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

PR/54053 CVS commit: src/lib/libc/gen

The following reply was made to PR lib/54053; it has been noted by GNATS.

From: "Robert Elz" <>
Subject: PR/54053 CVS commit: src/lib/libc/gen
Date: Mon, 11 Mar 2019 15:10:52 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Mon Mar 11 15:10:51 UTC 2019
 Modified Files:
 	src/lib/libc/gen: humanize_number.3 humanize_number.c
 Log Message:
 PR lib/54053
 When auto scaling, and the buffer is bigger than big enough
 for the biggest possible number, don't try and calculate
 the max value that will fit in the buffer - that calc
 will overflow (guaranteed) and is useless, the value
 we're formatting cannot possibly be bigger.  So simply
 use the unscaled value (the raw number).
 While here, also avoid returning values that are larger
 than the buffer len ... while it would be nice to be able
 to find out how big the buffer should be so the data will
 fit, the interface doesn't really allow that (the buffer
 length passed in controls the scaling - at least when
 auto scaling) and the code already does "return -1" when
 it detects the buffer length is too small, even before
 it works out how much would have been needed.  So, rather
 than returning a value > len (while truncating the result
 to fit in len ... all courtesy of snprintf()) return -1
 in this case as well.
 Also, allow suffix==NULL (meaning "") - there's no reason
 not to, and requiring users to pass in an explicit "" is
 not useful.
 To generate a diff of this commit:
 cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gen/humanize_number.3
 cvs rdiff -u -r1.17 -r1.18 src/lib/libc/gen/humanize_number.c
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

Home | Main Index | Thread Index | Old Index