From a99f268ff09a05ed854e137ea591504079140775 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 28 Aug 2022 13:23:01 -0700 Subject: [PATCH] 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 --- lib/sparse/SparseMatrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.40.0