From af1143d40ea145cb25a4d939ce822681d81264e4 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 12 Feb 2022 14:13:49 +1100 Subject: [PATCH] neatogen: replace 'MAXFLOAT' in clamping logic with 'FLT_MAX' This seems a more accurate definition of what overflow would mean under C99. Though as far as I can tell, it is not possible to reach this code with negative values in the array, so the `< 0` check is always false. The `>= FLT_MAX` is true for both `FLT_MAX` itself as well as positive infinity. --- lib/neatogen/stress.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/neatogen/stress.c b/lib/neatogen/stress.c index baa2d8c26..cb3996b27 100644 --- a/lib/neatogen/stress.c +++ b/lib/neatogen/stress.c @@ -8,7 +8,7 @@ * Contributors: Details at https://graphviz.org *************************************************************************/ - +#include #include #include #include @@ -1118,8 +1118,7 @@ int stress_majorization_kD_mkernel(vtx_data * graph, /* Input graph in sparse re invert_sqrt_vec(len, dist_accumulator); /* detect overflows */ for (j = 0; j < len; j++) { - if (dist_accumulator[j] >= MAXFLOAT - || dist_accumulator[j] < 0) { + if (dist_accumulator[j] >= FLT_MAX || dist_accumulator[j] < 0) { dist_accumulator[j] = 0; } } -- 2.40.0