Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static casting to int to fix clang-tidy warnings #53

Merged
merged 4 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ADT.C
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void ADT::buildADT(int d, int nelements, double* elementBbox)
// fp=fopen("adtReals.dat","w");
// fp1=fopen("adtInts.dat","w");
for (i = 0; i < nelem; i++) {
i4 = 4 * adtIntegers[4 * i];
i4 = 4 * adtIntegers[static_cast<int>(4 * i)];
adtIntegers[i4 + 3] = i;
}
// for(i=0;i<nelem;i++)
Expand Down
21 changes: 12 additions & 9 deletions src/CartBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@
}

for (i = 0; i < listptr->nweights; i++) {
int const cell_index = cart_utils::get_cell_index(
dims[0], dims[1], nf, listptr->inode[3 * i],
listptr->inode[3 * i + 1], listptr->inode[3 * i + 2]);
int const cell_index =
static_cast<int>(cart_utils::get_cell_index(
dims[0], dims[1], nf,
listptr->inode[static_cast<int>(3 * i)],
listptr->inode[3 * i + 1], listptr->inode[3 * i + 2]));
for (n = 0; n < nvar_cell; n++) {
weight = listptr->weights[i];
qq[n] += qcell[cell_index + ncell_nf * n] * weight;
Expand Down Expand Up @@ -168,7 +170,8 @@
for (int n = 0; n < 3; n++) {
dx[n] = cg->dx[3 * global_id + n];
}
dims[0] = cg->ihi[3 * global_id] - cg->ilo[3 * global_id] + 1;
dims[0] = cg->ihi[static_cast<int>(3 * global_id)] -
cg->ilo[static_cast<int>(3 * global_id)] + 1;
dims[1] = cg->ihi[3 * global_id + 1] - cg->ilo[3 * global_id + 1] + 1;
dims[2] = cg->ihi[3 * global_id + 2] - cg->ilo[3 * global_id + 2] + 1;
nf = cg->nf;
Expand Down Expand Up @@ -224,7 +227,7 @@
listptr->receptorInfo[1] = remoteid;
listptr->receptorInfo[2] = remoteblockid;
for (n = 0; n < 3; n++) {
ix[n] = (xtmp[n] - xlo[n]) / dx[n];
ix[n] = static_cast<int>((xtmp[n] - xlo[n]) / dx[n]);
rst[n] = (xtmp[n] - xlo[n] - ix[n] * dx[n]) / dx[n];
if (ix[n] == dims[n]) {
if (fabs(rst[n]) < TOL) {
Expand Down Expand Up @@ -256,10 +259,10 @@
}
if (donor_frac == nullptr) {
listptr->nweights = 8;
listptr->weights =
(double*)malloc(sizeof(double) * (listptr->nweights * 2));
listptr->inode =
(int*)malloc(sizeof(int) * (listptr->nweights * 2 * 3));
listptr->weights = (double*)malloc(
sizeof(double) * (static_cast<int>(listptr->nweights * 2)));
listptr->inode = (int*)malloc(
sizeof(int) * (static_cast<int>(listptr->nweights * 2 * 3)));

cart_interp::linear_interpolation(
nf, ix, dims, rst, &(listptr->nweights), listptr->inode,
Expand Down Expand Up @@ -463,7 +466,7 @@
}
}
} else {
if ((temp = donorList[idof]) != nullptr) {

Check warning on line 469 in src/CartBlock.C

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

an assignment within an 'if' condition is bug-prone [bugprone-assignment-in-if-condition]
// simplify logic here: the first one on the list is the
// best donor anyway, accept it if its not a mandatory
// receptor on the donor side
Expand Down Expand Up @@ -627,7 +630,7 @@
}
}
} else {
if ((temp = donorList[idof]) != nullptr) {

Check warning on line 633 in src/CartBlock.C

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

an assignment within an 'if' condition is bug-prone [bugprone-assignment-in-if-condition]
// simplify logic here: the first one on the list is the
// best donor anyway, accept it if its not a mandatory
// receptor on the donor side
Expand Down
Loading