misc/118461: humanize_number(3) incorrectly formats values from 1048051712 to 1048575999 as "1000".

Edward Tomasz Napierala trasz at FreeBSD.org
Thu Dec 6 05:30:01 PST 2007


>Number:         118461
>Category:       misc
>Synopsis:       humanize_number(3) incorrectly formats values from 1048051712 to 1048575999  as "1000".
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 06 13:30:00 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Edward Tomasz Napierala
>Release:        7.0-BETA3
>Organization:
>Environment:
FreeBSD traszkan.ds7 7.0-BETA4 FreeBSD 7.0-BETA4 #0: Thu Dec  6 10:04:38 CET 2007     trasz at traszkan.ds7:/usr/obj/site1/trasz/src/sys/TRASZKAN7  i386
>Description:
For values in range <1048051712, 1048575999>, humanize number incorrectly formats them as "1000" - the "M" prefix is missing.

This affects "df -h" output.  (That's how I found it.)

>How-To-Repeat:
#include <stdio.h>
#include <string.h>
#include <sys/param.h>
#include <libutil.h>

#define START 1024*1024*999
#define END 1024*1024*1001

int main(void)
{
        char buf[6];
        int64_t bytes;

        for (bytes = START; bytes < END; bytes++) {
                humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1), bytes, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);

                printf("%s\n", buf);

                if (strcmp(buf, "1000") == 0)
                        printf("Here, it's %ld\n", (long)bytes);
        }

        return 0;
}

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list