--Code Change

-Fix compiler warnings in XmlToEmber
This commit is contained in:
Seth Troisi 2022-02-13 00:30:56 -08:00
parent ee7ca7065e
commit 344c8c6457
10 changed files with 22 additions and 30 deletions

View File

@ -198,7 +198,10 @@ win32 {
QMAKE_CXXFLAGS += -Wmain QMAKE_CXXFLAGS += -Wmain
QMAKE_CXXFLAGS += -Wfatal-errors QMAKE_CXXFLAGS += -Wfatal-errors
QMAKE_CXXFLAGS += -Wall -fpermissive QMAKE_CXXFLAGS += -Wall -fpermissive
QMAKE_CXXFLAGS += -Wold-style-cast
# CL has lots of old-style-cast which clogs up warning logs
#QMAKE_CXXFLAGS += -Wold-style-cast
QMAKE_CXXFLAGS += -Wno-unused-parameter QMAKE_CXXFLAGS += -Wno-unused-parameter
QMAKE_CXXFLAGS += -Wno-unused-function QMAKE_CXXFLAGS += -Wno-unused-function
QMAKE_CXXFLAGS += -Wold-style-cast QMAKE_CXXFLAGS += -Wold-style-cast

View File

@ -53,8 +53,6 @@ bool EmberToXml<T>::Save(const string& filename, C<Ember<T>, Alloc>& embers, siz
if (f.is_open()) if (f.is_open())
{ {
const auto prev = embers.begin();
//Always ensure times make sense. //Always ensure times make sense.
for (auto& ember : embers) for (auto& ember : embers)
ember.m_Time = t++; ember.m_Time = t++;
@ -922,4 +920,4 @@ EXPORT_EMBER_TO_XML(float)
#ifdef DO_DOUBLE #ifdef DO_DOUBLE
EXPORT_EMBER_TO_XML(double) EXPORT_EMBER_TO_XML(double)
#endif #endif
} }

View File

@ -36,7 +36,7 @@ bool PaletteList<T>::AddPaletteFile(const string& filename, const vector<Palette
{ {
if (!GetPaletteListByFullPath(filename)) if (!GetPaletteListByFullPath(filename))
{ {
const auto item = s_Palettes.insert(make_pair(filename, palettes)); s_Palettes.insert(make_pair(filename, palettes));
Save(filename); Save(filename);
return true; return true;
} }

View File

@ -95,7 +95,7 @@ std::vector<T> Spline<T>::Interpolate(const std::vector<T>& newX)
{ {
std::vector<T> output; output.resize(newX.size()); std::vector<T> output; output.resize(newX.size());
for (int i = 0; i < newX.size(); i++) for (size_t i = 0; i < newX.size(); i++)
output[i] = Interpolate(newX[i]); output[i] = Interpolate(newX[i]);
return output; return output;

View File

@ -3608,7 +3608,6 @@ public:
} }
T tempx, tempy; T tempx, tempy;
T boost = 1;//Boost is the separation distance between the two planes.
T sumX, sumY; T sumX, sumY;
if (m_VarType == eVariationType::VARTYPE_REG) if (m_VarType == eVariationType::VARTYPE_REG)
@ -3629,6 +3628,7 @@ public:
//Creating Z factors relative to the planes. These will be added, whereas x and y will be assigned. //Creating Z factors relative to the planes. These will be added, whereas x and y will be assigned.
//Original does += z *, so using z on the right side of = is intentional. //Original does += z *, so using z on the right side of = is intentional.
if (m_MajPlane == 2) if (m_MajPlane == 2)
//Boost is the separation distance between the two planes.
helper.Out.z = helper.In.z * T(0.5) * m_ZLift + (posNeg * m_Boost); helper.Out.z = helper.In.z * T(0.5) * m_ZLift + (posNeg * m_Boost);
else else
helper.Out.z = helper.In.z * T(0.5) * m_ZLift; helper.Out.z = helper.In.z * T(0.5) * m_ZLift;

View File

@ -490,7 +490,6 @@ public:
/// <returns>The variation if found, else nullptr.</returns> /// <returns>The variation if found, else nullptr.</returns>
Variation<T>* RemoveVariationById(eVariationId id) Variation<T>* RemoveVariationById(eVariationId id)
{ {
bool found = false;
Variation<T>* var = nullptr; Variation<T>* var = nullptr;
AllVarsFunc([&](vector<Variation<T>*>& variations, bool & keepGoing) AllVarsFunc([&](vector<Variation<T>*>& variations, bool & keepGoing)
{ {
@ -736,9 +735,8 @@ public:
else else
{ {
//There are no variations, so the affine transformed points can be assigned directly to the output points. //There are no variations, so the affine transformed points can be assigned directly to the output points.
T inX = inPoint->m_X; outPoint->m_X = 0;//(m_Affine.A() * inPoint->m_X) + (m_Affine.B() * inPoint->m_Y) + m_Affine.C();
outPoint->m_X = 0;//(m_Affine.A() * inX) + (m_Affine.B() * inPoint->m_Y) + m_Affine.C(); outPoint->m_Y = 0;//(m_Affine.D() * inPoint->m_X) + (m_Affine.E() * inPoint->m_Y) + m_Affine.F();
outPoint->m_Y = 0;//(m_Affine.D() * inX) + (m_Affine.E() * inPoint->m_Y) + m_Affine.F();
outPoint->m_Z = 0;//inPoint->m_Z; outPoint->m_Z = 0;//inPoint->m_Z;
} }

View File

@ -682,7 +682,7 @@ static const char* CheckNameVal(xmlNode* node, const char* name)
} }
return nullptr; return nullptr;
}; }
/// <summary> /// <summary>
/// Helper function to verify that the name of a node /// Helper function to verify that the name of a node
@ -697,7 +697,7 @@ static xmlNode* CheckNodeName(xmlNode* node, const char* name)
return node; return node;
return nullptr; return nullptr;
}; }
/// <summary> /// <summary>
/// Helper function to get the value of the name field of a node. /// Helper function to get the value of the name field of a node.
@ -713,7 +713,7 @@ static const char* GetNameVal(xmlNode* node, const char* name = "name")
return CCX(attStr); return CCX(attStr);
return nullptr; return nullptr;
}; }
/// <summary> /// <summary>
/// Helper function to get the child of a node based on the value of its name field. /// Helper function to get the child of a node based on the value of its name field.
@ -729,7 +729,7 @@ static xmlNode* GetChildNode(xmlNode* node, const char* name)
return childNode; return childNode;
return nullptr; return nullptr;
}; }
/// <summary> /// <summary>
/// Helper function to get the child of a node based on the name of the child node. /// Helper function to get the child of a node based on the name of the child node.
@ -745,7 +745,7 @@ static xmlNode* GetChildNodeByNodeName(xmlNode* node, const char* name)
return node; return node;
return nullptr; return nullptr;
}; }
/// <summary> /// <summary>
/// Helper function to parse the content of a field of a node and convert the string into a value of type T and store in the passed in val parameter. /// Helper function to parse the content of a field of a node and convert the string into a value of type T and store in the passed in val parameter.
@ -849,7 +849,6 @@ void XmlToEmber<T>::ScanForChaosNodes(xmlNode* curNode, const char* parentFile,
currentEmber.m_Name = embername; currentEmber.m_Name = embername;
const auto childNode = thisNode; const auto childNode = thisNode;
bool ret = true;
parseEmberSuccess = ParseEmberElementFromChaos(childNode, currentEmber); parseEmberSuccess = ParseEmberElementFromChaos(childNode, currentEmber);
if (!parseEmberSuccess) if (!parseEmberSuccess)
@ -888,10 +887,7 @@ void XmlToEmber<T>::ScanForChaosNodes(xmlNode* curNode, const char* parentFile,
template <typename T> template <typename T>
bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& currentEmber) bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& currentEmber)
{ {
bool fromEmber = false, ret = true;
const char* loc = __FUNCTION__; const char* loc = __FUNCTION__;
int soloXform = -1;
size_t count = 0, index = 0;
T sensorWidth = 2; T sensorWidth = 2;
xmlAttrPtr att; xmlAttrPtr att;
currentEmber.m_Palette.Clear();//Wipe out the current palette. currentEmber.m_Palette.Clear();//Wipe out the current palette.
@ -918,7 +914,6 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
if (!varname.empty()) if (!varname.empty())
{ {
const T weight = 1;
const auto corrvarname = GetCorrectedVariationName(m_BadVariationNames, varname); const auto corrvarname = GetCorrectedVariationName(m_BadVariationNames, varname);
const auto corrwprefix = !StartsWith(corrvarname, prefix) ? prefix + corrvarname : corrvarname; const auto corrwprefix = !StartsWith(corrvarname, prefix) ? prefix + corrvarname : corrvarname;
@ -1264,7 +1259,6 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
if (const auto curvesnode = GetChildNodeByNodeName(childNode, "curves")) if (const auto curvesnode = GetChildNodeByNodeName(childNode, "curves"))
{ {
T val = 0;
auto curvenodesfunc = [&](xmlNode * node, int index) auto curvenodesfunc = [&](xmlNode * node, int index)
{ {
float x, y; float x, y;
@ -1289,15 +1283,15 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
{ {
bool haveknots = false, havevals = false; bool haveknots = false, havevals = false;
for (auto childNode = node->children; childNode; childNode = childNode->next) for (auto innerChildNode = node->children; innerChildNode; innerChildNode = innerChildNode->next)
{ {
if (childNode->type == XML_ELEMENT_NODE) if (innerChildNode->type == XML_ELEMENT_NODE)
{ {
if (const auto node = CheckNodeName(childNode, "table")) if (const auto innernode = CheckNodeName(innerChildNode, "table"))
{ {
if (!haveknots) if (!haveknots)
{ {
if (const auto knotvalsnode = GetChildNodeByNodeName(node, "values")) if (const auto knotvalsnode = GetChildNodeByNodeName(innernode, "values"))
{ {
if (knotvalsnode->children) if (knotvalsnode->children)
{ {
@ -1310,7 +1304,7 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
} }
else if (!havevals) else if (!havevals)
{ {
if (const auto valvalsnode = GetChildNodeByNodeName(node, "values")) if (const auto valvalsnode = GetChildNodeByNodeName(innernode, "values"))
{ {
if (valvalsnode->children) if (valvalsnode->children)
{ {

View File

@ -137,7 +137,7 @@ static string GetExePath(const char* argv0)
cerr << "Could not discern full path from executable.\n"; cerr << "Could not discern full path from executable.\n";
#else #else
auto fullsize = readlink("/proc/self/exe", v.data(), v.size()); readlink("/proc/self/exe", v.data(), v.size());
fullpath = string(v.data()); fullpath = string(v.data());
#endif #endif
#endif #endif

View File

@ -250,7 +250,6 @@ struct NoDelimiters : std::ctype<char>
static std::ctype_base::mask const* GetTable() static std::ctype_base::mask const* GetTable()
{ {
typedef std::ctype<char> cctype; typedef std::ctype<char> cctype;
static const cctype::mask* const_rc = cctype::classic_table();
static cctype::mask rc[cctype::table_size]; static cctype::mask rc[cctype::table_size];
std::memset(rc, 0, cctype::table_size * sizeof(cctype::mask)); std::memset(rc, 0, cctype::table_size * sizeof(cctype::mask));
return &rc[0]; return &rc[0];

View File

@ -185,7 +185,6 @@ template <typename T>
void FractoriumEmberController<T>::CreateReferenceFile() void FractoriumEmberController<T>::CreateReferenceFile()
{ {
bool nv = false; bool nv = false;
size_t i;
StopAllPreviewRenderers(); StopAllPreviewRenderers();
auto temppal = m_Ember.m_Palette; auto temppal = m_Ember.m_Palette;
m_EmberFile.Clear(); m_EmberFile.Clear();
@ -258,6 +257,7 @@ void FractoriumEmberController<T>::CreateReferenceFile()
m_EmberFile.m_Embers.push_back(ember); m_EmberFile.m_Embers.push_back(ember);
}; };
size_t i;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
addsquaresfunc(i, regVars[i]); addsquaresfunc(i, regVars[i]);