]> granicus.if.org Git - graphviz/commitdiff
grammar.y startgraph: [nfc] remove a static local
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 6 Feb 2022 06:19:35 +0000 (17:19 +1100)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 7 Feb 2022 07:51:14 +0000 (18:51 +1100)
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.

lib/cgraph/grammar.y

index bf47373db27b98b5c7b7b9cf1b258d9b0fc65cc5..aa93523e7d801876f80c2f53701b14619d199a16 100644 (file)
@@ -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 {