From: Matthew Fernandez Date: Fri, 10 Sep 2021 04:24:36 +0000 (-0700) Subject: smyrna object_color: rephrase to make initialization of 'vis' more obvious X-Git-Tag: 2.49.1~19^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67773f081a4724390e58229ab45e680fff3fcd14;p=graphviz smyrna object_color: rephrase to make initialization of 'vis' more obvious Auditing all call sites of this function reveals it is only ever called with edges and nodes. But the compiler could not see enough to know this. On macOS, Clang dutifully warns: topviewfuncs.c:165:13: warning: variable 'vis' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] as noted by Stephen.¹ ¹ https://forum.graphviz.org/t/tracking-down-warnings-old-news-to-some-of-you/821 --- diff --git a/cmd/smyrna/topviewfuncs.c b/cmd/smyrna/topviewfuncs.c index 3c9207784..4c1ec7ab8 100644 --- a/cmd/smyrna/topviewfuncs.c +++ b/cmd/smyrna/topviewfuncs.c @@ -8,6 +8,7 @@ * Contributors: Details at https://graphviz.org *************************************************************************/ +#include #include "topviewfuncs.h" #include #include "smyrna_utils.h" @@ -162,7 +163,8 @@ static int object_color(void* obj,glCompColor* c) Alpha=getAttrFloat(g,objg,"defaultedgealpha",1); vis = GE_visible (objg); } - else if(objType==AGNODE) { + else { + assert(objType == AGNODE); Alpha=getAttrFloat(g,objg,"defaultnodealpha",1); vis = GN_visible (objg); }