]> granicus.if.org Git - gc/commitdiff
Fix 'variable assigned a value that is never used' cppcheck style warnings
authorIvan Maidanski <ivmai@mail.ru>
Mon, 17 Oct 2016 22:42:22 +0000 (01:42 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 17 Oct 2016 22:42:22 +0000 (01:42 +0300)
* dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Remove
datastart local variable.
* extra/AmigaOS.c [GC_AMIGA_DS] (GC_register_data_segments): Remove
num local variable.
* extra/MacOS.c (firstTime): Remove.
* extra/MacOS.c (GC_MacTemporaryNewPtr): Do not define firstTime if
SHARED_LIBRARY_BUILD.
* extra/MacOS.c (GC_MacFreeTemporaryMemory): Do not define (and update)
totalMemoryUsed if SHARED_LIBRARY_BUILD.
* extra/msvc_dbg.c (GetDescriptionFromAddress): Do not assign size
variable when its value no longer used.

dyn_load.c
extra/AmigaOS.c
extra/MacOS.c
extra/msvc_dbg.c

index be5b14f6a65b8e74c1ac83d2eb88d1779d465573..558fb88701b42b89fff81dcc75a8ac0a81d4cb7e 100644 (file)
@@ -310,19 +310,6 @@ STATIC word GC_register_map_entries(char *maps)
     unsigned int maj_dev;
     ptr_t least_ha, greatest_ha;
     unsigned i;
-    ptr_t datastart;
-
-#   ifdef DATASTART_IS_FUNC
-      static ptr_t datastart_cached = (ptr_t)(word)-1;
-
-      /* Evaluate DATASTART only once.  */
-      if (datastart_cached == (ptr_t)(word)-1) {
-        datastart_cached = DATASTART;
-      }
-      datastart = datastart_cached;
-#   else
-      datastart = DATASTART;
-#   endif
 
     GC_ASSERT(I_HOLD_LOCK());
     sort_heap_sects(GC_our_memory, GC_n_memory);
index a1f24a802e53f32eb5ddacdbe79bb447b4094518..e0cbbd749f13a2962cb32f7448e6b0146fee12ae 100644 (file)
@@ -72,9 +72,6 @@ ptr_t GC_get_main_stack_base()
      BPTR myseglist;
      ULONG *data;
 
-     int        num;
-
-
 #    ifdef __GNUC__
         ULONG dataSegSize;
         GC_bool found_segment = FALSE;
@@ -108,7 +105,6 @@ ptr_t GC_get_main_stack_base()
 
         /* xoper hunks Shell Process */
 
-        num=0;
         for (data = (ULONG *)BADDR(myseglist); data != NULL;
              data = (ULONG *)BADDR(data[0])) {
           if (((ULONG) GC_register_data_segments < (ULONG) &data[1]) ||
@@ -121,7 +117,6 @@ ptr_t GC_get_main_stack_base()
               GC_add_roots_inner((char *)&data[1],
                                  ((char *)&data[1]) + data[-1], FALSE);
           }
-          ++num;
         } /* for */
 #       ifdef __GNUC__
            if (!found_segment) {
index 57c224826c07ffc1b5f2d98a7a29a355cfcd0d7f..ae0dd9f8a680114d100f46c174c1d89d263d0d31 100644 (file)
@@ -58,13 +58,14 @@ struct TemporaryMemoryBlock {
 };
 
 static TemporaryMemoryHandle theTemporaryMemory = NULL;
-static Boolean firstTime = true;
 
 void GC_MacFreeTemporaryMemory(void);
 
 Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory)
 {
+#     if !defined(SHARED_LIBRARY_BUILD)
         static Boolean firstTime = true;
+#     endif
         OSErr result;
         TemporaryMemoryHandle tempMemBlock;
         Ptr tempPtr = nil;
@@ -119,11 +120,15 @@ void GC_MacFreeTemporaryMemory()
 # endif
 
     if (theTemporaryMemory != NULL) {
+#     if !defined(SHARED_LIBRARY_BUILD)
         long totalMemoryUsed = 0;
+#     endif
         TemporaryMemoryHandle tempMemBlock = theTemporaryMemory;
         while (tempMemBlock != NULL) {
                 TemporaryMemoryHandle nextBlock = (**tempMemBlock).nextBlock;
+#             if !defined(SHARED_LIBRARY_BUILD)
                 totalMemoryUsed += GetHandleSize((Handle)tempMemBlock);
+#             endif
                 DisposeHandle((Handle)tempMemBlock);
                 tempMemBlock = nextBlock;
         }
@@ -132,7 +137,7 @@ void GC_MacFreeTemporaryMemory()
 #       if !defined(SHARED_LIBRARY_BUILD)
           if (GC_print_stats) {
             fprintf(stdout, "[total memory used:  %ld bytes.]\n",
-                  totalMemoryUsed);
+                    totalMemoryUsed);
             fprintf(stdout, "[total collections: %lu]\n",
                     (unsigned long)GC_gc_no);
           }
index 659bb32f39b7c284cc24540a29e3d2fbfffb1176..4862a5995abb2a9c1c9c5f97467be06025031672 100644 (file)
@@ -342,8 +342,6 @@ size_t GetDescriptionFromAddress(void* address, const char* format,
   size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
 
   buffer += GetModuleNameFromAddress(address, buffer, size);
-  size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
-
   return buffer - begin;
 }