[hackers] [sbase] humansize: Use uintmax_t for size || Dionysis Grigoropoulos
commit 2d6cde186235f571ef954c8051eacdbbf7105c6e
Author: Dionysis Grigoropoulos <info_AT_erethon.com>
Date: Tue Apr 28 12:23:25 2015 +0300
humansize: Use uintmax_t for size
du(1) breaks on 32-bit size_t for files greater than 4G.
diff --git a/libutil/human.c b/libutil/human.c
index eb5d0b7..91679bc 100644
--- a/libutil/human.c
+++ b/libutil/human.c
_AT_@ -1,11 +1,12 @@
/* See LICENSE file for copyright and license details. */
#include <stdio.h>
#include <string.h>
+#include <stdint.h>
#include "../util.h"
char *
-humansize(size_t n)
+humansize(uintmax_t n)
{
static char buf[16];
const char postfixes[] = "BKMGTPE";
_AT_@ -16,7 +17,7 @@ humansize(size_t n)
size /= 1024;
if (!i)
- snprintf(buf, sizeof(buf), "%zu", n);
+ snprintf(buf, sizeof(buf), "%ju", n);
else
snprintf(buf, sizeof(buf), "%.1f%c", size, postfixes[i]);
diff --git a/util.h b/util.h
index bd8ddc0..4784fa2 100644
--- a/util.h
+++ b/util.h
_AT_@ -66,7 +66,7 @@ int eregcomp(regex_t *, const char *, int);
void enmasse(int, char **, int (*)(const char *, const char *, int));
void fnck(const char *, const char *, int (*)(const char *, const char *, int), int);
mode_t getumask(void);
-char *humansize(size_t);
+char *humansize(uintmax_t);
mode_t parsemode(const char *, mode_t, mode_t);
void putword(FILE *, const char *);
#undef strtonum
Received on Tue Apr 28 2015 - 12:37:06 CEST
This archive was generated by hypermail 2.3.0
: Tue Apr 28 2015 - 12:48:12 CEST