SVNews r327317

NOTE: This service is experimental and subject to change! Use at your own risk!

2017-12-28 22:57:34 - r327317 by robak (robak)

Complete list of files affected by revision r327317:

(Note: At the moment, these links point to ViewVC on They are probably slow. Do not overuse.)

  History   Contents   Diff   MODIFY   /head/lib/libutil/humanize_number.3  
  History   Contents   Diff   MODIFY   /head/lib/libutil/humanize_number.c  
  History   Contents   Diff   MODIFY   /head/lib/libutil/tests/humanize_number_test.c  

Commit message:

humanize_number(3): fix math edge case in rounding large numbers

Fix for remainder overflow, when in rare cases adding remainder to divider
exceeded 1 and turned the total to 1000 in final formatting, taking up
the space for the unit character.

The fix continues the division of the original number if the above case
happens -- added the appropriate check to the for loop performing
the division. This lowers the value shown, to make it fit into the buffer
space provided (1.0M for 4+1 character buffer, as used by ls).

Add test case for the reported bug and extend test program to support
providing buffer length (ls -lh uses 5, tests hard-coded 4).

PR: 224498
Submitted by: Pawel Biernacki <>
Reported by: Masachika Ishizuka <>
Reviewed by: cem, kib
Approved by: cem, kib
MFC after: 1 week
Sponsored by: Mysterious Code Ltd.
Differential Revision: D13578


Powered by Python FreeBSD support by secnetix GmbH & Co. KG

Page generated in 35 ms, 3 files printed. Current time is 2018-04-20 06:59:55. All times are in UTC/GMT.