Skip to content

Commit

Permalink
Fix several compiler warnings
Browse files Browse the repository at this point in the history
* -Wmaybe-uninitialized
* -Wunused-parameter
* -Wunused-variable
* -Wnonnull
* -Wstringop-truncation
* -Wstringop-overflow
  • Loading branch information
wwmayer committed Jun 18, 2024
1 parent 27c61ef commit c899e5e
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/Gui/OverlayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ class OverlayManager::Private {
OverlayTabWidget *dst = nullptr;
int dstIndex = -1;
QDockWidget *dstDock = nullptr;
Qt::DockWidgetArea dstDockArea;
Qt::DockWidgetArea dstDockArea {};

if (!tabWidget) {
rect = QRect(pos - dragOffset, dragSize);
Expand Down
3 changes: 2 additions & 1 deletion src/Gui/Tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4727,11 +4727,12 @@ void DocumentItem::updateItemSelection(DocumentObjectItem* item)
const char* docname = obj->getDocument()->getName();
const auto& subname = str.str();

#ifdef FC_DEBUG
if (!subname.empty()) {
auto parentItem = item->getParentItem();
assert(parentItem);
}

#endif

if (!selected) {
Gui::Selection().rmvSelection(docname, objname, subname.c_str());
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Import/App/PreCompiled.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

// boost
#include <boost/algorithm/string/predicate.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/range/adaptor/indexed.hpp>

// OpenCasCade =====================================================================================
Expand Down
8 changes: 7 additions & 1 deletion src/Mod/Import/App/ReaderGltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "PreCompiled.h"
#ifndef _PreComp_
#include <boost/core/ignore_unused.hpp>
#include <Standard_Version.hxx>
#if OCC_VERSION_HEX >= 0x070500
#include <BRep_Builder.hxx>
Expand Down Expand Up @@ -73,7 +74,7 @@ void ReaderGltf::read(Handle(TDocStd_Document) hDoc)
processDocument(hDoc);

#else
(void)hDoc;
boost::ignore_unused(hDoc);
throw Base::RuntimeError("gITF support requires OCCT 7.5.0 or later");
#endif
}
Expand All @@ -100,6 +101,8 @@ void ReaderGltf::processDocument(Handle(TDocStd_Document) hDoc)
}
}
}
#else
boost::ignore_unused(hDoc);
#endif
}

Expand Down Expand Up @@ -138,6 +141,9 @@ TopoDS_Shape ReaderGltf::processSubShapes(Handle(TDocStd_Document) hDoc,
aColorTool->SetColor(faceLabel, rgba, XCAFDoc_ColorSurf);
}
}
#else
boost::ignore_unused(hDoc);
boost::ignore_unused(subShapeLabels);
#endif

return {std::move(compound)};
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Import/App/WriterGltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "PreCompiled.h"
#ifndef _PreComp_
#include <boost/core/ignore_unused.hpp>
#include <Standard_Version.hxx>
#include <TColStd_IndexedDataMapOfStringString.hxx>
#if OCC_VERSION_HEX >= 0x070500
Expand Down Expand Up @@ -62,6 +63,7 @@ void WriterGltf::write(Handle(TDocStd_Document) hDoc) const // NOLINT
throw Base::FileException("Cannot save to file: ", file);
}
#else
boost::ignore_unused(hDoc);
throw Base::RuntimeError("gITF support requires OCCT 7.5.0 or later");
#endif
}
5 changes: 2 additions & 3 deletions src/Mod/Import/App/dxf/ImpExpDxf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,12 +1073,11 @@ void ImpExpDxfWrite::exportBSpline(BRepAdaptor_Curve& c)
s = c.Value(f);
ePt = c.Value(l);
Base::Console().Message(
"DxfWrite::exportBSpline - no result- from:(%.3f,%.3f) to:(%.3f,%.3f) poles: %d\n",
"DxfWrite::exportBSpline - no result- from:(%.3f,%.3f) to:(%.3f,%.3f)\n",
s.X(),
s.Y(),
ePt.X(),
ePt.Y(),
spline->NbPoles());
ePt.Y());
TColgp_Array1OfPnt controlPoints(0, 1);
controlPoints.SetValue(0, s);
controlPoints.SetValue(1, ePt);
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Mesh/App/WildMagic4/Wm4System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ char* System::Strcpy (char* acDst, size_t uiDstSize, const char* acSrc)
// copy failed.
return nullptr;
}
strncpy(acDst,acSrc,uiSrcLen);
strncpy(acDst,acSrc,uiSrcLen + 1);
acDst[uiSrcLen] = 0;
return acDst;
#endif
Expand Down Expand Up @@ -962,7 +962,7 @@ char* System::Strcat (char* acDst, size_t uiDstSize, const char* acSrc)
// the concatenation failed.
return nullptr;
}
strncat(acDst,acSrc,uiSrcLen);
strncat(acDst,acSrc,uiSrcLen + 1);
acDst[uiSumLen] = 0;
return acDst;
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Part/App/WireJoiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
****************************************************************************/

#include "PreCompiled.h"
#include <boost/core/ignore_unused.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/graph/graph_concepts.hpp>

Expand Down Expand Up @@ -1730,6 +1731,7 @@ class WireJoiner::WireJoinerP {
}
for (auto &info : edges) {
if (auto wire = info.wireInfo.get()) {
boost::ignore_unused(wire);

// Originally here there was a call to the precompiler macro assertCheck(), which
// has been replaced with the precompiler macro assert()
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Sketcher/App/SketchObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9478,6 +9478,7 @@ std::pair<std::string,std::string> SketchObject::getElementName(
index.appendToStringBuffer(ret.second);
if (auto realName = convertInternalName(ret.second.c_str())) {
Data::MappedElement mappedElement;
(void)realName;
// Todo: Do we need to add the InternalShape?
// if (mapped)
// mappedElement = InternalShape.getShape().getElementName(name);
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Sketcher/App/planegcs/GCS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2084,7 +2084,7 @@ int System::solve_BFGS(SubSystem* subsys, bool /*isFine*/, bool isRedundantsolvi
}

double divergingLim = 1e6 * err + 1e12;
double h_norm;
double h_norm {};

for (int iter = 1; iter < maxIterNumber; iter++) {
h_norm = h.norm();
Expand Down Expand Up @@ -2241,7 +2241,7 @@ int System::solve_LM(SubSystem* subsys, bool isRedundantsolving)
mu = tau * diag_A.lpNorm<Eigen::Infinity>();
}

double h_norm;
double h_norm {};
// determine increment using adaptive damping
int k = 0;
while (k < 50) {
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Sketcher/Gui/CommandConstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2214,11 +2214,11 @@ class DrawSketchHandlerDimension : public DrawSketchHandler
GeoId1, static_cast<int>(PosId1), GeoId2, ActDist);
}
// Circle/arc - line, circle/arc - circle/arc cases
else if (PosId1 == Sketcher::PointPos::none
&& PosId2 == Sketcher::PointPos::none) {
else if (PosId1 == Sketcher::PointPos::none && PosId2 == Sketcher::PointPos::none) {
const Part::Geometry* geo1 = Obj->getGeometry(GeoId1);
const Part::Geometry* geo2 = Obj->getGeometry(GeoId2);
double radius1, radius2;
double radius1 {};
double radius2 {};
Base::Vector3d center1, center2;
if (isCircle(*geo1)) {
auto conic = static_cast<const Part::GeomCircle*>(geo1);
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Sketcher/Gui/DrawSketchHandlerOffset.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ class DrawSketchHandlerOffset: public DrawSketchHandlerOffsetBase

vCCO = generatevCC(listOfOffsetGeoIds);

int geoIdCandidate1, geoIdCandidate2;
int geoIdCandidate1 {};
int geoIdCandidate2 {};

int newCurveCounter = 0;
int prevCurveCounter = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Sketcher/Gui/EditModeGeometryCoinConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ template<typename GeoType,
EditModeGeometryCoinConverter::AnalyseMode analysemode>
void EditModeGeometryCoinConverter::convert(const Sketcher::GeometryFacade* geometryfacade,
[[maybe_unused]] int geoid,
int subLayer)
[[maybe_unused]] int subLayer)
{
auto geo = static_cast<const GeoType*>(geometryfacade->getGeometry());
auto layerId = getSafeGeomLayerId(geometryfacade);
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Sketcher/Gui/EditModeGeometryCoinConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class EditModeGeometryCoinConverter
template<typename GeoType, PointsMode pointmode, CurveMode curvemode, AnalyseMode analysemode>
void convert(const Sketcher::GeometryFacade* geometryfacade,
[[maybe_unused]] int geoId,
int subLayerId = 0);
[[maybe_unused]] int subLayerId = 0);

private:
/// Reference to ViewProviderSketch in order to access the public and the Attorney Interface
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Spreadsheet/Gui/SheetModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
else if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId())
|| prop->isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
/* Number */
double d;
long l;
double d {};
long l {};
bool isInteger = false;
if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
d = static_cast<const App::PropertyFloat*>(prop)->getValue();
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/TechDraw/Gui/QGIViewDimension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2550,7 +2550,7 @@ void QGIViewDimension::drawAngle(TechDraw::DrawViewDimension* dimension,

double endAngle = (endPoint - angleVertex).Angle();
double startAngle = (startPoint - angleVertex).Angle();
double arcRadius;
double arcRadius {};

int standardStyle = viewProvider->StandardAndStyle.getValue();
int renderExtent = viewProvider->RenderingExtent.getValue();
Expand Down

0 comments on commit c899e5e

Please sign in to comment.