Skip to content

Commit

Permalink
static_cast<ptrdiff_t>:q
Browse files Browse the repository at this point in the history
  • Loading branch information
itopcuoglu committed Dec 17, 2024
1 parent 6d9e109 commit 34790de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/CartBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ 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],
dims[0], dims[1], nf,
listptr->inode[static_cast<ptrdiff_t>(3 * i)],

Check warning on line 116 in src/CartBlock.C

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

no header providing "ptrdiff_t" is directly included [misc-include-cleaner]
listptr->inode[(3 * i) + 1], listptr->inode[(3 * i) + 2]));
for (n = 0; n < nvar_cell; n++) {
weight = listptr->weights[i];
Expand Down Expand Up @@ -169,7 +170,8 @@ void CartBlock::preprocess(CartGrid* cg)
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<ptrdiff_t>(3 * global_id)] -
cg->ilo[static_cast<ptrdiff_t>(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
10 changes: 6 additions & 4 deletions src/CartGrid.C
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,19 @@ void CartGrid::search(double* x, int* donorid, int npts)
}
}
}
if (myid == 2 && abs(x[3 * i] - 0.739573) < 1e-5 &&
if (myid == 2 &&
abs(x[static_cast<ptrdiff_t>(3 * i)] - 0.739573) < 1e-5 &&

Check warning on line 225 in src/CartGrid.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]

Check failure on line 225 in src/CartGrid.C

View workflow job for this annotation

GitHub Actions / CPU (ubuntu-22.04, Debug)

‘ptrdiff_t’ does not name a type
abs(x[(3 * i) + 1] + 0.259310) < 1e-5 &&
abs(x[(3 * i) + 2] + 0.639614) < 1e-5) {
printf(
"%d %d %f %f %f %d\n", myid, i, x[3 * i], x[(3 * i) + 1],
"%d %d %f %f %f %d\n", myid, i,
x[static_cast<ptrdiff_t>(3 * i)], x[(3 * i) + 1],

Check warning on line 230 in src/CartGrid.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]

Check failure on line 230 in src/CartGrid.C

View workflow job for this annotation

GitHub Actions / CPU (ubuntu-22.04, Debug)

‘ptrdiff_t’ does not name a type
x[(3 * i) + 2], donorid[i]);
}
if (donorid[i] == -1) {
printf(
"%d %f %f %f\n", myid, x[3 * i], x[(3 * i) + 1],
x[(3 * i) + 2]);
"%d %f %f %f\n", myid, x[static_cast<ptrdiff_t>(3 * i)],

Check warning on line 235 in src/CartGrid.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]

Check failure on line 235 in src/CartGrid.C

View workflow job for this annotation

GitHub Actions / CPU (ubuntu-22.04, Debug)

‘ptrdiff_t’ does not name a type
x[(3 * i) + 1], x[(3 * i) + 2]);
}
}
// printf("CartGrid::search Processor %d located %d of %d
Expand Down

0 comments on commit 34790de

Please sign in to comment.