From 1f17b453e0aa46ac4a1980cbe2e234b330f69e73 Mon Sep 17 00:00:00 2001 From: Tim Davis Date: Sun, 29 Oct 2023 16:32:31 -0500 Subject: [PATCH] CHOLMOD: silence CodeQL warnings (all code was safe) --- CHOLMOD/Cholesky/cholmod_solve.c | 8 +++++--- CHOLMOD/Cholesky/cholmod_spsolve.c | 2 +- CHOLMOD/Cholesky/t_cholmod_rowfac.c | 2 +- CHOLMOD/Utility/t_cholmod_transpose_sym.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHOLMOD/Cholesky/cholmod_solve.c b/CHOLMOD/Cholesky/cholmod_solve.c index d29c679ab..905f85fe1 100644 --- a/CHOLMOD/Cholesky/cholmod_solve.c +++ b/CHOLMOD/Cholesky/cholmod_solve.c @@ -110,7 +110,8 @@ static void perm ) { double *Yx, *Yz, *Bx, *Bz ; - Int k2, nk, p, k, j, nrow, ncol, d, dual, dj, j2 ; + Int k2, nk, p, k, j, nrow, ncol, d, dj, j2 ; + size_t dual ; /* ---------------------------------------------------------------------- */ /* get inputs */ @@ -532,7 +533,8 @@ static void ptrans ) { double *Yx, *Yz, *Bx, *Bz ; - Int k2, nk, p, k, j, nrow, ncol, d, dual, dj, j2 ; + Int k2, nk, p, k, j, nrow, ncol, d, dj, j2 ; + size_t dual ; /* ---------------------------------------------------------------------- */ /* get inputs */ @@ -1543,7 +1545,7 @@ int CHOLMOD(solve2) /* returns TRUE on success, FALSE on failure */ #ifndef NSUPERNODAL /* allocate workspace */ cholmod_dense *E ; - Int dual ; + size_t dual ; Common->blas_ok = TRUE ; dual = (L->xtype == CHOLMOD_REAL && B->xtype != CHOLMOD_REAL) ? 2 : 1 ; Y = CHOLMOD(ensure_dense) (Y_Handle, n, dual*nrhs, n, L->xtype, Common); diff --git a/CHOLMOD/Cholesky/cholmod_spsolve.c b/CHOLMOD/Cholesky/cholmod_spsolve.c index 1f0d00893..869aefc39 100644 --- a/CHOLMOD/Cholesky/cholmod_spsolve.c +++ b/CHOLMOD/Cholesky/cholmod_spsolve.c @@ -112,7 +112,7 @@ cholmod_sparse *CHOLMOD(spsolve) /* returns the sparse solution X */ block = MIN (nrhs, 4) ; /* initial size of X is at most 4*n */ - nzmax = n*block ; + nzmax = ((size_t) n) * ((size_t) block) ; X = CHOLMOD(spzeros) (n, nrhs, nzmax, xtype, Common) ; B4 = CHOLMOD(zeros) (n, block, B->xtype, Common) ; diff --git a/CHOLMOD/Cholesky/t_cholmod_rowfac.c b/CHOLMOD/Cholesky/t_cholmod_rowfac.c index 4b343176a..ffdce34f3 100644 --- a/CHOLMOD/Cholesky/t_cholmod_rowfac.c +++ b/CHOLMOD/Cholesky/t_cholmod_rowfac.c @@ -157,7 +157,7 @@ static int TEMPLATE (cholmod_rowfac) * zomplex. Xwork [i] == 0 must hold. */ Wz = Wx + n ; /* size n for zomplex case only */ mark = Common->mark ; - size_t wsize = (L->xtype == CHOLMOD_REAL ? 1:2) * n ; + size_t wsize = (L->xtype == CHOLMOD_REAL ? 1:2) * ((size_t) n) ; ASSERT (Common->xworkbytes >= wsize * sizeof (Real)) ; /* ---------------------------------------------------------------------- */ diff --git a/CHOLMOD/Utility/t_cholmod_transpose_sym.c b/CHOLMOD/Utility/t_cholmod_transpose_sym.c index f2ca2ef5e..789963897 100644 --- a/CHOLMOD/Utility/t_cholmod_transpose_sym.c +++ b/CHOLMOD/Utility/t_cholmod_transpose_sym.c @@ -115,7 +115,7 @@ int CHOLMOD(transpose_sym) // allocate workspace //-------------------------------------------------------------------------- - CHOLMOD(allocate_work) (0, ((Perm == NULL) ? 1: 2) * n, 0, Common) ; + CHOLMOD(allocate_work) (0, ((Perm == NULL) ? 1: 2) * A->ncol, 0, Common) ; RETURN_IF_ERROR ; Int *Wi = (Int *) Common->Iwork ; // size n integers