Skip to content

Commit

Permalink
Fix various compiler warnings on macOS (#5313) (#5323)
Browse files Browse the repository at this point in the history
I had problems with the OpenMPD files because those had apparently been changed on `develop` to fix all the missing `[]` in the delete calls plus some other changes. So, I too `--ours` in the merge of those and then hit yet another conflict in one of those files that I then fixed by hand directly on GitHub.
  • Loading branch information
markcmiller86 committed Dec 19, 2020
1 parent 67d1fe4 commit 7be2032
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/avt/Expressions/Abstract/avtExpressionFilter.C
Expand Up @@ -365,7 +365,7 @@ avtExpressionFilter::UpdateExtents(avtDataTree_p tree)
// not referenced by the zone list.
//
unsigned char *referenced = NULL;
if (isPoint & ds->GetNumberOfCells() > 0)
if (isPoint && ds->GetNumberOfCells() > 0)
{
referenced = new unsigned char[data->GetNumberOfTuples()];
memset(referenced, 0, data->GetNumberOfTuples());
Expand Down
4 changes: 2 additions & 2 deletions src/common/expr/ExprNode.C
Expand Up @@ -323,7 +323,7 @@ ListExpr::PrintNode(ostream &o)
for (size_t i=0; i<elems->size(); i++)
{
char tmp[256];
snprintf(tmp, 256, "Element % 2zu: ", i);
snprintf(tmp, sizeof(tmp), "Element %2zu: ", i);
(*elems)[i]->Print(o,tmp);
}
}
Expand Down Expand Up @@ -397,7 +397,7 @@ ArgsExpr::PrintNode(ostream &o)
for (size_t i=0; i<args->size(); i++)
{
char tmp[256];
snprintf(tmp, 256, "Arg % 2zu: ", i);
snprintf(tmp, sizeof(tmp), "Arg %2zu: ", i);
(*args)[i]->Print(o, tmp);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/common/misc/DebugStream.h
Expand Up @@ -35,11 +35,11 @@ namespace DebugStream
extern MISC_API int GetLevel();
}

#define debug1 if (!DebugStream::Level1()) ; else (DebugStream::Stream1((char const *)__FILE__,(int)__LINE__))
#define debug2 if (!DebugStream::Level2()) ; else (DebugStream::Stream2())
#define debug3 if (!DebugStream::Level3()) ; else (DebugStream::Stream3())
#define debug4 if (!DebugStream::Level4()) ; else (DebugStream::Stream4())
#define debug5 if (!DebugStream::Level5()) ; else (DebugStream::Stream5())
#define debug1 DebugStream::Level1() && DebugStream::Stream1((char const *)__FILE__,(int)__LINE__)
#define debug2 DebugStream::Level2() && DebugStream::Stream2()
#define debug3 DebugStream::Level3() && DebugStream::Stream3()
#define debug4 DebugStream::Level4() && DebugStream::Stream4()
#define debug5 DebugStream::Level5() && DebugStream::Stream5()

#define vcerr(c) if (VisItInit::IsComponent(#c)) std::cerr << #c ": "

Expand Down
1 change: 1 addition & 0 deletions src/databases/IDX/pidx_idx_io.C
Expand Up @@ -87,6 +87,7 @@ VisitIDXIO::DTypes convertType(PIDX_data_type intype)
return VisitIDXIO::IDX_FLOAT64;

fprintf(stderr, "Type not found for PIDX\n");
return VisitIDXIO::UNKNOWN;
}


Expand Down
16 changes: 10 additions & 6 deletions src/databases/IDX/visit_idx_utils.h
Expand Up @@ -27,16 +27,20 @@ static inline float cfloat (std::string s) {float value;std::istringstream
static inline double cdouble(std::string s) {double value;std::istringstream iss(s);iss>>value;return value;}
static inline int cround (double x) { x = x + 0.5 - (x<0); return (int)x; }

// trim from start
// trim from start (in place)
static inline std::string &ltrim(std::string &s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
return s;
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
return !std::isspace(ch);
}));
return s;
}

// trim from end
// trim from end (in place)
static inline std::string &rtrim(std::string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
return s;
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
return !std::isspace(ch);
}).base(), s.end());
return s;
}

// trim from both ends
Expand Down
15 changes: 6 additions & 9 deletions src/databases/MFIXCDF/avtMFIXCDFFileFormat.C
Expand Up @@ -51,7 +51,6 @@
#define cbrt(x) (pow(x, 1.0/3.0))
#endif

using std::auto_ptr;
using std::vector;
using std::ostringstream;

Expand Down Expand Up @@ -1584,14 +1583,12 @@ avtMFIXCDFFileFormat::GetVectorVar(int domain, const char *varname)
nzvals= (widths[2]+3);
}

// This trick with auto_ptr makes xvec, yvec and zvec get deleted
// when they go out of scope.
auto_ptr< vector<float> > xvec(new vector<float>(totZones));
float* xdata= &(*xvec)[0];
auto_ptr< vector<float> > yvec(new vector<float>(totZones));
float* ydata= &(*yvec)[0];
auto_ptr< vector<float> > zvec(new vector<float>(totZones));
float* zdata= &(*zvec)[0];
vector<float> xvec(totZones);
vector<float> yvec(totZones);
vector<float> zvec(totZones);
float *xdata = &xvec[0];
float *ydata = &yvec[0];
float *zdata = &zvec[0];

if (!strncmp(varname,"Vel_",4))
{
Expand Down
7 changes: 2 additions & 5 deletions src/databases/OpenPMD/OpenPMDClasses/PMDFile.C
Expand Up @@ -217,8 +217,7 @@ void PMDFile::ScanFileAttributes()
// Read attribute
H5Aread (attrId, atype, buffer); // not NULL-terminated
buffer[size] = '\0';

this->meshesPath = buffer;
this->meshesPath = buffer; // string copy
delete [] buffer;

}
Expand All @@ -229,9 +228,7 @@ void PMDFile::ScanFileAttributes()
// Read attribute
H5Aread (attrId, atype, buffer); // not NULL-terminated
buffer[size] = '\0';

this->particlesPath = buffer;

this->particlesPath = buffer; // string copy
delete [] buffer;
}
}
Expand Down

0 comments on commit 7be2032

Please sign in to comment.