Change all `map_handle_err(map_free())` conditionals to `UNLIKELY` (`ifU()`), as it is unlikely an unmap will fail on a map that has already been established successfully.

Fortune for naka's current commit: Small blessing − 小吉
master
Avril 3 years ago
parent 037a234953
commit 7fd570ff6f
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -114,7 +114,7 @@ static int map_haystacks(const char* const * h, map_t maps[pOUT])
maps-=1; maps-=1;
ERROR("Failed to map file `%s', rolling back %lu maps. (erp: %p, prev: %p)", path, d, c, maps); ERROR("Failed to map file `%s', rolling back %lu maps. (erp: %p, prev: %p)", path, d, c, maps);
while( d --> 0 ) while( d --> 0 )
if(!map_handle_err(map_free(* (--maps)))) WARN("Failed to free map at %p (in %lu unwind)", maps, d); ifU(!map_handle_err(map_free(* (--maps)))) WARN("Failed to free map at %p (in %lu unwind)", maps, d);
return 0; return 0;
} }
d+=1; d+=1;
@ -151,7 +151,7 @@ inv_args:
TRACE("Attempting to map %lu haystacks", hsn); TRACE("Attempting to map %lu haystacks", hsn);
if(!map_haystacks((const char**)(argv+1), haystacks)) { if(!map_haystacks((const char**)(argv+1), haystacks)) {
// Unmap needle before return. // Unmap needle before return.
if(!map_handle_err(map_free(needle))) WARN("Failed to unmap needle before exiting after failed haystack maps"); ifU(!map_handle_err(map_free(needle))) WARN("Failed to unmap needle before exiting after failed haystack maps");
return PROG_RET_MAP_HAYSTACK_FAILED; return PROG_RET_MAP_HAYSTACK_FAILED;
} }
@ -177,11 +177,11 @@ inv_args:
for(int i=0;i<(int)hsn;i++) { for(int i=0;i<(int)hsn;i++) {
INFO("Unmapping haystack haystack file `%s' (#%d) (map addr %p)", argv[i+1], i+1, haystacks+i); INFO("Unmapping haystack haystack file `%s' (#%d) (map addr %p)", argv[i+1], i+1, haystacks+i);
if(!map_handle_err(map_free(haystacks[i]))) m_rval = !m_rval ? PROG_RET_UNMAP_HAYSTACK_N_FAILED(i+1) : m_rval; ifU(!map_handle_err(map_free(haystacks[i]))) m_rval = !m_rval ? PROG_RET_UNMAP_HAYSTACK_N_FAILED(i+1) : m_rval;
} }
TRACE("Unmap haystacks ended with main rval: %d", m_rval); TRACE("Unmap haystacks ended with main rval: %d", m_rval);
INFO("Unmapping needle file `%s'", *argv); INFO("Unmapping needle file `%s'", *argv);
if(!map_handle_err(map_free(needle))) m_rval = !m_rval ? PROG_RET_UNMAP_NEEDLE_FAILED : m_rval; ifU(!map_handle_err(map_free(needle))) m_rval = !m_rval ? PROG_RET_UNMAP_NEEDLE_FAILED : m_rval;
TRACE("main end: rval %d", m_rval); TRACE("main end: rval %d", m_rval);
return m_rval; return m_rval;
} }

Loading…
Cancel
Save