From: Matthew Fernandez Date: Sun, 28 Aug 2022 20:11:26 +0000 (-0700) Subject: sfdpgen check_real_array_size: abbreviate no-op 'MAX' call X-Git-Tag: 6.0.1~14^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c5e605e590409a77a835db1d57bd3b669442ebe;p=graphviz sfdpgen check_real_array_size: 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 --- diff --git a/lib/sfdpgen/spring_electrical.c b/lib/sfdpgen/spring_electrical.c index e316c46d6..e7e87cd20 100644 --- a/lib/sfdpgen/spring_electrical.c +++ b/lib/sfdpgen/spring_electrical.c @@ -308,7 +308,7 @@ static double update_step(int adaptive_cooling, double step, double Fnorm, doubl static void check_real_array_size(double **a, int len, int *lenmax){ if (len >= *lenmax){ - *lenmax = len + MAX((int) 0.2*len, 10); + *lenmax = len + 10; *a = REALLOC(*a, sizeof(double)*(*lenmax)); }