From 5742f863a8db6d2dd118c21c6d8cfb11d0beb821 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 3 Feb 2012 19:34:47 +0400 Subject: [PATCH] Prevent compiler warnings in GC_FindTopOfStack and GC_ports (Darwin) * darwin_stop_world.c (GC_FindTopOfStack): Initialize "frame" local variable from "stack_start" unless done via PPC lwz/ld instruction (to prevent "uninitialized variable use" compiler warning; add assertion for "stack_start" value; add 'U' suffix to int constant to prevent comparison of signed and unsigned value. * os_dep.c (GC_ports): Explicitly initialize "reply" field to zero if THREADS (to suppress compiler warning on Darwin). --- darwin_stop_world.c | 21 ++++++++++++--------- os_dep.c | 3 +++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/darwin_stop_world.c b/darwin_stop_world.c index 2255905d..cd72779b 100644 --- a/darwin_stop_world.c +++ b/darwin_stop_world.c @@ -53,15 +53,18 @@ GC_INNER ptr_t GC_FindTopOfStack(unsigned long stack_start) { StackFrame *frame; - if (stack_start == 0) { # ifdef POWERPC -# if CPP_WORDSZ == 32 - __asm__ __volatile__ ("lwz %0,0(r1)" : "=r" (frame)); -# else - __asm__ __volatile__ ("ld %0,0(r1)" : "=r" (frame)); -# endif -# endif - } else { + if (stack_start == 0) { +# if CPP_WORDSZ == 32 + __asm__ __volatile__ ("lwz %0,0(r1)" : "=r" (frame)); +# else + __asm__ __volatile__ ("ld %0,0(r1)" : "=r" (frame)); +# endif + } else +# else + GC_ASSERT(stack_start != 0); /* not implemented */ +# endif /* !POWERPC */ + /* else */ { frame = (StackFrame *)stack_start; } @@ -76,7 +79,7 @@ GC_INNER ptr_t GC_FindTopOfStack(unsigned long stack_start) /* we do these next two checks after going to the next frame because the LR for the first stack frame in the loop is not set up on purpose, so we shouldn't check it. */ - if ((frame->savedLR & ~0x3) == 0 || (frame->savedLR & ~0x3) == ~0x3) + if ((frame->savedLR & ~0x3) == 0 || (frame->savedLR & ~0x3) == ~0x3U) break; /* if the next LR is bogus, stop */ } # ifdef DEBUG_THREADS diff --git a/os_dep.c b/os_dep.c index c4058416..03a0ca8d 100644 --- a/os_dep.c +++ b/os_dep.c @@ -3900,6 +3900,9 @@ STATIC struct { (void (*)(void))catch_exception_raise_state, (void (*)(void))catch_exception_raise_state_identity }, +# ifdef THREADS + 0, /* for 'exception' */ +# endif 0 }; -- 2.50.1