From: Magnus Jacobsson Date: Sat, 7 Nov 2020 15:11:57 +0000 (+0100) Subject: Remove 1 -Wmaybe-uninitialized warning in ink.c X-Git-Tag: 2.46.0~11^2~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7b72f6a0e1768902f675e7c90c113812ffd0e4c9;p=graphviz Remove 1 -Wmaybe-uninitialized warning in ink.c 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. --- diff --git a/lib/mingle/agglomerative_bundling.c b/lib/mingle/agglomerative_bundling.c index 3e562f76e..1a26d0ef7 100644 --- a/lib/mingle/agglomerative_bundling.c +++ b/lib/mingle/agglomerative_bundling.c @@ -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; diff --git a/lib/mingle/ink.c b/lib/mingle/ink.c index fb9bbe03a..7603db314 100644 --- a/lib/mingle/ink.c +++ b/lib/mingle/ink.c @@ -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;