From 70eabde9a581d340837c98b11d3ced324155d1ae Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Thu, 28 May 2009 00:47:37 -0600 Subject: [PATCH] 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 Signed-off-by: Theodore Ts'o --- e2fsck/util.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/e2fsck/util.c b/e2fsck/util.c index 78c053c..89f7908 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); -- 1.8.3.1