diff mbox

use unsigned values for memory tracking stats

Message ID 20090528064737.GF3218@webber.adilger.int
State Accepted, archived
Headers show

Commit Message

Andreas Dilger May 28, 2009, 6:47 a.m. UTC
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>


Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Theodore Ts'o May 28, 2009, 11:57 a.m. UTC | #1
On Thu, May 28, 2009 at 12:47:37AM -0600, Andreas Dilger wrote:
> 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>

Applied, thanks

						- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

Index: e2fsprogs-cfs/e2fsck/util.c
===================================================================
--- e2fsprogs-cfs.orig/e2fsck/util.c
+++ e2fsprogs-cfs/e2fsck/util.c
@@ -330,15 +330,15 @@  void print_resource_track(const char *de
 		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: %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);