From: Ivan Maidanski Date: Fri, 9 Nov 2018 17:08:20 +0000 (+0300) Subject: Eliminate 'uninitialized var' cppcheck false positive in mach_dep, os_dep X-Git-Tag: v8.0.2~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3fe6c87998fe0ee724de041e5b15380f510df2eb;p=gc Eliminate 'uninitialized var' cppcheck false positive in mach_dep, os_dep * 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. --- diff --git a/mach_dep.c b/mach_dep.c index fab9e66d..49d81bb6 100644 --- a/mach_dep.c +++ b/mach_dep.c @@ -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. */ diff --git a/os_dep.c b/os_dep.c index 45abd33f..026aaf64 100644 --- 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