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

More clang-tidy fixes #64

Merged
merged 17 commits into from
Dec 30, 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
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Checks: 'bugprone-*,
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
HeaderFileExtensions: ['', "H", 'h', 'hh', 'hpp', 'hxx']
AnalyzeTemporaryDtors: false
FormatStyle: none
User: user
CheckOptions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
echo "CCACHE_EXTRAFILES=${{github.workspace}}/.clang-tidy" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=50M" >> $GITHUB_ENV
echo "CTCACHE_DIR=~/.cache/ctcache" >> $GITHUB_ENV
echo "CLANG_TIDY_VERSION=17" >> $GITHUB_ENV
echo "CLANG_TIDY_VERSION=19" >> $GITHUB_ENV
- name: Install clang-tidy
run: |
echo 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-retries
Expand Down
6 changes: 4 additions & 2 deletions src/ADT.C
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ADT.h"
#include "buildADTrecursion.h"
#include <limits>
#include <cstddef>

void ADT::buildADT(int d, int nelements, double* elementBbox)
{
Expand Down Expand Up @@ -74,7 +75,8 @@ void ADT::buildADT(int d, int nelements, double* elementBbox)
}
for (i = 0; i < ndim / 2; i++) {
i2 = 2 * i + 1;
adtExtents[i2] = std::max(adtExtents[i2], coord[j6 + i + ndim / 2]);
adtExtents[i2] =
std::max(adtExtents[i2], coord[j6 + i + (ndim / 2)]);
}
}
//
Expand Down Expand Up @@ -112,7 +114,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[static_cast<int>(4 * i)];
i4 = 4 * adtIntegers[static_cast<ptrdiff_t>(4 * i)];
adtIntegers[i4 + 3] = i;
}
// for(i=0;i<nelem;i++)
Expand Down
44 changes: 23 additions & 21 deletions src/CartBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <limits>
#include "TiogaMeshInfo.h"
#include "codetypes.h"
#include "CartBlock.h"
Expand All @@ -30,7 +32,6 @@
#include "linCartInterp.h"
#include "linklist.h"
#include "tioga_utils.h"
#include <limits>

void CartBlock::registerData(int lid, TIOGA::AMRMeshInfo* minfo)
{
Expand Down Expand Up @@ -111,14 +112,13 @@
}

for (i = 0; i < listptr->nweights; i++) {
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]));
int const cell_index = (cart_utils::get_cell_index(
dims[0], dims[1], nf,
listptr->inode[static_cast<ptrdiff_t>(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;
qq[n] += qcell[cell_index + (ncell_nf * n)] * weight;
}

int const ind_offset = 3 * (listptr->nweights + i);
Expand All @@ -129,7 +129,7 @@
for (n = 0; n < nvar_node; n++) {
weight = listptr->weights[listptr->nweights + i];
qq[nvar_cell + n] +=
qnode[node_index + nnode_nf * n] * weight;
qnode[node_index + (nnode_nf * n)] * weight;
}
}

Expand All @@ -150,14 +150,14 @@
return;
}
for (int i = 0; i < nvar_node; i++) {
qnode[index - ncell_nf + nnode_nf * i] = qval[nvar_cell + i];
qnode[index - ncell_nf + (nnode_nf * i)] = qval[nvar_cell + i];
}
} else {
if (nvar_cell == 0) {
return;
}
for (int i = 0; i < nvar_cell; i++) {
qcell[index + ncell_nf * i] = qval[i];
qcell[index + (ncell_nf * i)] = qval[i];
}
}
}
Expand All @@ -166,15 +166,15 @@
{
int nfrac;
for (int n = 0; n < 3; n++) {
xlo[n] = cg->xlo[3 * global_id + n];
xlo[n] = cg->xlo[(3 * global_id) + n];
}
for (int n = 0; n < 3; n++) {
dx[n] = cg->dx[3 * global_id + n];
dx[n] = cg->dx[(3 * global_id) + n];
}
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;
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;
myid = cg->myid;
donor_frac = cg->donor_frac;
Expand All @@ -201,7 +201,7 @@
deallocateLinkList(donorList[i]);
donorList[i] = nullptr;
}
TIOGA_FREE(donorList);

Check warning on line 204 in src/CartBlock.C

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

multilevel pointer conversion from 'DONORLIST **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion]
}
deallocateLinkList4(interpList);
interpList = nullptr;
Expand Down Expand Up @@ -261,9 +261,11 @@
if (donor_frac == nullptr) {
listptr->nweights = 8;
listptr->weights = (double*)malloc(
sizeof(double) * (static_cast<int>(listptr->nweights * 2)));
sizeof(double) *
(static_cast<unsigned long>(listptr->nweights * 2)));
listptr->inode = (int*)malloc(
sizeof(int) * (static_cast<int>(listptr->nweights * 2 * 3)));
sizeof(int) *
(static_cast<unsigned long>(listptr->nweights * 2 * 3)));

cart_interp::linear_interpolation(
nf, ix, dims, rst, &(listptr->nweights), listptr->inode,
Expand Down Expand Up @@ -758,21 +760,21 @@
for (k = 0; k < dims[2] + 1; k++) {
for (j = 0; j < dims[1] + 1; j++) {
for (i = 0; i < dims[0] + 1; i++) {
fprintf(fp, "%lf\n", xlo[0] + dx[0] * i);
fprintf(fp, "%lf\n", xlo[0] + (dx[0] * i));
}
}
}
for (k = 0; k < dims[2] + 1; k++) {
for (j = 0; j < dims[1] + 1; j++) {
for (i = 0; i < dims[0] + 1; i++) {
fprintf(fp, "%lf\n", xlo[1] + dx[1] * j);
fprintf(fp, "%lf\n", xlo[1] + (dx[1] * j));
}
}
}
for (k = 0; k < dims[2] + 1; k++) {
for (j = 0; j < dims[1] + 1; j++) {
for (i = 0; i < dims[0] + 1; i++) {
fprintf(fp, "%lf\n", xlo[2] + dx[2] * k);
fprintf(fp, "%lf\n", xlo[2] + (dx[2] * k));
}
}
}
Expand Down
37 changes: 22 additions & 15 deletions src/CartGrid.C
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <cmath>
#include <numeric>
#include <limits>
#include <cstddef>

#include "tioga_gpu.h"
#include "TiogaMeshInfo.h"
Expand Down Expand Up @@ -159,7 +160,8 @@ void CartGrid::preprocess()
for (i = 0; i < ngrids; i++) {
for (n = 0; n < 3; n++) {
xlosup[n] =
((xlosup[n] <= xlo[3 * i + n]) ? xlosup[n] : xlo[3 * i + n]);
((xlosup[n] <= xlo[(3 * i) + n]) ? xlosup[n]
: xlo[(3 * i) + n]);
}
maxlevel = ((maxlevel >= level_num[i]) ? maxlevel : level_num[i]);
}
Expand All @@ -172,7 +174,7 @@ void CartGrid::preprocess()
for (i = 0; i < ngrids; i++) {
lcount[level_num[i]]++;
for (n = 0; n < 3; n++) {
dxlvl[3 * level_num[i] + n] = dx[3 * i + n];
dxlvl[(3 * level_num[i]) + n] = dx[(3 * i) + n];
}
}
}
Expand All @@ -191,7 +193,8 @@ void CartGrid::search(double* x, int* donorid, int npts)
donorid[i] = -1;
for (l = maxlevel - 1; l >= 0 && static_cast<int>(flag) == 0; l--) {
for (n = 0; n < 3; n++) {
il[n] = floor((x[3 * i + n] - xlosup[n]) / dxlvl[3 * l + n]);
il[n] =
floor((x[(3 * i) + n] - xlosup[n]) / dxlvl[(3 * l) + n]);
}
for (j = 0; j < ngrids && static_cast<int>(flag) == 0; j++) {
if (level_num[j] == l) {
Expand All @@ -202,13 +205,15 @@ void CartGrid::search(double* x, int* donorid, int npts)
// for(n=0;n<3;n++) flag = flag && (il[n] >=ilo[3*j+n]);
// for(n=0;n<3;n++) flag = flag && (il[n] <=ihi[3*j+n]);
for (n = 0; n < 3; n++) {
flag = flag && ((x[3 * i + n] - xlo[3 * j + n]) > -TOL);
flag = flag &&
((x[(3 * i) + n] - xlo[(3 * j) + n]) > -TOL);
}
for (n = 0; n < 3; n++) {
flag = flag &&
((x[3 * i + n] -
(xlo[3 * j + n] +
dx[3 * j + n] * (dims[3 * j + n]))) < TOL);
flag =
flag &&
((x[(3 * i) + n] -
(xlo[(3 * j) + n] +
dx[(3 * j) + n] * (dims[(3 * j) + n]))) < TOL);
}
if (flag) {
dcount++;
Expand All @@ -217,17 +222,19 @@ void CartGrid::search(double* x, int* donorid, int npts)
}
}
}
if (myid == 2 && abs(x[static_cast<int>(3 * i)] - 0.739573) < 1e-5 &&
abs(x[3 * i + 1] + 0.259310) < 1e-5 &&
abs(x[3 * i + 2] + 0.639614) < 1e-5) {
if (myid == 2 &&
abs(x[static_cast<ptrdiff_t>(3 * i)] - 0.739573) < 1e-5 &&
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[static_cast<int>(3 * i)],
x[3 * i + 1], x[3 * i + 2], donorid[i]);
"%d %d %f %f %f %d\n", myid, i,
x[static_cast<ptrdiff_t>(3 * i)], x[(3 * i) + 1],
x[(3 * i) + 2], donorid[i]);
}
if (donorid[i] == -1) {
printf(
"%d %f %f %f\n", myid, x[static_cast<int>(3 * i)], x[3 * i + 1],
x[3 * i + 2]);
"%d %f %f %f\n", myid, x[static_cast<ptrdiff_t>(3 * i)],
x[(3 * i) + 1], x[(3 * i) + 2]);
}
}
// printf("CartGrid::search Processor %d located %d of %d
Expand Down
Loading
Loading