]> granicus.if.org Git - gc/commitdiff
Turn some unreachable return statements into reachable (to suppress
authorIvan Maidanski <ivmai@mail.ru>
Mon, 23 Jan 2012 04:03:10 +0000 (08:03 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 23 Jan 2012 11:59:12 +0000 (15:59 +0400)
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.

dbg_mlc.c
mark.c
os_dep.c
win32_threads.c

index 1eb25eb50834c364cf71b79bcb8c5bb318d3ef88..c6b76fe523f14903c83c2571dce9625e2c8a43ee 100644 (file)
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
   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();
         /* 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. */
diff --git a/mark.c b/mark.c
index 858cf1fe8b16d3e2ff0ce9f7c8e3f35134c1cbfc..4d70b5964bf3afdad0a69a6a654eb554372d7ef2 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -325,7 +325,7 @@ static void alloc_mark_stack(size_t);
 {
     switch(GC_mark_state) {
         case MS_NONE:
-            return(FALSE);
+            break;
 
         case MS_PUSH_RESCUERS:
             if (GC_mark_stack_top
@@ -335,7 +335,7 @@ static void alloc_mark_stack(size_t);
                 /* in the future.                                        */
                 GC_mark_stack_too_small = TRUE;
                 MARK_FROM_MARK_STACK();
-                return(FALSE);
+                break;
             } else {
                 scan_ptr = GC_push_next_marked_dirty(scan_ptr);
                 if (scan_ptr == 0) {
@@ -350,7 +350,7 @@ static void alloc_mark_stack(size_t);
                     }
                 }
             }
-            return(FALSE);
+            break;
 
         case MS_PUSH_UNCOLLECTABLE:
             if (GC_mark_stack_top
@@ -361,7 +361,7 @@ static void alloc_mark_stack(size_t);
                   if (GC_parallel) GC_mark_stack_too_small = TRUE;
 #               endif
                 MARK_FROM_MARK_STACK();
-                return(FALSE);
+                break;
             } else {
                 scan_ptr = GC_push_next_marked_uncollectable(scan_ptr);
                 if (scan_ptr == 0) {
@@ -372,7 +372,7 @@ static void alloc_mark_stack(size_t);
                     }
                 }
             }
-            return(FALSE);
+            break;
 
         case MS_ROOTS_PUSHED:
 #           ifdef PARALLEL_MARK
@@ -394,14 +394,13 @@ static void alloc_mark_stack(size_t);
                   if (GC_mark_state == MS_ROOTS_PUSHED) {
                     GC_mark_state = MS_NONE;
                     return(TRUE);
-                  } else {
-                    return(FALSE);
                   }
+                  break;
                 }
 #           endif
             if (GC_mark_stack_top >= GC_mark_stack) {
                 MARK_FROM_MARK_STACK();
-                return(FALSE);
+                break;
             } else {
                 GC_mark_state = MS_NONE;
                 if (GC_mark_stack_too_small) {
@@ -414,11 +413,11 @@ static void alloc_mark_stack(size_t);
         case MS_PARTIALLY_INVALID:
             if (!GC_objects_are_marked) {
                 GC_mark_state = MS_PUSH_UNCOLLECTABLE;
-                return(FALSE);
+                break;
             }
             if (GC_mark_stack_top >= GC_mark_stack) {
                 MARK_FROM_MARK_STACK();
-                return(FALSE);
+                break;
             }
             if (scan_ptr == 0 && GC_mark_state == MS_INVALID) {
                 /* About to start a heap scan for marked objects. */
@@ -436,11 +435,12 @@ static void alloc_mark_stack(size_t);
                     GC_mark_state = MS_ROOTS_PUSHED;
                 }
             }
-            return(FALSE);
+            break;
+
         default:
             ABORT("GC_mark_some: bad state");
-            return(FALSE);
     }
+    return(FALSE);
 }
 
 #ifdef WRAP_MARK_SOME
index 8bc10991ffe627dfb83273f6698ea2e18809a1da..fbd9b81f8f40e54a82a32de407a02f64c6e60332 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -3997,6 +3997,8 @@ STATIC void *GC_mprotect_thread(void *arg)
   } msg;
   mach_msg_id_t id;
 
+  if ((word)arg == (word)-1) return 0; /* to make compiler happy */
+
 # if defined(THREADS) && !defined(GC_NO_THREADS_DISCOVERY)
     GC_darwin_register_mach_handler_thread(mach_thread_self());
 # endif
@@ -4062,8 +4064,6 @@ STATIC void *GC_mprotect_thread(void *arg)
           }
     } /* switch */
   } /* for(;;) */
-    /* NOT REACHED */
-  return NULL;
 }
 
 /* All this SIGBUS code shouldn't be necessary. All protection faults should
index 7cc0dcfa1ee202d8fb80e22b2f2e23a1cea23db2..66ae019e27d0c62a44063ea2548da5776a639e05 100644 (file)
@@ -2616,16 +2616,17 @@ GC_INNER void GC_thr_init(void)
         /* This may run with the collector uninitialized. */
         thread_id = GetCurrentThreadId();
         if (parallel_initialized && GC_main_thread != thread_id) {
-          /* Don't lock here.   */
-#         ifdef GC_ASSERTIONS
-            sb_result =
-#         endif
-              GC_get_stack_base(&sb);
-          GC_ASSERT(sb_result == GC_SUCCESS);
 #         if defined(THREAD_LOCAL_ALLOC) || defined(PARALLEL_MARK)
             ABORT("Cannot initialize thread local cache from DllMain");
+#         else
+            /* Don't lock here. */
+#           ifdef GC_ASSERTIONS
+              sb_result =
+#           endif
+                GC_get_stack_base(&sb);
+            GC_ASSERT(sb_result == GC_SUCCESS);
+            GC_register_my_thread_inner(&sb, thread_id);
 #         endif
-          GC_register_my_thread_inner(&sb, thread_id);
         } /* o.w. we already did it during GC_thr_init, called by GC_init */
         break;