diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-02-01 10:17:53 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-02-01 10:17:53 +0100 |
commit | dcea714680fd6836380ea2b190e3b61b8323ab22 (patch) | |
tree | ef276d2b3e84c77fe2b8c85a228a7fcac918efa1 | |
parent | 7613608b23211a418cfe7404dbe2fcb3ee8b0cd7 (diff) |
kernel: fix pointer truncation in xspanalloc(), fix format prints
-rw-r--r-- | sys/src/9/port/xalloc.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/src/9/port/xalloc.c b/sys/src/9/port/xalloc.c index ab6be9b34..b677b252b 100644 --- a/sys/src/9/port/xalloc.c +++ b/sys/src/9/port/xalloc.c @@ -57,6 +57,7 @@ xinit(void) upages = conf.upages; kpages = conf.npage - upages; + pm = palloc.mem; for(i=0; i<nelem(conf.mem); i++){ m = &conf.mem[i]; @@ -99,7 +100,7 @@ xspanalloc(ulong size, int align, ulong span) panic("xspanalloc: %lud %d %lux", size, align, span); if(span > 2) { - v = (a + span) & ~(span-1); + v = (a + span) & ~((uintptr)span-1); t = v - a; if(t > 0) xhole(PADDR(a), t); @@ -111,7 +112,7 @@ xspanalloc(ulong size, int align, ulong span) v = a; if(align > 1) - v = (v + align) & ~(align-1); + v = (v + align) & ~((uintptr)align-1); return (void*)v; } @@ -261,16 +262,17 @@ xsummary(void) { int i; Hole *h; + uintptr s; i = 0; for(h = xlists.flist; h; h = h->link) i++; - print("%d holes free\n", i); - i = 0; + + s = 0; for(h = xlists.table; h; h = h->link) { print("%#p %#p %p\n", h->addr, h->top, h->size); - i += h->size; + s += h->size; } - print("%d bytes free\n", i); + print("%lld bytes free\n", (vlong)s); } |