| Summary: | [libutil] [patch] humanize_number(3) incorrectly formats values from 1048051712 to 1048575999 as "1000". | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Edward Tomasz Napierala <trasz> |
| Component: | kern | Assignee: | Antoine Brodin <antoine> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 7.0-BETA3 | ||
| Hardware: | Any | ||
| OS: | Any | ||
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." 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 Take. 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 patched in revision 1.3 of src/lib/libutil/humanize_number.c 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"
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 Fixed in HEAD, RELENG_7 and RELENG_6. Thanks for the report! |
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; }