summaryrefslogtreecommitdiff
path: root/e2fsck
diff options
context:
space:
mode:
authorAndreas Dilger <adilger@sun.com>2009-05-28 00:47:37 -0600
committerTheodore Ts'o <tytso@mit.edu>2009-05-28 07:59:04 -0400
commit70eabde9a581d340837c98b11d3ced324155d1ae (patch)
tree111569f0a6bfa8b5eb662fa35c4ac88158d5321a /e2fsck
parent6267ee49be64035d8a9772c3bafed18a09874fa5 (diff)
downloade2fsprogs-70eabde9a581d340837c98b11d3ced324155d1ae.tar.gz
e2fsck: use unsigned values for memory tracking stats
Use unsigned values for printing memory tracking to avoid overflows. The mallinfo() data is currently signed ints, but it might change in the future so we may as well compute/print unsigned longs. Signed-off-by: Andreas Dilger <adilger@sun.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'e2fsck')
-rw-r--r--e2fsck/util.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/e2fsck/util.c b/e2fsck/util.c
index 78c053cc..89f79081 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -330,15 +330,16 @@ void print_resource_track(const char *desc, struct resource_track *track,
printf("%s: ", desc);
#ifdef HAVE_MALLINFO
-#define kbytes(x) (((x) + 1023) / 1024)
+#define kbytes(x) (((unsigned long)(x) + 1023) / 1024)
malloc_info = mallinfo();
- printf(_("Memory used: %uk/%uk (%uk/%uk), "),
+ printf(_("Memory used: %luk/%luk (%luk/%luk), "),
kbytes(malloc_info.arena), kbytes(malloc_info.hblkhd),
kbytes(malloc_info.uordblks), kbytes(malloc_info.fordblks));
#else
- printf(_("Memory used: %u, "),
- (int) (((char *) sbrk(0)) - ((char *) track->brk_start)));
+ printf(_("Memory used: %lu, "),
+ (unsigned long) (((char *) sbrk(0)) -
+ ((char *) track->brk_start)));
#endif
#ifdef HAVE_GETRUSAGE
getrusage(RUSAGE_SELF, &r);