From: Matthew Fernandez Date: Sun, 28 Aug 2022 20:23:01 +0000 (-0700) Subject: sparse SparseMatrix_coordinate_form_add_entry: abbreviate no-op 'MAX' call X-Git-Tag: 6.0.1~14^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a99f268ff09a05ed854e137ea591504079140775;p=graphviz sparse SparseMatrix_coordinate_form_add_entry: abbreviate no-op 'MAX' call d1d1ae30865c14bb7e6a75f8772543c10419e48b 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: fixes #2269 --- diff --git a/lib/sparse/SparseMatrix.c b/lib/sparse/SparseMatrix.c index 3ba6852c6..924ad40ea 100644 --- a/lib/sparse/SparseMatrix.c +++ b/lib/sparse/SparseMatrix.c @@ -1464,7 +1464,7 @@ SparseMatrix SparseMatrix_coordinate_form_add_entry(SparseMatrix A, int irn, if (nz + nentries >= A->nzmax){ nzmax = nz + nentries; - nzmax = MAX(10, (int) 0.2*nzmax) + nzmax; + nzmax += 10; A = SparseMatrix_realloc(A, nzmax); } A->ia[nz] = irn;