From 91a420c0c4dd26268791a80d73a475b1a87d4123 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 18 Oct 2016 11:39:17 +0300 Subject: [PATCH] Workaround 'Uninitialized variable' cppcheck errors * 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 ®s. * 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 | 5 ++--- mach_dep.c | 7 +++++-- os_dep.c | 17 +++++++++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/extra/AmigaOS.c b/extra/AmigaOS.c index e0cbbd74..07feb75b 100644 --- a/extra/AmigaOS.c +++ b/extra/AmigaOS.c @@ -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; diff --git a/mach_dep.c b/mach_dep.c index 6a9bc0f0..61b5ed26 100644 --- a/mach_dep.c +++ b/mach_dep.c @@ -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 *) ®s; + register ptr_t lim = (ptr_t)(®s) + (sizeof regs); /* Setjmp doesn't always clear all of the buffer. */ /* That tends to preserve garbage. Clear it. */ diff --git a/os_dep.c b/os_dep.c index 4bb70488..6d12de1c 100644 --- 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 -- 2.40.0