From: Ben Gras Date: Tue, 18 Sep 2012 13:10:59 +0000 (+0200) Subject: some coverity fixes. X-Git-Tag: v3.2.1~321 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.rndc-confgen.html?a=commitdiff_plain;h=d526f1a0db2c255ae87d7e4ce23155b42fea4671;p=minix.git some coverity fixes. --- diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index 8f9e9b8b8..2578b3200 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -95,6 +95,8 @@ void utrace(struct ut *, int); # define _MALLOC_UNLOCK() if (__isthreaded) _SPINUNLOCK(&thread_lock); #endif /* __FreeBSD__ */ +#include + #include #if defined(__NetBSD__) # define malloc_minsize 16U @@ -1030,7 +1032,7 @@ free_pages(void *ptr, size_t idx, struct pginfo *info) pf->size > malloc_cache && /* ..and the cache is full, */ pf->end == malloc_brk && /* ..and none behind us, */ malloc_brk == sbrk((intptr_t)0)) { /* ..and it's OK to do... */ - + int r; /* * Keep the cache intact. Notice that the '>' above guarantees that * the pf will always have at least one page afterwards. @@ -1038,7 +1040,8 @@ free_pages(void *ptr, size_t idx, struct pginfo *info) pf->end = (char *)pf->page + malloc_cache; pf->size = malloc_cache; - brk(pf->end); + r = brk(pf->end); + assert(r >= 0); malloc_brk = pf->end; idx = ptr2idx(pf->end); diff --git a/servers/vm/region.c b/servers/vm/region.c index 8d083aad9..9ed75d779 100644 --- a/servers/vm/region.c +++ b/servers/vm/region.c @@ -677,6 +677,7 @@ static int map_subfree(struct vir_region *region, if(start == 0 && len == region->length) full = 1; + physr_init_iter(&iter); physr_start_iter(region->phys, &iter, start, AVL_GREATER_EQUAL); while((pr = physr_get_iter(&iter))) { physr_incr_iter(&iter); @@ -981,7 +982,7 @@ int written; if(!(newpb = pb_new(ml->phys)) || !(newphysr = pb_reference(newpb, offset, region))) { printf("map_new_physblock: no memory for the ph slabs\n"); - if(newphysr) SLABFREE(newphysr); + assert(!newphysr); if(newpb) SLABFREE(newpb); r = ENOMEM; break; @@ -1715,6 +1716,7 @@ int map_unmap_region(struct vmproc *vmp, struct vir_region *r, * point to the same addresses, make them shrink by the * same amount. */ + physr_init_iter(&iter); physr_start_iter(r->phys, &iter, offset, AVL_GREATER_EQUAL); while((pr = physr_get_iter(&iter))) {