summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjh <jh@FreeBSD.org>2010-01-18 14:07:41 +0000
committerjh <jh@FreeBSD.org>2010-01-18 14:07:41 +0000
commit9e83e75eb5ad2b3e144a8f919ef66f129d4fd3cb (patch)
treefb49fbc6e1f99ded2ac82f5df8f485a912336343
parentc3fd255426edd16af1593a5ff8125bdefa328e56 (diff)
downloadFreeBSD-src-9e83e75eb5ad2b3e144a8f919ef66f129d4fd3cb.zip
FreeBSD-src-9e83e75eb5ad2b3e144a8f919ef66f129d4fd3cb.tar.gz
Print sizes up to INT64_MAX in md_prthumanval().
PR: bin/125365 Approved by: trasz (mentor) MFC after: 2 weeks
-rw-r--r--sbin/mdconfig/mdconfig.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c
index 107a259..ec667c5 100644
--- a/sbin/mdconfig/mdconfig.c
+++ b/sbin/mdconfig/mdconfig.c
@@ -454,14 +454,15 @@ static void
md_prthumanval(char *length)
{
char buf[6];
- uint64_t bytes;
+ uintmax_t bytes;
char *endptr;
- bytes = strtoul(length, &endptr, 10);
- if (bytes == (unsigned)ULONG_MAX || *endptr != '\0')
+ errno = 0;
+ bytes = strtoumax(length, &endptr, 10);
+ if (errno != 0 || *endptr != '\0' || bytes > INT64_MAX)
return;
- humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1),
- bytes, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
+ humanize_number(buf, sizeof(buf), (int64_t)bytes, "",
+ HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
(void)printf("%6s", buf);
}
OpenPOWER on IntegriCloud