]> granicus.if.org Git - gc/commitdiff
Eliminate 'assigned value never used' CSA warning in min_bytes_allocd
authorIvan Maidanski <ivmai@mail.ru>
Tue, 13 Sep 2016 18:04:47 +0000 (21:04 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 13 Sep 2016 18:04:47 +0000 (21:04 +0300)
The warning was reported only if GC_ALWAYS_MULTITHREADED.

* alloc.c (min_bytes_allocd): Assign stack_size value for the
single-threaded case only if GC_need_to_lock is false.

alloc.c

diff --git a/alloc.c b/alloc.c
index 41e4a8044d1b41550ce494c4f825da964152d4e3..e9de9113da5ed29173deab6559b1535d13f4a6f6 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -202,15 +202,7 @@ GC_API GC_stop_func GC_CALL GC_get_stop_func(void)
 static word min_bytes_allocd(void)
 {
     word result;
-#   ifdef STACK_NOT_SCANNED
-      word stack_size = 0;
-#   elif defined(STACK_GROWS_UP)
-      word stack_size = GC_approx_sp() - GC_stackbottom;
-            /* GC_stackbottom is used only for a single-threaded case.  */
-#   else
-      word stack_size = GC_stackbottom - GC_approx_sp();
-#   endif
-
+    word stack_size;
     word total_root_size;       /* includes double stack size,  */
                                 /* since the stack is expensive */
                                 /* to scan.                     */
@@ -226,8 +218,17 @@ static word min_bytes_allocd(void)
           GC_log_printf("Total stacks size: %lu\n",
                         (unsigned long)stack_size);
 #       endif
-      }
+      } else
 #   endif
+    /* else*/ {
+#     ifdef STACK_NOT_SCANNED
+        stack_size = 0;
+#     elif defined(STACK_GROWS_UP)
+        stack_size = GC_approx_sp() - GC_stackbottom;
+#     else
+        stack_size = GC_stackbottom - GC_approx_sp();
+#     endif
+    }
 
     total_root_size = 2 * stack_size + GC_root_size;
     scan_size = 2 * GC_composite_in_use + GC_atomic_in_use / 4