Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Dec 2007 13:22:09 GMT
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/118461: humanize_number(3) incorrectly formats values from 1048051712 to 1048575999 as "1000".
Message-ID:  <200712061322.lB6DM9s7018332@www.freebsd.org>
Resent-Message-ID: <200712061330.lB6DU1ss013445@freefall.freebsd.org>

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

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



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