From f86a8b44b4e2f96747aa8f270e9a02a8538ff334 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 28 Aug 2022 13:21:18 -0700 Subject: [PATCH] sparse check_or_realloc_arrays: abbreviate no-op 'MAX' call 1b847b5abf50d2ab0701523b90a20306d0ee5528 seems to have incorrectly assumed multiplication has a higher precedence than casts. In reality, it is the opposite, meaning the first parameter to this `MAX` call was always 0. So the entire expression would evaluate to 10. Empirically this seems to have been fine since this code has been in use for over a decade with no specific problems blamed on this area. So lets just abbreviate it into what it evaluates to. Gitlab: #2269 --- lib/sparse/QuadTree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sparse/QuadTree.c b/lib/sparse/QuadTree.c index 1e5fabb39..bf73ede93 100644 --- a/lib/sparse/QuadTree.c +++ b/lib/sparse/QuadTree.c @@ -67,7 +67,7 @@ static int node_data_get_id(void *d){ static void check_or_realloc_arrays(int dim, int *nsuper, int *nsupermax, double **center, double **supernode_wgts, double **distances){ if (*nsuper >= *nsupermax) { - *nsupermax = *nsuper + MAX(10, (int) 0.2*(*nsuper)); + *nsupermax = *nsuper + 10; *center = REALLOC(*center, sizeof(double)*(*nsupermax)*dim); *supernode_wgts = REALLOC(*supernode_wgts, sizeof(double)*(*nsupermax)); *distances = REALLOC(*distances, sizeof(double)*(*nsupermax)); -- 2.40.0