silence static code analysis warnings about integer overflows

This commit is contained in:
Axel Kohlmeyer
2022-07-16 06:23:09 -04:00
parent 6689a20754
commit e856bb2364
4 changed files with 10 additions and 10 deletions

View File

@ -235,8 +235,8 @@ void ComputeGrid::set_grid_local()
double ComputeGrid::memory_usage()
{
double nbytes = size_array_rows * size_array_cols * sizeof(double); // grid
nbytes += size_array_rows * size_array_cols * sizeof(double); // gridall
nbytes += size_array_cols * ngridlocal * sizeof(double); // gridlocal
double nbytes = (double) size_array_rows * size_array_cols * sizeof(double); // grid
nbytes += (double) size_array_rows * size_array_cols * sizeof(double); // gridall
nbytes += (double) size_array_cols * ngridlocal * sizeof(double); // gridlocal
return nbytes;
}

View File

@ -265,6 +265,6 @@ void ComputeGridLocal::assign_coords()
double ComputeGridLocal::memory_usage()
{
int nbytes = size_local_rows * size_local_cols * sizeof(double); // gridlocal
double nbytes = (double) size_local_rows * size_local_cols * sizeof(double); // gridlocal
return nbytes;
}

View File

@ -292,7 +292,7 @@ void ComputeSNAGrid::compute_array()
}
}
memset(&grid[0][0], 0, size_array_rows * size_array_cols * sizeof(double));
memset(&grid[0][0], 0, sizeof(double) * size_array_rows * size_array_cols);
for (int iz = nzlo; iz <= nzhi; iz++)
for (int iy = nylo; iy <= nyhi; iy++)

View File

@ -77,7 +77,7 @@ vstore(nullptr), astore(nullptr), rbuf(nullptr)
else if (narg == 6) arrayflag = 1;
else tensorflag = 1;
nvalues = n2*n3;
nbytes = n2*n3 * sizeof(double);
nbytes = nvalues * sizeof(double);
}
vstore = nullptr;
@ -194,7 +194,7 @@ void FixStore::write_restart(FILE *fp)
rbuf[0] = n1;
rbuf[1] = n2;
if (vecflag) memcpy(&rbuf[2],vstore,n1*sizeof(double));
else if (arrayflag) memcpy(&rbuf[2],&astore[0][0],n1*n2*sizeof(double));
else if (arrayflag) memcpy(&rbuf[2],&astore[0][0],sizeof(double)*n1*n2);
int n = n1*n2 + 2;
if (comm->me == 0) {
@ -391,8 +391,8 @@ int FixStore::size_restart(int /*nlocal*/)
double FixStore::memory_usage()
{
double bytes = 0.0;
if (flavor == GLOBAL) bytes += n1*n2 * sizeof(double);
if (flavor == PERATOM) bytes += atom->nmax*n2*n3 * sizeof(double);
double bytes = (double) n1 * n2;
if (flavor == GLOBAL) bytes *= sizeof(double);
if (flavor == PERATOM) bytes *= atom->nmax * sizeof(double);
return bytes;
}