]> granicus.if.org Git - gc/commitdiff
Eliminate 'uninitialized var' cppcheck false positive in mach_dep, os_dep
authorIvan Maidanski <ivmai@mail.ru>
Fri, 9 Nov 2018 17:08:20 +0000 (20:08 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 26 Nov 2018 07:13:32 +0000 (10:13 +0300)
* mach_dep.c (GC_with_callee_saves_pushed): Change type of "context"
local variable from void* volatile to volatile ptr_t.
* os_dep.c [(SVR4 || AIX || DGUX || (LINUX && SPARC)) && !PCR]
(GC_SysVGetDataStart): Change type of "result" local variable from
char* volatile to volatile ptr_t.

mach_dep.c
os_dep.c

index fab9e66d2861de332795e598f21aea4a6ff6a9ca..49d81bb63be6a052d504ad90b34b609f4ca0c364 100644 (file)
@@ -228,7 +228,7 @@ GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *),
                                           volatile ptr_t arg)
 {
   volatile int dummy;
-  void * volatile context = 0;
+  volatile ptr_t context = 0;
 
 # if defined(HAVE_PUSH_REGS)
     GC_push_regs();
@@ -263,7 +263,7 @@ GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *),
           /* getcontext() is broken, do not try again.          */
           /* E.g., to workaround a bug in Docker ubuntu_32bit.  */
         } else {
-          context = &ctxt;
+          context = (ptr_t)&ctxt;
         }
         if (EXPECT(0 == getcontext_works, FALSE))
           getcontext_works = context != NULL ? 1 : -1;
@@ -327,7 +327,7 @@ GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *),
 # endif /* !HAVE_PUSH_REGS */
   /* TODO: context here is sometimes just zero.  At the moment, the     */
   /* callees don't really need it.                                      */
-  fn(arg, context);
+  fn(arg, (/* no volatile */ void *)context);
   /* Strongly discourage the compiler from treating the above   */
   /* as a tail-call, since that would pop the register          */
   /* contents before we get a chance to look at them.           */
index 45abd33f590e6dc692328964281f0be2b7be702a..026aaf64271dd2bdd1927b9f15a6addb659835a4 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -1937,7 +1937,7 @@ void GC_register_data_segments(void)
     word next_page = ((text_end + (word)max_page_size - 1)
                       & ~((word)max_page_size - 1));
     word page_offset = (text_end & ((word)max_page_size - 1));
-    char * volatile result = (char *)(next_page + page_offset);
+    volatile ptr_t result = (char *)(next_page + page_offset);
     /* Note that this isn't equivalent to just adding           */
     /* max_page_size to &etext if &etext is at a page boundary  */
 
@@ -1965,7 +1965,7 @@ void GC_register_data_segments(void)
         /* text and data segments, so plan A brought us something.      */
         result = (char *)GC_find_limit(DATAEND, FALSE);
     }
-    return((ptr_t)result);
+    return (/* no volatile */ ptr_t)result;
   }
 # endif