From: Andreas Dilger Date: Thu, 28 May 2009 06:47:37 +0000 (-0600) Subject: e2fsck: use unsigned values for memory tracking stats X-Git-Tag: v1.41.6~20 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=70eabde9a581d340837c98b11d3ced324155d1ae;p=tools%2Fe2fsprogs.git 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 --- 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);