use unsigned values for memory tracking stats
PATCH 1/1 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 <[email protected]>
e2fsck/util.c +4 -4
@@ -330,15 +330,15 @@ void print_resource_track(const char *deprintf ("%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: %dk/%dk (%dk/%dk), " ), +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: %d, " ), - (int ) (((char *)sbrk (0 )) - ((char *) track->brk_start))); +printf (_ ("Memory used: %lu, " ), + (long ) (((char *)sbrk (0 )) - ((char *) track->brk_start)));#endif #ifdef HAVE_GETRUSAGE getrusage (RUSAGE_SELF , &r);
Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
Theodore Tso
AppliedQuoted 5 lines · Andreas Dilger
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 <[email protected]>
Applied, thanks
- Ted