some coverity fixes.

This commit is contained in:
Ben Gras 2012-09-18 15:10:59 +02:00
parent ddf1981004
commit d526f1a0db
2 changed files with 8 additions and 3 deletions

View file

@ -95,6 +95,8 @@ void utrace(struct ut *, int);
# define _MALLOC_UNLOCK() if (__isthreaded) _SPINUNLOCK(&thread_lock);
#endif /* __FreeBSD__ */
#include <assert.h>
#include <sys/types.h>
#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);

View file

@ -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))) {