From nobody@FreeBSD.org  Thu Dec  6 13:22:13 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A73FB16A468
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  6 Dec 2007 13:22:13 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 9676A13C4E8
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  6 Dec 2007 13:22:13 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id lB6DM9dK018333
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 6 Dec 2007 13:22:09 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id lB6DM9s7018332;
	Thu, 6 Dec 2007 13:22:09 GMT
	(envelope-from nobody)
Message-Id: <200712061322.lB6DM9s7018332@www.freebsd.org>
Date: Thu, 6 Dec 2007 13:22:09 GMT
From: Edward Tomasz Napierala <trasz@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: humanize_number(3) incorrectly formats values from 1048051712 to 1048575999  as "1000".
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         118461
>Category:       kern
>Synopsis:       [libutil] [patch] humanize_number(3) incorrectly formats values from 1048051712 to 1048575999  as "1000".
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    antoine
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 06 13:30:00 UTC 2007
>Closed-Date:    Sun Apr 20 16:48:32 UTC 2008
>Last-Modified:  Sun Apr 20 16:48:32 UTC 2008
>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:

From: Ricardo Nabinger Sanchez <rnsanchez@wait4.org>
To: Edward Tomasz Napierala <trasz@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/118461: humanize_number(3) incorrectly formats values from
 1048051712 to 1048575999 as "1000".
Date: Thu, 6 Dec 2007 11:46:47 -0200

 You may want to take a look at 102694, which has additional info on this
 matter (http://www.freebsd.org/cgi/query-pr.cgi?pr=102694).
 
 -- 
 Ricardo Nabinger Sanchez                   rnsanchez@wait4.org
 Powered by FreeBSD                  http://rnsanchez.wait4.org
 
   "Left to themselves, things tend to go from bad to worse."

From: Edward Tomasz Napierala <trasz@FreeBSD.org>
To: Ricardo Nabinger Sanchez <rnsanchez@wait4.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/118461: humanize_number(3) incorrectly formats values
	from 1048051712 to 1048575999 as "1000".
Date: Thu, 6 Dec 2007 15:55:09 +0100

 NetBSD seems to have fixed this already:
 
 http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/gen/humanize_number.c.diff?r1=1.11&r2=1.12
 
 -- 
 If you cut off my head, what would I say?  Me and my head, or me and my body?
 
Responsible-Changed-From-To: freebsd-bugs->antoine 
Responsible-Changed-By: antoine 
Responsible-Changed-When: Sat Mar 1 08:44:44 UTC 2008 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=118461 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/118461: commit references a PR
Date: Sat,  8 Mar 2008 21:56:06 +0000 (UTC)

 antoine     2008-03-08 21:55:59 UTC
 
   FreeBSD src repository
 
   Modified files:
     lib/libutil          humanize_number.c 
   Log:
   Merge changes from NetBSD on humanize_number.c, 1.8 -> 1.13
   Significant changes:
   - rev. 1.11: Use PRId64 instead of a cast to long long and %lld to print
   an int64_t.
   - rev. 1.12: Fix a bug that humanize_number() produces "1000" where it
   should be "1.0G" or "1.0M".  The bug reported by Greg Troxel.
   
   PR:             118461
   PR:             102694
   Approved by:    rwatson (mentor)
   Obtained from:  NetBSD
   MFC after:      1 month
   
   Revision  Changes    Path
   1.3       +10 -5     src/lib/libutil/humanize_number.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: antoine 
State-Changed-When: Sat Mar 8 22:04:28 UTC 2008 
State-Changed-Why:  
patched in revision 1.3 of src/lib/libutil/humanize_number.c 

http://www.freebsd.org/cgi/query-pr.cgi?pr=118461 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/118461: commit references a PR
Date: Sun, 20 Apr 2008 16:29:05 +0000 (UTC)

 antoine     2008-04-20 16:29:01 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_7)
     lib/libutil          humanize_number.c 
   Log:
   MFC to RELENG_7:
     Merge changes from NetBSD on humanize_number.c, 1.8 -> 1.13
     Significant changes:
     - rev. 1.11: Use PRId64 instead of a cast to long long and %lld to print
     an int64_t.
     - rev. 1.12: Fix a bug that humanize_number() produces "1000" where it
     should be "1.0G" or "1.0M".  The bug reported by Greg Troxel.
   
     PR:             118461
     PR:             102694
     Approved by:    rwatson (mentor)
     Obtained from:  NetBSD
     MFC after:      1 month
   
   Revision  Changes    Path
   1.2.10.1  +10 -5     src/lib/libutil/humanize_number.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/118461: commit references a PR
Date: Sun, 20 Apr 2008 16:32:24 +0000 (UTC)

 antoine     2008-04-20 16:32:20 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     lib/libutil          humanize_number.c 
   Log:
   MFC to RELENG_6:
     Merge changes from NetBSD on humanize_number.c, 1.8 -> 1.13
     Significant changes:
     - rev. 1.11: Use PRId64 instead of a cast to long long and %lld to print
     an int64_t.
     - rev. 1.12: Fix a bug that humanize_number() produces "1000" where it
     should be "1.0G" or "1.0M".  The bug reported by Greg Troxel.
   
     PR:             118461
     PR:             102694
     Approved by:    rwatson (mentor)
     Obtained from:  NetBSD
     MFC after:      1 month
   
   Revision  Changes    Path
   1.2.2.1   +10 -5     src/lib/libutil/humanize_number.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: antoine 
State-Changed-When: Sun Apr 20 16:47:56 UTC 2008 
State-Changed-Why:  
Fixed in HEAD, RELENG_7 and RELENG_6. 
Thanks for the report! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=118461 
>Unformatted:
