Print sizes up to INT64_MAX in md_prthumanval().
PR: bin/125365 Approved by: trasz (mentor) MFC after: 2 weeks
This commit is contained in:
parent
b9a74f2ad5
commit
0e3ebc63e6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=202573
@ -454,14 +454,15 @@ static void
|
|||||||
md_prthumanval(char *length)
|
md_prthumanval(char *length)
|
||||||
{
|
{
|
||||||
char buf[6];
|
char buf[6];
|
||||||
uint64_t bytes;
|
uintmax_t bytes;
|
||||||
char *endptr;
|
char *endptr;
|
||||||
|
|
||||||
bytes = strtoul(length, &endptr, 10);
|
errno = 0;
|
||||||
if (bytes == (unsigned)ULONG_MAX || *endptr != '\0')
|
bytes = strtoumax(length, &endptr, 10);
|
||||||
|
if (errno != 0 || *endptr != '\0' || bytes > INT64_MAX)
|
||||||
return;
|
return;
|
||||||
humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1),
|
humanize_number(buf, sizeof(buf), (int64_t)bytes, "",
|
||||||
bytes, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
|
HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
|
||||||
(void)printf("%6s", buf);
|
(void)printf("%6s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user