diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2012-01-23 08:03:10 +0400 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2012-01-23 15:59:12 +0400 |
commit | f23154f0a8f02b9519632e4341635f7c5e866da0 (patch) | |
tree | 3a42df39df1ebdb9f5b279ca82960ce1af8698cd /dbg_mlc.c | |
parent | 88e029199608ed563aa3a6ba6f14988f486efced (diff) | |
download | bdwgc-f23154f0a8f02b9519632e4341635f7c5e866da0.tar.gz |
Turn some unreachable return statements into reachable (to suppress
compiler warning)
* dbg_mlc.c (GC_generate_random_heap_address): Change function
algorithm structure to have reachable return statement at function end.
* mark.c (GC_mark_some): Likewise.
* os_dep.c (GC_mprotect_thread): Place a dummy return statement (which
uses function "arg"); remove unreachable return statement.
* win32_threads.c (GC_DllMain): Place GC_ASSERT before
GC_get_stack_base.
Diffstat (limited to 'dbg_mlc.c')
-rw-r--r-- | dbg_mlc.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -142,7 +142,9 @@ GC_API void * GC_CALL GC_generate_random_heap_address(void) { size_t i; + size_t size; word heap_offset = RANDOM(); + if (GC_heapsize > RAND_MAX) { heap_offset *= RAND_MAX; heap_offset += RANDOM(); @@ -151,17 +153,18 @@ /* This doesn't yield a uniform distribution, especially if */ /* e.g. RAND_MAX = 1.5* GC_heapsize. But for typical cases, */ /* it's not too bad. */ - for (i = 0; i < GC_n_heap_sects; ++ i) { - size_t size = GC_heap_sects[i].hs_bytes; + for (i = 0;; ++i) { + if (i >= GC_n_heap_sects) + ABORT("GC_generate_random_heap_address: size inconsistency"); + + size = GC_heap_sects[i].hs_bytes; if (heap_offset < size) { - return GC_heap_sects[i].hs_start + heap_offset; + break; } else { heap_offset -= size; } } - ABORT("GC_generate_random_heap_address: size inconsistency"); - /*NOTREACHED*/ - return 0; + return GC_heap_sects[i].hs_start + heap_offset; } /* Generate a random address inside a valid marked heap object. */ |