]> granicus.if.org Git - graphviz/commitdiff
Remove 1 -Wmaybe-uninitialized warning in ink.c
authorMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Sat, 7 Nov 2020 15:11:57 +0000 (16:11 +0100)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Sat, 21 Nov 2020 08:17:09 +0000 (09:17 +0100)
Most certainly the unitialized values were not intended to used by the
callers since the return value of the function in this case is set to
a "large" value to indicate failure and the callers have assertions
that seems to guard from using such values by mistake (although a
thorough understanding of the algorithm and minimum ink values are
needed to prove this).

Altough the original author seems to have intended to set them to the
mid point, perhaps as a precautionary measure, the assigment has been
removed and new assertions has been added to the relevant call sites
to garantee that they are never used.

lib/mingle/agglomerative_bundling.c
lib/mingle/ink.c

index 3e562f76ea0b4f65a28c259dc08cd66ed4f8afe2..1a26d0ef791497eb0665599ec118bdd139a384fa 100644 (file)
@@ -625,6 +625,7 @@ static pedge* agglomerative_ink_bundling_internal(int dim, SparseMatrix A, pedge
        ink1 = ink(edges, ia[i+1]-ia[i], pick, &ink0, &meet1, &meet2, angle_param, angle);
        if (Verbose && DEBUG) fprintf(stderr,"finish calling ink2...\n");
        assert(fabs(ink1 - cgrid->inks[i])<=MAX(TOL, TOL*ink1) && ink1 - ink0 <= TOL);
+       assert(ink1 < 1000 * ink0); /* assert that points were found */
        wgt_all = 0.;
        if (ia[i+1]-ia[i] > 1){
          for (j = ia[i]; j < ia[i+1]; j++){
@@ -684,6 +685,7 @@ static pedge* agglomerative_ink_bundling_internal(int dim, SparseMatrix A, pedge
       ink1 = ink(edges, ia[i+1]-ia[i], pick, &ink0, &meet1, &meet2, angle_param, angle);
       if (Verbose && DEBUG) fprintf(stderr,"done calling ink3...\n");
       assert(fabs(ink1 - cgrid->inks[i])<=MAX(TOL, TOL*ink1) && ink1 - ink0 <= TOL);
+      assert(ink1 < 1000 * ink0); /* assert that points were found */
       xx[i*4 + 0] = meet1.x;
       xx[i*4 + 1] = meet1.y;
       xx[i*4 + 2] = meet2.x;
index fb9bbe03aed66371642f639a1f5368ac93982305..7603db3142d7f68dc3e246a96b736b0393cf615d 100644 (file)
@@ -314,7 +314,6 @@ double ink(pedge* edges, int numEdges, int *pick, double *ink0, point_t *meet1,
       /* no point can be found that satisfies the angular constraints, so we give up and set ink to a large value */
       if (Verbose && 0) fprintf(stderr,"no point satisfying any angle constraints can be found. cbeg=%f cend=%f\n",cbegin,cend);
       inkUsed = 1000*(*ink0);
-      *meet1 = *meet2 = mid;
       free (sources);
       free (targets);
       return inkUsed;