Commit f9aeaa60 authored by js9's avatar js9

Fixing a whole bunch of warnings, especially ones that were real bugs.

More info....

Arrays in the visit_* font .h files had values >255 but were of type unsigned char.
Many comparisons of char*'s with char*'s by pointer.  Convert to real string compare.
Sprintf's with too few arguments.
Sscanf's with a 32-bit %format trying to fill a 64-bit operand
Printf should use %p for pointers, not %x.
Missing cases in switch statements.
Order of operations undefined (e.g. "line == line++;").
Much use of string literals as values to char*, used const char* or casted instead.
Use of "char" as an index into an array.  Cast to unsigned char before use.
Some timer handle mismatches between start and stop.
Static function prototypes declared in header files with definitions in .C files.
Some lines with "if (a=b)" should have read "if (a==b)".  I changed those.
Others with "if (a=b)" were correct, and I made them "if ((a=b))"
Fixed the order of many constructor initializers
Added missing return statements from non-void functions, or made the function void.
Removed extraneous "\"s at the end of some comments (multiline comment possible)
Removed unnecessary modifier flags in scanf format strings.
Multiline string literals are deprecated.  Made them terminate at line endings.
Python code generation now uses const char* for string literals.
va_arg won't accept enums; they're promoted to int's.  So I changed a va_arg parser
to retrieve an int, then cast to the right enum aftwards.
Checking "if(buff)" when buff is defined as char[256] is always true.
ColorAttribute.xml was broken.




git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@4783 18c085ea-50e0-402c-830e-de6fd14e8384
parent 980c72d4
......@@ -970,8 +970,14 @@ avtScalarMetaData::BuildEnumNChooseRMap(int n, int maxr, std::vector<std::vector
// Function: Bi-nomial coefficient (n-choose-r)
//
// Programmer: Mark C. Miller, Thu Mar 27 14:16:45 PDT 2008
//
// Modifications:
// Jeremy Meredith, Thu Aug 7 14:24:38 EDT 2008
// Made it member function so that we got the static namespace benefits
// without the warnings that static functions in headers tend to generate.
//
// ****************************************************************************
double NChooseR(int n, int r)
double avtScalarMetaData::NChooseR(int n, int r)
{
if (n == 0)
{
......@@ -1001,10 +1007,16 @@ double NChooseR(int n, int r)
// ids (digits representing enum set membership)
//
// Programmer: Mark C. Miller, Thu Mar 27 14:16:45 PDT 2008
//
// Modifications:
// Jeremy Meredith, Thu Aug 7 14:24:38 EDT 2008
// Made it member function so that we got the static namespace benefits
// without the warnings that static functions in headers tend to generate.
//
// ****************************************************************************
void
ComboValFromDigits(const std::vector<std::vector<int> > &ptMap,
avtScalarMetaData::ComboValFromDigits(const std::vector<std::vector<int> > &ptMap,
const std::list<int> &digits, double *id)
{
int row, col;
......@@ -1025,10 +1037,16 @@ ComboValFromDigits(const std::vector<std::vector<int> > &ptMap,
// set membership) to single numerical value.
//
// Programmer: Mark C. Miller, Thu Mar 27 14:16:45 PDT 2008
//
// Modifications:
// Jeremy Meredith, Thu Aug 7 14:24:38 EDT 2008
// Made it member function so that we got the static namespace benefits
// without the warnings that static functions in headers tend to generate.
//
// ****************************************************************************
void
ComboDigitsFromVal(double id, int n, int maxr,
avtScalarMetaData::ComboDigitsFromVal(double id, int n, int maxr,
const std::vector<std::vector<int> > &ptMap, std::list<int> &digits)
{
int row, col, grp;
......
......@@ -465,8 +465,14 @@ Definition:
// Function: Bi-nomial coefficient (n-choose-r)
//
// Programmer: Mark C. Miller, Thu Mar 27 14:16:45 PDT 2008
//
// Modifications:
// Jeremy Meredith, Thu Aug 7 14:24:38 EDT 2008
// Made it member function so that we got the static namespace benefits
// without the warnings that static functions in headers tend to generate.
//
// ****************************************************************************
double NChooseR(int n, int r)
double avtScalarMetaData::NChooseR(int n, int r)
{
if (n == 0)
{
......@@ -499,10 +505,16 @@ Definition:
// ids (digits representing enum set membership)
//
// Programmer: Mark C. Miller, Thu Mar 27 14:16:45 PDT 2008
//
// Modifications:
// Jeremy Meredith, Thu Aug 7 14:24:38 EDT 2008
// Made it member function so that we got the static namespace benefits
// without the warnings that static functions in headers tend to generate.
//
// ****************************************************************************
void
ComboValFromDigits(const std::vector<std::vector<int> > &ptMap,
avtScalarMetaData::ComboValFromDigits(const std::vector<std::vector<int> > &ptMap,
const std::list<int> &digits, double *id)
{
int row, col;
......@@ -526,10 +538,16 @@ Definition:
// set membership) to single numerical value.
//
// Programmer: Mark C. Miller, Thu Mar 27 14:16:45 PDT 2008
//
// Modifications:
// Jeremy Meredith, Thu Aug 7 14:24:38 EDT 2008
// Made it member function so that we got the static namespace benefits
// without the warnings that static functions in headers tend to generate.
//
// ****************************************************************************
void
ComboDigitsFromVal(double id, int n, int maxr,
avtScalarMetaData::ComboDigitsFromVal(double id, int n, int maxr,
const std::vector<std::vector<int> > &ptMap, std::list<int> &digits)
{
int row, col, grp;
......
......@@ -132,6 +132,9 @@ public:
void SetEnumAlwaysIncludeValue(double val);
void SetEnumAlwaysIncludeRange(double min, double max);
static void BuildEnumNChooseRMap(int n, int maxr, std::vector<std::vector<int> > &ptMap);
static double NChooseR(int n, int r);
static void ComboValFromDigits(const std::vector<std::vector<int> > &ptMap, const std::list<int> &digits, double *id);
static void ComboDigitsFromVal(double id, int n, int maxr, const std::vector<std::vector<int> > &ptMap, std::list<int> &digits);
static void UpdateValByInsertingDigit(double *id, int n, int maxr, const std::vector<std::vector<int> > &ptMap, int newDigit);
// IDs that can be used to identify fields in case statements
......@@ -187,8 +190,4 @@ private:
static const char *TypeMapFormatString;
};
// User-defined functions
static double NChooseR(int n, int r);
static void ComboValFromDigits(const std::vector<std::vector<int> > &ptMap, const std::list<int> &digits, double *id);
static void ComboDigitsFromVal(double id, int n, int maxr, const std::vector<std::vector<int> > &ptMap, std::list<int> &digits);
#endif
......@@ -98,11 +98,11 @@
</Function>
<Function name="BuildEnumNChooseRMap" user="true" member="true">
</Function>
<Function name="NChooseR" user="true" member="false">
<Function name="NChooseR" user="true" member="true">
</Function>
<Function name="ComboValFromDigits" user="true" member="false">
<Function name="ComboValFromDigits" user="true" member="true">
</Function>
<Function name="ComboDigitsFromVal" user="true" member="false">
<Function name="ComboDigitsFromVal" user="true" member="true">
</Function>
<Function name="UpdateValByInsertingDigit" user="true" member="true">
</Function>
......
......@@ -543,6 +543,9 @@ avtSIL::AddArray(avtSILArray_p a)
// Dave Bremer, Tue Apr 1 15:13:05 PDT 2008
// Added code to add an entries to setTable and collTable
//
// Jeremy Meredith, Thu Aug 7 14:26:47 EDT 2008
// Removed unused variable.
//
// ****************************************************************************
void
......@@ -551,7 +554,6 @@ avtSIL::AddMatrix(avtSILMatrix_p m)
int i;
int coll_count = GetNumCollections();
int matrix_index = matrices.size();
m->SetSIL(this);
m->SetStartSet(GetNumSets());
......@@ -716,6 +718,12 @@ avtSIL::GetSILSet(int index, bool &isTemporary) const
// Modifications:
// Dave Bremer, Tue Apr 1 15:13:05 PDT 2008
// Rewrote to use FindSet
//
// Jeremy Meredith, Thu Aug 7 14:27:16 EDT 2008
// Throw an exception if we get an unhandled SIL. Since this path
// currently returned no value from a non-void function, obviously
// an Exception should be at least as safe as that.
//
// ****************************************************************************
avtSILSet_p
......@@ -754,6 +762,8 @@ avtSIL::GetSILSetInternal(int index, bool &isTemporary, bool returnNullIfTempora
rv = matrices[iLocalIndex]->GetSILSet(iLocalSubIndex);
//AddMapsToTemporarySet(rv, index);
return rv;
default:
EXCEPTION1(ImproperUseException, "Unexpected SIL set type");
}
}
......@@ -773,6 +783,11 @@ avtSIL::GetSILSetInternal(int index, bool &isTemporary, bool returnNullIfTempora
// Dave Bremer, Tue Apr 1 15:13:05 PDT 2008
// Rewrote to use FindSet
//
// Jeremy Meredith, Thu Aug 7 14:27:16 EDT 2008
// Throw an exception if we get an unhandled SIL. Since this path
// currently returned no value from a non-void function, obviously
// an Exception should be at least as safe as that.
//
// ****************************************************************************
int
......@@ -797,6 +812,8 @@ avtSIL::GetSILSetID(int index) const
return arrays[iLocalIndex]->GetSILSetID(iLocalSubIndex);
case MATRIX:
return matrices[iLocalIndex]->GetSILSetID(iLocalSubIndex);
default:
EXCEPTION1(ImproperUseException, "Unexpected SIL set type");
}
}
......@@ -815,6 +832,11 @@ avtSIL::GetSILSetID(int index) const
// Dave Bremer, Tue Apr 1 15:13:05 PDT 2008
// Rewrote to use FindSet
//
// Jeremy Meredith, Thu Aug 7 14:27:16 EDT 2008
// Throw an exception if we get an unhandled SIL. Since this path
// currently returned no value from a non-void function, obviously
// an Exception should be at least as safe as that.
//
// ****************************************************************************
bool
......@@ -845,6 +867,8 @@ avtSIL::SILSetHasMapsOut(int index) const
return false;
case MATRIX:
return false;
default:
EXCEPTION1(ImproperUseException, "Unexpected SIL set type");
}
}
......@@ -910,6 +934,12 @@ avtSIL::AddMapsToTemporarySet(avtSILSet_p pSet, int setIndex) const
//
// Dave Bremer, Tue Apr 1 15:13:05 PDT 2008
// Rewrote to use FindColl
//
// Jeremy Meredith, Thu Aug 7 14:27:16 EDT 2008
// Throw an exception if we get an unhandled SIL. Since this path
// currently returned no value from a non-void function, obviously
// an Exception should be at least as safe as that.
//
// ****************************************************************************
avtSILCollection_p
......@@ -933,6 +963,8 @@ avtSIL::GetSILCollection(int index) const
return arrays[iLocalIndex]->GetSILCollection();
case MATRIX:
return matrices[iLocalIndex]->GetSILCollection(iLocalSubIndex);
default:
EXCEPTION1(ImproperUseException, "Unexpected SIL set type");
}
}
......@@ -960,6 +992,10 @@ avtSIL::GetSILCollection(int index) const
//
// Dave Bremer, Tue Apr 1 15:13:05 PDT 2008
// Rewrote to iterate through setTable.
//
// Jeremy Meredith, Thu Aug 7 14:29:02 EDT 2008
// Added a default case to avoid warnings.
//
// ****************************************************************************
int
......@@ -1008,6 +1044,8 @@ avtSIL::GetSetIndex(const std::string &name, int collID) const
//Skip this because apparently this method will never be called
//with the name of a set contained in a matrix.
break;
default:
break;
}
}
EXCEPTION1(InvalidVariableException, name);
......@@ -1039,6 +1077,10 @@ avtSIL::GetSetIndex(const std::string &name, int collID) const
//
// Dave Bremer, Tue Apr 1 15:13:05 PDT 2008
// Rewrote to iterate through collTable.
//
// Jeremy Meredith, Thu Aug 7 14:29:02 EDT 2008
// Added a default case to avoid warnings.
//
// ****************************************************************************
int
......@@ -1066,6 +1108,8 @@ avtSIL::GetCollectionIndex(std::string name, int superset) const
//Skip this because apparently this method will never be called
//with the name of a collection contained in a matrix.
break;
default:
break;
}
}
EXCEPTION1(InvalidVariableException, name);
......@@ -1094,6 +1138,9 @@ avtSIL::GetCollectionIndex(std::string name, int superset) const
// Kathleen Bonnell, Tue Jun 3 08:13:27 PDT 2008
// Remove unreferenced variable.
//
// Jeremy Meredith, Thu Aug 7 14:29:02 EDT 2008
// Added a default case to avoid warnings.
//
// ****************************************************************************
avtSIL::EntryType
......@@ -1126,6 +1173,9 @@ avtSIL::GetCollectionSource(int index,
outMatrix = matrices[iLocalIndex];
outIndex = iLocalSubIndex;
return MATRIX;
default:
// Fall out to exception
break;
}
EXCEPTION2(BadIndexException, index, GetNumCollections());
}
......
......@@ -150,6 +150,10 @@ avtSILRestrictionTraverser::Equal(avtSILRestriction_p silr2)
// Programmer: Jeremy Meredith
// Creation: August 28, 2006
//
// Modifications:
// Jeremy Meredith, Thu Aug 7 14:30:09 EDT 2008
// Removed unusued vars.
//
// ****************************************************************************
int
......@@ -164,8 +168,6 @@ avtSILRestrictionTraverser::GetEnumerationCount()
//
// Identify the collection that has role of an enumeration
//
const vector<unsigned char> &useSet = silr->useSet;
bool foundOneOff = false;
for (i = 0 ; i < mapsOut.size() ; i++)
{
avtSILCollection_p coll = silr->GetSILCollection(mapsOut[i]);
......
......@@ -79,8 +79,8 @@ using std::vector;
//
// Static data members
//
char *avtDatabaseFactory::fallbackFormat = "Silo";
char *avtDatabaseFactory::formatToTryFirst = NULL;
char *avtDatabaseFactory::fallbackFormat = strdup("Silo");// not const; can't
char *avtDatabaseFactory::formatToTryFirst = NULL; // use literal as-is
bool avtDatabaseFactory::createMeshQualityExpressions = true;
bool avtDatabaseFactory::createTimeDerivativeExpressions = true;
bool avtDatabaseFactory::createVectorMagnitudeExpressions = true;
......
......@@ -4127,6 +4127,9 @@ avtGenericDatabase::EnumScalarSelect(avtDatasetCollection &dsc,
// Jeremy Meredith, Tue Jun 7 10:55:18 PDT 2005
// Allowed empty domains.
//
// Jeremy Meredith, Wed Aug 6 18:08:33 EDT 2008
// Changed char* to const char* to fix warning.
//
// ****************************************************************************
void
......@@ -4134,7 +4137,7 @@ avtGenericDatabase::SpeciesSelect(avtDatasetCollection &dsc,
intVector &domains, boolVector &specList,
avtDataRequest_p &spec, avtSourceFromDatabase *src)
{
char *progressString = "Doing species selection";
const char *progressString = "Doing species selection";
src->DatabaseProgress(0, 0, progressString);
int timestep = spec->GetTimestep();
......
......@@ -115,6 +115,10 @@ avtSymmEvalExpression::AddInputVariableName(const char *vname)
// Programmer: Hank Childs
// Creation: January 21, 2006
//
// Modifications:
// Jeremy Meredith, Thu Aug 7 14:33:34 EDT 2008
// Use %ld for long integers.
//
// ****************************************************************************
void
......@@ -156,7 +160,7 @@ avtSymmEvalExpression::ProcessArguments(ArgsExpr *args,
if (elems->size() != GetNumberOfInputParameters())
{
char msg[1024];
SNPRINTF(msg, 1024, "%s. You're list had %d numbers, where %d were "
SNPRINTF(msg, 1024, "%s. You're list had %ld numbers, where %d were "
"expected.", badSyntaxMsg, elems->size(),
GetNumberOfInputParameters());
EXCEPTION2(ExpressionException, outputVariableName, msg);
......
......@@ -103,6 +103,10 @@ avtCurvatureExpression::~avtCurvatureExpression()
// Programmer: Hank Childs
// Creation: May 11, 2006
//
// Modifications:
// Jeremy Meredith, Thu Aug 7 14:33:06 EDT 2008
// Removed unused var.
//
// ****************************************************************************
vtkDataArray *
......@@ -133,8 +137,6 @@ avtCurvatureExpression::DeriveVariable(vtkDataSet *in_ds)
vtkPolyData *out = curvatures->GetOutput();
vtkDataArray *curvature = out->GetPointData()->GetArray(
doGauss ? "Gauss_Curvature" : "Mean_Curvature");
bool shouldDelete = false;
vtkFloatArray *flt_curvature = vtkFloatArray::New();
int npts = pd->GetNumberOfPoints();
flt_curvature->SetNumberOfTuples(npts);
......
......@@ -245,6 +245,8 @@ avtPerformColorTableLookupExpression::ProcessArguments(ArgsExpr *args,
// Creation: Tue Jan 8 17:04:08 PST 2008
//
// Modifications:
// Jeremy Meredith, Wed Aug 6 17:23:47 EDT 2008
// Assumed an "if (a=b)" line should have read "if (a==b)".
//
// ****************************************************************************
......@@ -292,7 +294,7 @@ avtPerformColorTableLookupExpression::DoOperation(vtkDataArray *in, vtkDataArray
// vtkSkewLookupTable. For vtkLogLookupTable it works fine, though. As a workaround, we manually check
// whether we are dealing with "Skew" lookup and cast vtkLookupTable manually to vtkSkewLookupTable if
// necessary.
if (mLUTMapping = Skew)
if (mLUTMapping == Skew)
col = dynamic_cast<vtkSkewLookupTable*>(vtkLUT)->MapValue(in->GetTuple1(i));
else
col = vtkLUT->MapValue(in->GetTuple1(i));
......
......@@ -57,6 +57,10 @@ class ExprPipelineState;
//
// Kathleen Bonnell, Fri Nov 17 08:32:54 PST 2006
// Added private CreateFilters(string) for FuncExpr class.
//
// Jeremy Meredith, Thu Aug 7 14:34:01 EDT 2008
// Reorder constructor initializers to be the correct order.
//
class EXPRESSION_API avtExprNode : public virtual ExprNode
......@@ -71,7 +75,7 @@ class EXPRESSION_API avtIntegerConstExpr
{
public:
avtIntegerConstExpr(const Pos &p, int v)
: avtExprNode(p), IntegerConstExpr(p,v), ExprNode(p) {}
: ExprNode(p), avtExprNode(p), IntegerConstExpr(p,v) {}
virtual void CreateFilters(ExprPipelineState *);
};
......@@ -80,7 +84,7 @@ class EXPRESSION_API avtFloatConstExpr
{
public:
avtFloatConstExpr(const Pos &p, float v)
: avtExprNode(p), FloatConstExpr(p,v), ExprNode(p) {}
: ExprNode(p), avtExprNode(p), FloatConstExpr(p,v) {}
virtual void CreateFilters(ExprPipelineState *);
};
......@@ -89,7 +93,7 @@ class EXPRESSION_API avtStringConstExpr
{
public:
avtStringConstExpr(const Pos &p, std::string v)
: avtExprNode(p), StringConstExpr(p,v), ExprNode(p) {}
: ExprNode(p), avtExprNode(p), StringConstExpr(p,v) {}
virtual void CreateFilters(ExprPipelineState *);
};
......@@ -98,7 +102,7 @@ class EXPRESSION_API avtBooleanConstExpr
{
public:
avtBooleanConstExpr(const Pos &p, bool v)
: avtExprNode(p), BooleanConstExpr(p,v), ExprNode(p) {}
: ExprNode(p), avtExprNode(p), BooleanConstExpr(p,v) {}
virtual void CreateFilters(ExprPipelineState *);
};
......@@ -107,7 +111,7 @@ class EXPRESSION_API avtUnaryExpr
{
public:
avtUnaryExpr(const Pos &p, char o, ExprNode *e)
: avtExprNode(p), UnaryExpr(p,o,e), ExprNode(p) {}
: ExprNode(p), avtExprNode(p), UnaryExpr(p,o,e) {}
virtual void CreateFilters(ExprPipelineState *);
};
......@@ -115,7 +119,7 @@ class EXPRESSION_API avtBinaryExpr : public avtExprNode, public BinaryExpr
{
public:
avtBinaryExpr(const Pos &p, char o, ExprNode *l, ExprNode *r)
: avtExprNode(p), BinaryExpr(p, o, l, r), ExprNode(p) {}
: ExprNode(p), avtExprNode(p), BinaryExpr(p, o, l, r) {}
virtual void CreateFilters(ExprPipelineState *);
};
......@@ -123,7 +127,7 @@ class EXPRESSION_API avtIndexExpr : public avtExprNode, public IndexExpr
{
public:
avtIndexExpr(const Pos &p, ExprNode *e, int ind)
: avtExprNode(p), IndexExpr(p,e,ind), ExprNode(p) {}
: ExprNode(p), avtExprNode(p), IndexExpr(p,e,ind) {}
virtual void CreateFilters(ExprPipelineState *);
};
......@@ -131,7 +135,7 @@ class EXPRESSION_API avtVectorExpr : public avtExprNode, public VectorExpr
{
public:
avtVectorExpr(const Pos &p, ExprNode *x, ExprNode *y, ExprNode *z=NULL)
: avtExprNode(p), VectorExpr(p,x,y,z), ExprNode(p) {}
: ExprNode(p), avtExprNode(p), VectorExpr(p,x,y,z) {}
virtual void CreateFilters(ExprPipelineState *);
};
......@@ -139,7 +143,7 @@ class EXPRESSION_API avtFunctionExpr : public avtExprNode, public FunctionExpr
{
public:
avtFunctionExpr(const Pos &p, std::string n, ArgsExpr *e=NULL)
: avtExprNode(p), FunctionExpr(p,n,e), ExprNode(p) {}
: ExprNode(p), avtExprNode(p), FunctionExpr(p,n,e) {}
virtual void CreateFilters(ExprPipelineState *);
private:
avtExpressionFilter *CreateFilters(std::string);
......@@ -149,7 +153,7 @@ class EXPRESSION_API avtVarExpr : public avtExprNode, public VarExpr
{
public:
avtVarExpr(const Pos &p, DBExpr *d, PathExpr *v, bool exp)
: avtExprNode(p), VarExpr(p,d,v,exp), ExprNode(p) {}
: ExprNode(p), avtExprNode(p), VarExpr(p,d,v,exp) {}
virtual void CreateFilters(ExprPipelineState *);
};
......
......@@ -166,6 +166,9 @@ avtVerdictExpression::~avtVerdictExpression()
// Hank Childs, Thu Jul 24 12:38:34 PDT 2008
// Add support for polygons and polyhedrons.
//
// Jeremy Meredith, Thu Aug 7 14:30:46 EDT 2008
// Made string literal const char*, not char*.
//
// ****************************************************************************
vtkDataArray *
......@@ -221,8 +224,8 @@ avtVerdictExpression::DeriveVariable(vtkDataSet *in_ds)
static bool issuedWarning = false;
if (!issuedWarning)