Skip to content

Commit

Permalink
This commit addresses all of the warnings and non-compliance issues i…
Browse files Browse the repository at this point in the history
…dentified by Clang and Clang++. They are all minor. The result passes 'ctest -L long' but pyEXP-example notebooks have not been run.
  • Loading branch information
Martin D. Weinberg committed Oct 16, 2024
1 parent 7d9cf63 commit 0218739
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 88 deletions.
10 changes: 5 additions & 5 deletions expui/BiorthBasis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ namespace BasisClasses
{
// Sanity check on derived class type
//
if (typeid(*coef) != typeid(CoefClasses::SphStruct))
if (typeid(coef.get()) != typeid(CoefClasses::SphStruct*))
throw std::runtime_error("Spherical::set_coefs: you must pass a CoefClasses::SphStruct");

// Sanity check on dimensionality
Expand Down Expand Up @@ -1431,7 +1431,7 @@ namespace BasisClasses

void Cylindrical::set_coefs(CoefClasses::CoefStrPtr coef)
{
if (typeid(*coef) != typeid(CoefClasses::CylStruct))
if (typeid(coef.get()) != typeid(CoefClasses::CylStruct*))
throw std::runtime_error("Cylindrical::set_coefs: you must pass a CoefClasses::CylStruct");

CoefClasses::CylStruct* cf = dynamic_cast<CoefClasses::CylStruct*>(coef.get());
Expand Down Expand Up @@ -1708,7 +1708,7 @@ namespace BasisClasses
{
// Sanity check on derived class type
//
if (typeid(*coef) != typeid(CoefClasses::CylStruct))
if (typeid(coef.get()) != typeid(CoefClasses::CylStruct*))
throw std::runtime_error("FlatDisk::set_coefs: you must pass a CoefClasses::CylStruct");

// Sanity check on dimensionality
Expand Down Expand Up @@ -2140,7 +2140,7 @@ namespace BasisClasses
{
// Sanity check on derived class type
//
if (typeid(*coef) != typeid(CoefClasses::SlabStruct))
if (typeid(coef) != typeid(CoefClasses::SlabStruct*))
throw std::runtime_error("Slab::set_coefs: you must pass a CoefClasses::SlabStruct");

// Sanity check on dimensionality
Expand Down Expand Up @@ -2572,7 +2572,7 @@ namespace BasisClasses
{
// Sanity check on derived class type
//
if (typeid(*coef) != typeid(CoefClasses::CubeStruct))
if (typeid(coef.get()) != typeid(CoefClasses::CubeStruct*))
throw std::runtime_error("Cube::set_coefs: you must pass a CoefClasses::CubeStruct");

// Sanity check on dimensionality
Expand Down
6 changes: 3 additions & 3 deletions expui/CoefContainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace MSSA
unpack_cylfld();
}
else {
throw std::runtime_error(std::string("CoefDB::unpack_channels(): can not reflect coefficient type=") + typeid(*coefs.get()).name());
throw std::runtime_error(std::string("CoefDB::unpack_channels(): can not reflect coefficient type=") + typeid(coefs.get()).name());
}

return coefs;
Expand All @@ -91,7 +91,7 @@ namespace MSSA
else if (dynamic_cast<CoefClasses::CylFldCoefs*>(coefs.get()))
{ } // Do nothing
else {
throw std::runtime_error(std::string("CoefDB::background(): can not reflect coefficient type=") + typeid(*coefs.get()).name());
throw std::runtime_error(std::string("CoefDB::background(): can not reflect coefficient type=") + typeid(coefs.get()).name());
}
}

Expand All @@ -112,7 +112,7 @@ namespace MSSA
else if (dynamic_cast<CoefClasses::CylFldCoefs*>(coefs.get()))
pack_cylfld();
else {
throw std::runtime_error(std::string("CoefDB::pack_channels(): can not reflect coefficient type=") + typeid(*coefs.get()).name());
throw std::runtime_error(std::string("CoefDB::pack_channels(): can not reflect coefficient type=") + typeid(coefs.get()).name());
}
}

Expand Down
7 changes: 4 additions & 3 deletions exputil/BarrierWrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ void BarrierWrapper::light_operator(const string& label,

// Compare adjacent strings in the list
if (localid==0) {
char tmp[cbufsz]; // Working buffer
// Working buffer
auto tmp = std::make_unique<char[]>(cbufsz);
bool firstime = true;
string one, two = strncpy(tmp, &bufferT[0], cbufsz);
string one, two = strncpy(tmp.get(), &bufferT[0], cbufsz);
for (int n=1; n<commsize; n++) {
one = two;
two = strncpy(tmp, &bufferT[cbufsz*n], cbufsz);
two = strncpy(tmp.get(), &bufferT[cbufsz*n], cbufsz);
if (one.compare(two) != 0) {
if (firstime) {
cout << std::string(60,'-') << std::endl << left
Expand Down
2 changes: 1 addition & 1 deletion exputil/EmpCylSL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5875,7 +5875,7 @@ void EmpCylSL::dump_images(const string& OUTFILE,
//============
// Open files
//============
std::ofstream out[Number];
auto out = std::make_unique<std::ofstream[]>(Number);
for (int j=0; j<Number; j++) {
Name = OUTFILE + Types[j] + ".eof_recon";
out[j].open(Name.c_str());
Expand Down
20 changes: 8 additions & 12 deletions exputil/GaussCore.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,18 @@
/*
Forward declaration for function QQp:
*/
static int QQp();
static int QQp(double, double*, double*);

/*
Function to test a real value for exceeding -1,
and quit on an error if condition not met.
*/
void GaussCheck(value)
double value;
void GaussCheck(double value)
{
if (value <= (-1.0)) {
fprintf(stderr, "Gauss package: parameter out of range: %g\n", value);
exit(1);
}
if (value <= (-1.0)) {
fprintf(stderr, "Gauss package: parameter out of range: %g\n", value);
exit(1);
}
}


Expand All @@ -54,11 +53,8 @@ static int n1;
/*
The workhorse.
*/
void GaussMaster(n, alpha, beta, conflag, abscis, weight)
int n;
double alpha, beta;
int conflag;
double abscis[], weight[];
void GaussMaster(int n, double alpha, double beta, int conflag,
double abscis[], double weight[])
{
#define FALSE 0
#define TRUE 1
Expand Down
6 changes: 4 additions & 2 deletions exputil/GaussCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
#define CONFLUENT 1
#define NOCONFLUENT 0

extern void GaussMaster();
extern void GaussCheck();
extern void GaussMaster(int n, double alpha, double beta, int conflag,
double abscis[], double weight[]);

extern void GaussCheck(double value);

/* ARGUMENT LISTS:
Expand Down
13 changes: 4 additions & 9 deletions exputil/Hermite.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
*/
#define odd(n) ((unsigned)(n) & 01)

void Odd_Hermite(n, alpha, abscis, weight, w0)
int n;
double alpha, abscis[], weight[], *w0;
void Odd_Hermite(int n, double alpha, double abscis[], double weight[],
double* w0)
{
int k;

Expand All @@ -41,9 +40,7 @@ double alpha, abscis[], weight[], *w0;
};


void Even_Hermite(n, alpha, abscis, weight)
int n;
double alpha, abscis[], weight[];
void Even_Hermite(int n, double alpha, double abscis[], double weight[])
{
int k;

Expand All @@ -59,9 +56,7 @@ double alpha, abscis[], weight[];
};


void Hermite(n, alpha, abscis, weight)
int n;
double alpha, abscis[], weight[];
void Hermite(int n, double alpha, double abscis[], double weight[])
{
int n1, k;

Expand Down
9 changes: 6 additions & 3 deletions exputil/Hermite.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
Translation of module Hermite (export).
*/

extern void Odd_Hermite();
extern void Even_Hermite();
extern void Hermite();
extern void Odd_Hermite(int n, double alpha, double abscis[], double weight[],
double* w0);

extern void Even_Hermite(int n, double alpha, double abscis[], double weight[]);

extern void Hermite(int n, double alpha, double abscis[], double weight[]);

/* ARGUMENT LISTS:
Expand Down
18 changes: 6 additions & 12 deletions exputil/Jacobi.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@

#define sqr(x) ((x)*(x))

void Jacobi(n, alpha, beta, abscis, weight)
int n;
double alpha, beta;
double abscis[], weight[];
void Jacobi(int n, double alpha, double beta, double abscis[], double weight[])
{
int k;

Expand All @@ -34,10 +31,8 @@ double abscis[], weight[];
}


void Radau_Jacobi(n, alpha, beta, abscis, weight, leftw)
int n;
double alpha, beta;
double abscis[], weight[], *leftw;
void Radau_Jacobi(int n, double alpha, double beta,
double abscis[], double weight[], double *leftw)
{
int k;
double temp;
Expand All @@ -62,10 +57,9 @@ double abscis[], weight[], *leftw;
};


void Lobatto_Jacobi(n, alpha, beta, abscis, weight, leftw, rightw)
int n;
double alpha, beta;
double abscis[], weight[], *leftw, *rightw;
void Lobatto_Jacobi(int n, double alpha, double beta,
double abscis[], double weight[],
double* leftw, double* rightw)
{
int k;
double temp1, temp2;
Expand Down
11 changes: 8 additions & 3 deletions exputil/Jacobi.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@
Translation of module Jacobi (export).
*/

extern void Jacobi(int n, double alpha, double beta,
double abscis[], double weight[]);

extern void Jacobi();
extern void Radau_Jacobi();
extern void Lobatto_Jacobi();
extern void Radau_Jacobi(int n, double alpha, double beta,
double abscis[], double weight[], double *leftw);

extern void Lobatto_Jacobi(int n, double alpha, double beta,
double abscis[], double weight[],
double* leftw, double* rightw);

/* ARGUMENT LISTS:
void Jacobi(n, alpha, beta, abscis, weight)
Expand Down
9 changes: 3 additions & 6 deletions exputil/Laguerre.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@
#include "GaussCore.h"
#include "Laguerre.h"

void Laguerre(n, alpha, abscis, weight)
int n;
double alpha, abscis[], weight[];
void Laguerre(int n, double alpha, double abscis[], double weight[])
{
GaussCheck(alpha);
GaussMaster(n, alpha, 0.0, CONFLUENT, abscis, weight);
};


void Radau_Laguerre(n, alpha, abscis, weight, leftw)
int n;
double alpha, abscis[], weight[], *leftw;
void Radau_Laguerre(int n, double alpha, double abscis[], double weight[],
double* leftw)
{
int k;
double temp;
Expand Down
6 changes: 4 additions & 2 deletions exputil/Laguerre.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
Translation of module Laguerre (export).
*/

extern void Laguerre();
extern void Radau_Laguerre();
extern void Laguerre(int n, double alpha, double abscis[], double weight[]);

extern void Radau_Laguerre(int n, double alpha,
double abscis[], double weight[], double* leftw);

/*
ARGUMENT LISTS:
Expand Down
13 changes: 7 additions & 6 deletions exputil/ParticleReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <iomanip>
#include <fstream>
#include <sstream>
#include <memory>
#include <numeric>
#include <string>
#include <vector>
Expand Down Expand Up @@ -530,11 +531,11 @@ namespace PR {

int rank = dataspace.getSimpleExtentNdims();

hsize_t dims[rank];
auto dims = std::make_unique<hsize_t[]>(rank);

int ndims = dataspace.getSimpleExtentDims(dims, NULL);
int ndims = dataspace.getSimpleExtentDims(dims.get(), NULL);

H5::DataSpace mspace(rank, dims);
H5::DataSpace mspace(rank, dims.get());

std::vector<float> masses(dims[0]);
dataset.read(&masses[0], H5::PredType::NATIVE_FLOAT, mspace, dataspace );
Expand Down Expand Up @@ -569,11 +570,11 @@ namespace PR {

int rank = dataspace.getSimpleExtentNdims();

hsize_t dims[rank];
auto dims = std::make_unique<hsize_t[]>(rank);

int ndims = dataspace.getSimpleExtentDims( dims, NULL);
int ndims = dataspace.getSimpleExtentDims( dims.get(), NULL);

H5::DataSpace mspace(rank, dims);
H5::DataSpace mspace(rank, dims.get());

std::vector<unsigned> seq(dims[0]);
dataset.read(&seq[0], H5::PredType::NATIVE_UINT32, mspace, dataspace );
Expand Down
2 changes: 1 addition & 1 deletion exputil/YamlConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ cxxopts::ParseResult LoadConfig(cxxopts::Options& options,
YAML::Node conf = YAML::LoadFile(config);

int count = conf.size()*2+1, cnt = 1;
char* data[count];
std::vector<char*> data(count);

data[0] = new char [11];
strcpy(data[0], "LoadConfig"); // Emulate the caller name
Expand Down
4 changes: 2 additions & 2 deletions include/EXPini.H
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ cxxopts::ParseResult LoadConfig(cxxopts::Options& options,
YAML::Node conf = YAML::LoadFile(config);

const int count = conf.size()*2+1;
char* data[count];
std::vector<char*> data(count);
int cnt = 1;

data[0] = new char [11];
Expand Down Expand Up @@ -131,7 +131,7 @@ cxxopts::ParseResult LoadConfig(cxxopts::Options& options,

auto vm = options.parse(cnt, &data[0]);

for (int i=0; i<cnt; i++) delete [] data[i];
for (auto & v : data) delete [] v;

return vm;
}
Expand Down
6 changes: 3 additions & 3 deletions utils/Analysis/gas2dcyl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ main(int argc, char **argv)
char *c = const_cast<char*>(files[n].c_str());
MPI_Bcast(c, sz+1, MPI_CHAR, 0, MPI_COMM_WORLD);
} else {
char l[sz+1];
MPI_Bcast(&l[0], sz+1, MPI_CHAR, 0, MPI_COMM_WORLD);
files.push_back(l);
auto l = std::make_unique<char[]>(sz+1);
MPI_Bcast(l.get(), sz+1, MPI_CHAR, 0, MPI_COMM_WORLD);
files.push_back(l.get());
}
MPI_Barrier(MPI_COMM_WORLD);
}
Expand Down
9 changes: 5 additions & 4 deletions utils/Analysis/psphisto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <memory>
#include <string>
#include <cmath>

// System libs
#include <sys/time.h>
Expand Down Expand Up @@ -177,9 +178,9 @@ main(int argc, char **argv)
char *c = const_cast<char*>(files[n].c_str());
MPI_Bcast(c, sz+1, MPI_CHAR, 0, MPI_COMM_WORLD);
} else {
char l[sz+1];
MPI_Bcast(&l[0], sz+1, MPI_CHAR, 0, MPI_COMM_WORLD);
files.push_back(l);
auto l = std::make_unique<char[]>(sz+1);
MPI_Bcast(l.get(), sz+1, MPI_CHAR, 0, MPI_COMM_WORLD);
files.push_back(l.get());
}
MPI_Barrier(MPI_COMM_WORLD);
}
Expand Down
Loading

0 comments on commit 0218739

Please sign in to comment.