]> granicus.if.org Git - graphviz/commitdiff
pathplan: phrase comparison in 'splinefits' with a tolerance
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 13 Nov 2022 17:57:47 +0000 (09:57 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 13 Nov 2022 22:54:42 +0000 (14:54 -0800)
From the adjustments to `a` in this function, it can be seen this is equivalent.
This squashes the warning:

  route.c: In function ‘splinefits’:
  route.c:252:15: warning: comparing floating-point with ‘==’ or ‘!=’ is unsafe
    [-Wfloat-equal]
    252 |         if (a == 0) {
        |               ^~

lib/pathplan/route.c

index 8eecef3393eba455954e2c7d39423d51bbc95f55..97b6bd31e57e2d5e0f9765f6bacb22383526c9f9 100644 (file)
@@ -249,7 +249,9 @@ static int splinefits(Pedge_t * edges, int edgen, Ppoint_t pa,
 #endif
            return 1;
        }
-       if (a == 0) {
+       // is `a` 0, accounting for the precision with which it was computed (on the
+       // last loop iteration) below?
+       if (a < 0.005) {
            if (forceflag) {
                if (growops(opl + 4) < 0) {
                    return -1;