[PATCH 1/7] use long for all mem stats

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The 32bit 4G limit is not so easily reached but still
it's easy to flirt with 500M+, even with a moderatly big
program.

Avoid any possible overflow and use unsigned long as
they cost nothing here.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 allocate.c | 2 +-
 allocate.h | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/allocate.c b/allocate.c
index daa4ac247..0cc556307 100644
--- a/allocate.c
+++ b/allocate.c
@@ -120,7 +120,7 @@ void *allocate(struct allocator_struct *desc, unsigned int size)
 
 void show_allocations(struct allocator_struct *x)
 {
-	fprintf(stderr, "%s: %d allocations, %d bytes (%d total bytes, "
+	fprintf(stderr, "%s: %d allocations, %lu bytes (%lu total bytes, "
 			"%6.2f%% usage, %6.2f average size)\n",
 		x->name, x->allocations, x->useful_bytes, x->total_bytes,
 		100 * (double) x->useful_bytes / x->total_bytes,
diff --git a/allocate.h b/allocate.h
index 64bb6dd64..cbddc2aa7 100644
--- a/allocate.h
+++ b/allocate.h
@@ -14,7 +14,8 @@ struct allocator_struct {
 	unsigned int chunking;
 	void *freelist;
 	/* statistics */
-	unsigned int allocations, total_bytes, useful_bytes;
+	unsigned int allocations;
+	unsigned long total_bytes, useful_bytes;
 };
 
 struct allocator_stats {
-- 
2.13.0

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



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux