Workaround 'Uninitialized variable' cppcheck errors
authorIvan Maidanski <ivmai@mail.ru>
Tue, 18 Oct 2016 08:39:17 +0000 (11:39 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 18 Oct 2016 08:39:17 +0000 (11:39 +0300)
* extra/AmigaOS.c [GC_AMIGA_DS] (GC_register_data_segments): Initialize
myseglist outside conditional statement.
* mach_dep.c [GETCONTEXT_FPU_EXCMASK_BUG && X86_64]
(GC_with_callee_saves_pushed): Call GC_noop1(&old_fcw) (before asm
fstcw) if CPPCHECK.
* mach_dep.c [!HAVE_BUILTIN_UNWIND_INIT] (GC_with_callee_saves_pushed):
Replace regs with &regs.
* os_dep.c [!MSWIN32 && !GC_OPENBSD_THREADS && ...]
(GC_get_main_stack_base): Set result to NULL if CPPCHECK but none of
HEURISTIC* and *STACKBOTTOM defined.

extra/AmigaOS.c
mach_dep.c
os_dep.c

index e0cbbd7..07feb75 100644 (file)
@@ -87,10 +87,9 @@ ptr_t GC_get_main_stack_base()
 
         /* Reference: Amiga Guru Book Pages: 538ff,565,573
                      and XOper.asm */
+        myseglist = proc->pr_SegList;
         if (proc->pr_Task.tc_Node.ln_Type==NT_PROCESS) {
-          if (proc->pr_CLI == NULL) {
-            myseglist = proc->pr_SegList;
-          } else {
+          if (proc->pr_CLI != NULL) {
             /* ProcLoaded       'Loaded as a command: '*/
             cli = BADDR(proc->pr_CLI);
             myseglist = cli->cli_Module;
index 6a9bc0f..61b5ed2 100644 (file)
@@ -243,6 +243,9 @@ GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *),
           /* client application to use -lm linker option.               */
           unsigned short old_fcw;
 
+#         if defined(CPPCHECK)
+            GC_noop1((word)&old_fcw);
+#         endif
           __asm__ __volatile__ ("fstcw %0" : "=m" (*&old_fcw));
 #       else
           int except_mask = fegetexcept();
@@ -292,8 +295,8 @@ GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *),
         /* We're not sure whether he would like  */
         /* to be acknowledged for it or not.     */
         jmp_buf regs;
-        register word * i = (word *) regs;
-        register ptr_t lim = (ptr_t)(regs) + (sizeof regs);
+        register word * i = (word *) &regs;
+        register ptr_t lim = (ptr_t)(&regs) + (sizeof regs);
 
         /* Setjmp doesn't always clear all of the buffer.               */
         /* That tends to preserve garbage.  Clear it.                   */
index 4bb7048..6d12de1 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -1203,14 +1203,11 @@ GC_INNER size_t GC_page_size = 0;
 #       else
           result = (ptr_t)((word)GC_approx_sp() & ~STACKBOTTOM_ALIGNMENT_M1);
 #       endif
-#     endif /* HEURISTIC1 */
-#     ifdef LINUX_STACKBOTTOM
+#     elif defined(LINUX_STACKBOTTOM)
          result = GC_linux_main_stack_base();
-#     endif
-#     ifdef FREEBSD_STACKBOTTOM
+#     elif defined(FREEBSD_STACKBOTTOM)
          result = GC_freebsd_main_stack_base();
-#     endif
-#     ifdef HEURISTIC2
+#     elif defined(HEURISTIC2)
         {
           ptr_t sp = GC_approx_sp();
 #         ifdef STACK_GROWS_DOWN
@@ -1231,8 +1228,12 @@ GC_INNER size_t GC_page_size = 0;
 #           endif
 #         endif
         }
-#     endif /* HEURISTIC2 */
-#     ifdef STACK_GROWS_DOWN
+#     elif defined(CPPCHECK)
+        result = NULL;
+#     else
+#       error None of HEURISTIC* and *STACKBOTTOM defined!
+#     endif
+#     if defined(STACK_GROWS_DOWN) && !defined(CPPCHECK)
         if (result == 0)
           result = (ptr_t)(signed_word)(-sizeof(ptr_t));
 #     endif