From patchwork Thu May 28 06:47:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Dilger X-Patchwork-Id: 27776 Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 9D7E3B6F44 for ; Thu, 28 May 2009 16:47:59 +1000 (EST) Received: by ozlabs.org (Postfix) id 89A34DDFB0; Thu, 28 May 2009 16:47:59 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 23ADDDDF36 for ; Thu, 28 May 2009 16:47:58 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750907AbZE1Gry (ORCPT ); Thu, 28 May 2009 02:47:54 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750951AbZE1Gry (ORCPT ); Thu, 28 May 2009 02:47:54 -0400 Received: from sca-es-mail-2.Sun.COM ([192.18.43.133]:36135 "EHLO sca-es-mail-2.sun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750907AbZE1Grx (ORCPT ); Thu, 28 May 2009 02:47:53 -0400 Received: from fe-sfbay-09.sun.com ([192.18.43.129]) by sca-es-mail-2.sun.com (8.13.7+Sun/8.12.9) with ESMTP id n4S6lnEs026429 for ; Wed, 27 May 2009 23:47:51 -0700 (PDT) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-disposition: inline Content-type: text/plain; CHARSET=US-ASCII Received: from conversion-daemon.fe-sfbay-09.sun.com by fe-sfbay-09.sun.com (Sun Java(tm) System Messaging Server 7u2-7.02 64bit (built Apr 16 2009)) id <0KKC00C00D7YJV00@fe-sfbay-09.sun.com> for linux-ext4@vger.kernel.org; Wed, 27 May 2009 23:47:49 -0700 (PDT) Received: from webber.adilger.int ([unknown] [68.147.209.238]) by fe-sfbay-09.sun.com (Sun Java(tm) System Messaging Server 7u2-7.02 64bit (built Apr 16 2009)) with ESMTPSA id <0KKC00KG9DJNTUE0@fe-sfbay-09.sun.com>; Wed, 27 May 2009 23:47:49 -0700 (PDT) Date: Thu, 28 May 2009 00:47:37 -0600 From: Andreas Dilger Subject: [PATCH] use unsigned values for memory tracking stats To: "Theodore Ts'o" Cc: linux-ext4@vger.kernel.org Message-id: <20090528064737.GF3218@webber.adilger.int> X-GPG-Key: 1024D/0D35BED6 X-GPG-Fingerprint: 7A37 5D79 BF1B CECA D44F 8A29 A488 39F5 0D35 BED6 User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 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 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);