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.
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 {