]> granicus.if.org Git - graphviz/commitdiff
dijkstra: remove use of raw 'INT_MAX'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 19 Dec 2021 19:17:59 +0000 (11:17 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 19 Dec 2021 23:14:36 +0000 (15:14 -0800)
This code was relying on this value being the same as `DIST_MAX`. `DIST_MAX` is
currently set to `INT_MAX`, but using `INT_MAX` directly here implied it was
safe to change the definition of `DIST_MAX` without updating this location,
which was not true.

lib/neatogen/dijkstra.c

index a4f4d82732b4061d2cf501b00633c3f6e6792f5e..f524d569d38b2fbc2ef9ffaf6fcfeb5e08fa78c6 100644 (file)
@@ -139,7 +139,7 @@ void dijkstra(int vertex, vtx_data * graph, int n, DistType * dist)
     int i;
     heap H;
     int closestVertex, neighbor;
-    DistType closestDist, prevClosestDist = INT_MAX;
+    DistType closestDist, prevClosestDist = MAX_DIST;
     static int *index;
 
     index = realloc(index, n * sizeof(int));