rts: Fix uninitialised variable uses
authorBen Gamari <bgamari.foss@gmail.com>
Mon, 3 Jul 2017 23:07:59 +0000 (19:07 -0400)
committerBen Gamari <ben@smart-cactus.org>
Mon, 3 Jul 2017 23:08:11 +0000 (19:08 -0400)
Strangely gcc 5.4 compiling on amd64 (nixos) complained about these.
Both warnings look correct, so I'm not sure why we haven't been seeing
these up until now.

Test Plan: Validate

Reviewers: simonmar, austin, erikd

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3693

rts/Interpreter.c
rts/sm/MarkWeak.c

index a2f0b58..a22e966 100644 (file)
@@ -285,7 +285,7 @@ interpretBCO (Capability* cap)
     // that these entities are non-aliasable.
     register StgPtr       Sp;    // local state -- stack pointer
     register StgPtr       SpLim; // local state -- stack lim pointer
-    register StgClosure   *tagged_obj = 0, *obj;
+    register StgClosure   *tagged_obj = 0, *obj = NULL;
     uint32_t n, m;
 
     LOAD_THREAD_STATE();
index 691e56a..9a077b3 100644 (file)
@@ -364,7 +364,7 @@ static void tidyThreadList (generation *gen)
 static void checkWeakPtrSanity(StgWeak *hd, StgWeak *tl)
 {
     StgWeak *w, *prev;
-    for (w = hd; w != NULL; prev = w, w = w->link) {
+    for (prev = NULL, w = hd; w != NULL; prev = w, w = w->link) {
         ASSERT(INFO_PTR_TO_STRUCT(UNTAG_CLOSURE((StgClosure*)w)->header.info)->type == WEAK
             || UNTAG_CLOSURE((StgClosure*)w)->header.info == &stg_DEAD_WEAK_info);
         checkClosure((StgClosure*)w);