From 5573d01079d72885286e184fffa69da2cb91fbf1 Mon Sep 17 00:00:00 2001 From: Giacomo Fiorin Date: Sat, 6 Feb 2021 17:30:01 -0500 Subject: [PATCH] Use typecast to silence CodeQL warnings --- lib/colvars/colvargrid.cpp | 24 ++++++++++++------------ lib/colvars/colvargrid.h | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/colvars/colvargrid.cpp b/lib/colvars/colvargrid.cpp index 7c2fe3b33c..6cf2cdee45 100644 --- a/lib/colvars/colvargrid.cpp +++ b/lib/colvars/colvargrid.cpp @@ -423,8 +423,8 @@ void integrate_potential::atimes(const std::vector &A, std::vector(w - 1); // Follows right edge if (periodic[0]) { xm = h * (w - 1); xp = h; @@ -478,7 +478,7 @@ void integrate_potential::atimes(const std::vector &A, std::vector &A, std::vector(h); // Skip left slab fact = facty * factz; for (i=1; i &A, std::vector(w - 1); // Follows right slab if (periodic[0]) { xm = d * h * (w - 1); xp = d * h; @@ -639,8 +639,8 @@ void integrate_potential::atimes(const std::vector &A, std::vector(d - 1); // Follows back slab if (periodic[1]) { ym = h * (d - 1); yp = h; @@ -664,8 +664,8 @@ void integrate_potential::atimes(const std::vector &A, std::vector(d - 1); + index2 += h * static_cast(d - 1); } } else { ym = -h; @@ -691,8 +691,8 @@ void integrate_potential::atimes(const std::vector &A, std::vector(d - 1); + index2 += h * static_cast(d - 1); } } diff --git a/lib/colvars/colvargrid.h b/lib/colvars/colvargrid.h index 427e5b0825..17d049a6eb 100644 --- a/lib/colvars/colvargrid.h +++ b/lib/colvars/colvargrid.h @@ -59,7 +59,7 @@ protected: { size_t addr = 0; for (size_t i = 0; i < nd; i++) { - addr += ix[i]*nxc[i]; + addr += ix[i]*static_cast(nxc[i]); if (cvm::debug()) { if (ix[i] >= nx[i]) { cvm::error("Error: exceeding bounds in colvar_grid.\n", BUG_ERROR);