From: Matthew Fernandez Date: Sun, 6 Feb 2022 06:19:35 +0000 (+1100) Subject: grammar.y startgraph: [nfc] remove a static local X-Git-Tag: 3.0.0~39^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=885137f9fecfd605a36e3b457b6d5f388e162c21;p=graphviz grammar.y startgraph: [nfc] remove a static local A simpler way of achieving the warning squashing the comment here is implying (uninitialized struct members) is to avoid the use of a static variable altogether. Beyond being simpler, this explains to the compiler the contents of this variable do not need to be preserved across calls and gets this function closer to being thread safe. --- diff --git a/lib/cgraph/grammar.y b/lib/cgraph/grammar.y index bf47373db..aa93523e7 100644 --- a/lib/cgraph/grammar.y +++ b/lib/cgraph/grammar.y @@ -521,13 +521,9 @@ static void newedge(Agnode_t *t, char *tport, Agnode_t *h, char *hport, char *ke static void startgraph(char *name, bool directed, bool strict) { - static Agdesc_t req; /* get rid of warnings */ - if (G == NULL) { SubgraphDepth = 0; - req.directed = directed; - req.strict = strict; - req.maingraph = TRUE; + Agdesc_t req = {.directed = directed, .strict = strict, .maingraph = true}; Ag_G_global = G = agopen(name,req,Disc); } else {