]> granicus.if.org Git - graphviz/commitdiff
neatogen makeObstacle: squash -Wmaybe-uninitialized warnings
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 8 Sep 2022 00:27:49 +0000 (17:27 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 29 Jan 2023 21:27:37 +0000 (13:27 -0800)
This seems to be a false positive, but to figure this out requires non-trivial
reasoning about the control flow in this function. We may as well remove the
need to think about this. This squashes these warnings:

  neatosplines.c: In function ‘makeObstacle’:
  neatosplines.c:360:37: warning: ‘margin.y’ may be used uninitialized in this
    function [-Wmaybe-uninitialized]
    360 |                             ymargin = -margin.y;
        |                             ~~~~~~~~^~~~~~~~~~~
  neatosplines.c:351:37: warning: ‘margin.x’ may be used uninitialized in this
    function [-Wmaybe-uninitialized]
    351 |                             xmargin = -margin.x;
        |                             ~~~~~~~~^~~~~~~~~~~

lib/neatogen/neatosplines.c

index f03da45be699023251ae2c3308d8be004cadf463..1d3531706b2b7cd41185914bf3ee7c097d9f6da9 100644 (file)
@@ -288,7 +288,7 @@ Ppoly_t *makeObstacle(node_t * n, expand_t* pmargin, bool isOrtho)
     pointf* verts = NULL;
     pointf vs[4];
     pointf p;
-    pointf margin;
+    pointf margin = {0};
 
     switch (shapeOf(n)) {
     case SH_POLY:
@@ -299,7 +299,6 @@ Ppoly_t *makeObstacle(node_t * n, expand_t* pmargin, bool isOrtho)
            isPoly = true;
            sides = 4;
            verts = vs;
-           margin.x = margin.y = 0;
                /* For fixedshape, we can't use the width and height, as this includes
                 * the label. We only want to use the actual node shape.
                 */