Skip to content

Commit

Permalink
Static casting to int to fix clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
itopcuoglu committed Jul 31, 2024
1 parent 435c740 commit 16f80b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
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 * static_cast<int>(adtIntegers[4 * i]);

Check warning on line 114 in src/ADT.C

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result]
adtIntegers[i4 + 3] = i;
}
// for(i=0;i<nelem;i++)
Expand Down
7 changes: 4 additions & 3 deletions src/CartBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ void CartBlock::getInterpolatedData(
}

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[3 * i],

Check warning on line 115 in src/CartBlock.C

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result]
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

0 comments on commit 16f80b2

Please sign in to comment.