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

Fix warnings #51

Merged
merged 4 commits into from
Jul 25, 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: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Checks: 'bugprone-*,
-readability-isolate-declaration,
-readability-avoid-const-params-in-decls,
-readability-identifier-length,
-readability-convert-member-functions-to-static,
-readability-function-cognitive-complexity'
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
Expand Down
7 changes: 3 additions & 4 deletions src/CartBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@

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],

Check warning on line 114 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];
Expand Down Expand Up @@ -168,7 +168,7 @@
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;

Check warning on line 171 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]

Check warning on line 171 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]
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 +224,7 @@
listptr->receptorInfo[1] = remoteid;
listptr->receptorInfo[2] = remoteblockid;
for (n = 0; n < 3; n++) {
ix[n] = (xtmp[n] - xlo[n]) / dx[n];

Check warning on line 227 in src/CartBlock.C

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

narrowing conversion from 'double' to 'int' [bugprone-narrowing-conversions]
rst[n] = (xtmp[n] - xlo[n] - ix[n] * dx[n]) / dx[n];
if (ix[n] == dims[n]) {
if (fabs(rst[n]) < TOL) {
Expand All @@ -232,7 +232,7 @@
rst[n] = (xtmp[n] - xlo[n] - ix[n] * dx[n]) / dx[n];
}
}
if (!(ix[n] >= 0 && ix[n] < dims[n])) {
if (ix[n] < 0 || ix[n] >= dims[n]) {
TRACEI(procid);
TRACEI(global_id);
TRACEI(local_id);
Expand All @@ -257,9 +257,9 @@
if (donor_frac == nullptr) {
listptr->nweights = 8;
listptr->weights =
(double*)malloc(sizeof(double) * (listptr->nweights * 2));

Check warning on line 260 in src/CartBlock.C

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

performing an implicit widening conversion to type 'unsigned long' of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]
listptr->inode =
(int*)malloc(sizeof(int) * (listptr->nweights * 2 * 3));

Check warning on line 262 in src/CartBlock.C

View workflow job for this annotation

GitHub Actions / Lint-clang-tidy

performing an implicit widening conversion to type 'unsigned long' of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]

cart_interp::linear_interpolation(
nf, ix, dims, rst, &(listptr->nweights), listptr->inode,
Expand Down Expand Up @@ -311,7 +311,7 @@
(j - nf) * (dims[0] + 1) + (i - nf) + ncell;
}

if (!(pointid >= 0 && pointid < ncell + nnode)) {
if (pointid < 0 || pointid >= ncell + nnode) {
TRACEI(index);
TRACEI(nf);
TRACEI(dims[0]);
Expand Down Expand Up @@ -463,7 +463,7 @@
}
}
} else {
if ((temp = donorList[idof]) != nullptr) {

Check warning on line 466 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 +627,7 @@
}
}
} else {
if ((temp = donorList[idof]) != nullptr) {

Check warning on line 630 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 @@ -739,7 +739,7 @@
}
if (bid == 0) {
fprintf(fp, "TITLE =\"Tioga output\"\n");
fprintf(fp, "VARIABLES=\"X\",\"Y\",\"Z\",\"IBLANK_CELL\" ");
fprintf(fp, R"(VARIABLES="X","Y","Z","IBLANK_CELL" )");
fprintf(fp, "\n");
}
fprintf(
Expand Down Expand Up @@ -798,5 +798,4 @@
}

fclose(fp);
return;
}
4 changes: 2 additions & 2 deletions src/CartGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class CartGrid
CartGrid() = default;
~CartGrid();

void registerData(TIOGA::AMRMeshInfo* m_info);
void registerData(TIOGA::AMRMeshInfo* minfo);
void
registerData(int nf, const int* idata, const double* rdata, int ngridsin);
void preprocess();
void search(double* x, int* donorid, int nsearch);
void search(double* x, int* donorid, int npts);
void setcallback(void (*f1)(int*, double*, int*, double*))
{
donor_frac = f1;
Expand Down
15 changes: 6 additions & 9 deletions src/MeshBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <vector>
#include <stdexcept>
#include <algorithm>
#include <unordered_set>
#include "mpi.h"
#include "codetypes.h"
#include "MeshBlock.h"
#include "TiogaMeshInfo.h"
#include "tioga_gpu.h"
#include "linklist.h"
#include "tioga_math.h"
Expand Down Expand Up @@ -830,7 +829,7 @@ void MeshBlock::writeCellFile(int bid)
snprintf(fname, sizeof(fname), "cell%s.dat", &(intstring[1]));
fp = fopen(fname, "w");
fprintf(fp, "TITLE =\"Tioga output\"\n");
fprintf(fp, "VARIABLES=\"X\",\"Y\",\"Z\",\"IBLANK\",\"IBLANK_CELL\" ");
fprintf(fp, R"(VARIABLES="X","Y","Z","IBLANK","IBLANK_CELL" )");
fprintf(fp, "\n");
fprintf(
fp, "ZONE T=\"VOL_MIXED\",N=%d E=%d ET=BRICK, F=FEBLOCK\n", nnodes,
Expand Down Expand Up @@ -917,7 +916,7 @@ void MeshBlock::writeFlowFile(int bid, double* q, int nvar, int type)
snprintf(fname, sizeof(fname), "flow%s.tec", &(intstring[1]));
fp = fopen(fname, "w");
fprintf(fp, "TITLE =\"Tioga output\"\n");
fprintf(fp, "VARIABLES=\"X\",\"Y\",\"Z\",\"IBLANK\",\"BTAG\"");
fprintf(fp, R"(VARIABLES="X","Y","Z","IBLANK","BTAG")");
for (i = 0; i < nvar; i++) {
snprintf(qstr, sizeof(qstr), "Q%d", i);
fprintf(fp, ",\"%s\"", qstr);
Expand Down Expand Up @@ -1120,12 +1119,12 @@ void MeshBlock::writeBCnodes(char nodetype2tag, int bodyid)
char filename[100];
FILE* fp;

int sbuffer = 1;
const int sbuffer = 1;
int rbuffer;
int i, ii, i3;

// set node type data
int nbc = (nodetype2tag == WALLNODETYPE) ? nwbc : nobc;
const int nbc = (nodetype2tag == WALLNODETYPE) ? nwbc : nobc;
int* bcnode = (nodetype2tag == WALLNODETYPE) ? wbcnode : obcnode;

int allnbc = 0;
Expand Down Expand Up @@ -1948,9 +1947,7 @@ MeshBlock::~MeshBlock()
if (nodeRes != nullptr) TIOGA_FREE(nodeRes);
if (elementBbox != nullptr) TIOGA_FREE(elementBbox);
if (elementList != nullptr) TIOGA_FREE(elementList);
if (adt != nullptr) {
delete[] adt;
}
delete[] adt;
if (donorList != nullptr) {
for (i = 0; i < nnodes; i++) {
deallocateLinkList(donorList[i]);
Expand Down
4 changes: 2 additions & 2 deletions src/MeshBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,10 @@ class MeshBlock
uint8_t* tagList);

void getQueryPoints(
OBB* obb, int* nints, int** intData, int* nreals, double** realData);
OBB* obc, int* nints, int** intData, int* nreals, double** realData);

void getQueryPoints2(
OBB* obb, int* nints, int** intData, int* nreals, double** realData);
OBB* obc, int* nints, int** intData, int* nreals, double** realData);

/** routines that do book keeping */

Expand Down
Loading