From b2a5f47e441961aa1c8c4a78ee25b96e91f75fc0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 17 Feb 2019 13:56:48 +0100 Subject: [PATCH] PVS: V560 A part of conditional expression is always true --- src/Base/Console.cpp | 4 +-- src/Gui/BlenderNavigationStyle.cpp | 2 +- src/Gui/CADNavigationStyle.cpp | 2 +- src/Gui/DemoMode.cpp | 2 +- src/Gui/GuiApplication.cpp | 44 +++++++++++------------- src/Gui/InventorNavigationStyle.cpp | 2 +- src/Gui/NavigationStyle.cpp | 4 +-- src/Gui/OpenCascadeNavigationStyle.cpp | 4 +-- src/Gui/RevitNavigationStyle.cpp | 2 +- src/Gui/TouchpadNavigationStyle.cpp | 2 +- src/Mod/Part/App/Attacher.cpp | 4 +-- src/Mod/Part/App/TopoShape.cpp | 4 ++- src/Mod/Part/App/TopoShapeSolidPyImp.cpp | 2 +- src/Mod/PartDesign/Gui/Command.cpp | 2 +- src/Mod/PartDesign/Gui/ViewProvider.cpp | 2 +- src/Mod/Sketcher/App/SketchObject.cpp | 2 +- 16 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/Base/Console.cpp b/src/Base/Console.cpp index 720b30e7b9..ec51800014 100644 --- a/src/Base/Console.cpp +++ b/src/Base/Console.cpp @@ -146,7 +146,7 @@ ConsoleSingleton::~ConsoleSingleton() */ void ConsoleSingleton::SetConsoleMode(ConsoleMode m) { - if(m && Verbose) + if (m & Verbose) _bVerbose = true; } @@ -155,7 +155,7 @@ void ConsoleSingleton::SetConsoleMode(ConsoleMode m) */ void ConsoleSingleton::UnsetConsoleMode(ConsoleMode m) { - if(m && Verbose) + if (m & Verbose) _bVerbose = false; } diff --git a/src/Gui/BlenderNavigationStyle.cpp b/src/Gui/BlenderNavigationStyle.cpp index 766ded8dc8..608c6c5e17 100644 --- a/src/Gui/BlenderNavigationStyle.cpp +++ b/src/Gui/BlenderNavigationStyle.cpp @@ -120,7 +120,7 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev) } // give the nodes in the foreground root the chance to handle events (e.g color bar) - if (!processed && !viewer->isEditing()) { + if (!viewer->isEditing()) { processed = handleEventInForeground(ev); if (processed) return true; diff --git a/src/Gui/CADNavigationStyle.cpp b/src/Gui/CADNavigationStyle.cpp index 1beda14573..eb6e47974a 100644 --- a/src/Gui/CADNavigationStyle.cpp +++ b/src/Gui/CADNavigationStyle.cpp @@ -124,7 +124,7 @@ SbBool CADNavigationStyle::processSoEvent(const SoEvent * const ev) } // give the nodes in the foreground root the chance to handle events (e.g color bar) - if (!processed && !viewer->isEditing()) { + if (!viewer->isEditing()) { processed = handleEventInForeground(ev); if (processed) return true; diff --git a/src/Gui/DemoMode.cpp b/src/Gui/DemoMode.cpp index a9250ebf2b..d6f9f40e0c 100644 --- a/src/Gui/DemoMode.cpp +++ b/src/Gui/DemoMode.cpp @@ -122,7 +122,7 @@ Gui::View3DInventor* DemoMode::activeView() const Document* doc = Application::Instance->activeDocument(); if (doc) { MDIView* view = doc->getActiveView(); - if (doc && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { + if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { return static_cast(view); } } diff --git a/src/Gui/GuiApplication.cpp b/src/Gui/GuiApplication.cpp index 76f9d39478..1dbe8992d3 100644 --- a/src/Gui/GuiApplication.cpp +++ b/src/Gui/GuiApplication.cpp @@ -108,31 +108,29 @@ bool GUIApplication::notify (QObject * receiver, QEvent * event) } // Print some more information to the log file (if active) to ease bug fixing - if (receiver && event) { - try { - std::stringstream dump; - dump << "The event type " << (int)event->type() << " was sent to " - << receiver->metaObject()->className() << "\n"; - dump << "Object tree:\n"; - if (receiver->isWidgetType()) { - QWidget* w = qobject_cast(receiver); - while (w) { - dump << "\t"; - dump << w->metaObject()->className(); - QString name = w->objectName(); - if (!name.isEmpty()) - dump << " (" << (const char*)name.toUtf8() << ")"; - w = w->parentWidget(); - if (w) - dump << " is child of\n"; - } - std::string str = dump.str(); - Base::Console().Log("%s",str.c_str()); + try { + std::stringstream dump; + dump << "The event type " << (int)event->type() << " was sent to " + << receiver->metaObject()->className() << "\n"; + dump << "Object tree:\n"; + if (receiver->isWidgetType()) { + QWidget* w = qobject_cast(receiver); + while (w) { + dump << "\t"; + dump << w->metaObject()->className(); + QString name = w->objectName(); + if (!name.isEmpty()) + dump << " (" << (const char*)name.toUtf8() << ")"; + w = w->parentWidget(); + if (w) + dump << " is child of\n"; } + std::string str = dump.str(); + Base::Console().Log("%s",str.c_str()); } - catch (...) { - Base::Console().Log("Invalid recipient and/or event in GUIApplication::notify\n"); - } + } + catch (...) { + Base::Console().Log("Invalid recipient and/or event in GUIApplication::notify\n"); } return true; diff --git a/src/Gui/InventorNavigationStyle.cpp b/src/Gui/InventorNavigationStyle.cpp index 58f7f83e9a..fbe46ea0f1 100644 --- a/src/Gui/InventorNavigationStyle.cpp +++ b/src/Gui/InventorNavigationStyle.cpp @@ -126,7 +126,7 @@ SbBool InventorNavigationStyle::processSoEvent(const SoEvent * const ev) } // give the nodes in the foreground root the chance to handle events (e.g color bar) - if (!processed && !viewer->isEditing()) { + if (!viewer->isEditing()) { processed = handleEventInForeground(ev); if (processed) return true; diff --git a/src/Gui/NavigationStyle.cpp b/src/Gui/NavigationStyle.cpp index 489834fb3b..e6128de03b 100644 --- a/src/Gui/NavigationStyle.cpp +++ b/src/Gui/NavigationStyle.cpp @@ -521,11 +521,11 @@ void NavigationStyle::boxZoom(const SbBox2s& box) float scaleX = (float)sizeX/(float)size[0]; float scaleY = (float)sizeY/(float)size[1]; float scale = std::max(scaleX, scaleY); - if (cam && cam->getTypeId() == SoOrthographicCamera::getClassTypeId()) { + if (cam->getTypeId() == SoOrthographicCamera::getClassTypeId()) { float height = static_cast(cam)->height.getValue() * scale; static_cast(cam)->height = height; } - else if (cam && cam->getTypeId() == SoPerspectiveCamera::getClassTypeId()) { + else if (cam->getTypeId() == SoPerspectiveCamera::getClassTypeId()) { float height = static_cast(cam)->heightAngle.getValue() / 2.0f; height = 2.0f * atan(tan(height) * scale); static_cast(cam)->heightAngle = height; diff --git a/src/Gui/OpenCascadeNavigationStyle.cpp b/src/Gui/OpenCascadeNavigationStyle.cpp index 87a1dc7a07..e18aa724e4 100644 --- a/src/Gui/OpenCascadeNavigationStyle.cpp +++ b/src/Gui/OpenCascadeNavigationStyle.cpp @@ -120,7 +120,7 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev) } // give the nodes in the foreground root the chance to handle events (e.g color bar) - if (!processed && !viewer->isEditing()) { + if (!viewer->isEditing()) { processed = handleEventInForeground(ev); if (processed) return true; @@ -252,7 +252,7 @@ SbBool OpenCascadeNavigationStyle::processSoEvent(const SoEvent * const ev) this->panningplane = vv.getPlane(viewer->getSoRenderManager()->getCamera()->focalDistance.getValue()); this->lockrecenter = false; } - else if (!press && (this->currentmode == NavigationStyle::PANNING)) { + else if (this->currentmode == NavigationStyle::PANNING) { newmode = NavigationStyle::IDLE; processed = true; } diff --git a/src/Gui/RevitNavigationStyle.cpp b/src/Gui/RevitNavigationStyle.cpp index 074ccba102..31778e4c89 100644 --- a/src/Gui/RevitNavigationStyle.cpp +++ b/src/Gui/RevitNavigationStyle.cpp @@ -120,7 +120,7 @@ SbBool RevitNavigationStyle::processSoEvent(const SoEvent * const ev) } // give the nodes in the foreground root the chance to handle events (e.g color bar) - if (!processed && !viewer->isEditing()) { + if (!viewer->isEditing()) { processed = handleEventInForeground(ev); if (processed) return true; diff --git a/src/Gui/TouchpadNavigationStyle.cpp b/src/Gui/TouchpadNavigationStyle.cpp index b1510a5904..d18fa06f84 100644 --- a/src/Gui/TouchpadNavigationStyle.cpp +++ b/src/Gui/TouchpadNavigationStyle.cpp @@ -120,7 +120,7 @@ SbBool TouchpadNavigationStyle::processSoEvent(const SoEvent * const ev) } // give the nodes in the foreground root the chance to handle events (e.g color bar) - if (!processed && !viewer->isEditing()) { + if (!viewer->isEditing()) { processed = handleEventInForeground(ev); if (processed) return true; diff --git a/src/Mod/Part/App/Attacher.cpp b/src/Mod/Part/App/Attacher.cpp index 4aaef99efd..1b928a2529 100644 --- a/src/Mod/Part/App/Attacher.cpp +++ b/src/Mod/Part/App/Attacher.cpp @@ -235,7 +235,7 @@ Base::Placement AttachEngine::placementFactory(const gp_Dir &ZAxis, gp_Ax3 ax3;//OCC representation of the final placement if (!makeYVertical) { ax3 = gp_Ax3(Origin, ZAxis, XAxis); - } else if (makeYVertical && !makeLegacyFlatFaceOrientation) { + } else if (!makeLegacyFlatFaceOrientation) { //align Y along Z, if possible gp_Vec YAxis(0.0,0.0,1.0); XAxis = YAxis.Crossed(gp_Vec(ZAxis)); @@ -1163,7 +1163,7 @@ Base::Placement AttachEngine3D::calculateAttachedPlacement(Base::Placement origP throw Base::ValueError("AttachEngine3D::calculateAttachedPlacement: not enough subshapes (need one false and one vertex)."); bool bThruVertex = false; - if (shapes[0]->ShapeType() == TopAbs_VERTEX && shapes.size()>=2) { + if (shapes[0]->ShapeType() == TopAbs_VERTEX) { std::swap(shapes[0],shapes[1]); bThruVertex = true; } diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index a430bfdfdd..90217c856a 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -2507,8 +2507,10 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b { if (_Shape.IsNull()) throw Base::ValueError("makeOffset2D: input shape is null!"); - if (allowOpenResult && OCC_VERSION_HEX < 0x060900) +#if OCC_VERSION_HEX < 0x060900 + if (allowOpenResult) throw Base::AttributeError("openResult argument is not supported on OCC < 6.9.0."); +#endif // OUTLINE OF MAKEOFFSET2D // * Prepare shapes to process diff --git a/src/Mod/Part/App/TopoShapeSolidPyImp.cpp b/src/Mod/Part/App/TopoShapeSolidPyImp.cpp index 0d6f112d7d..b749d43023 100644 --- a/src/Mod/Part/App/TopoShapeSolidPyImp.cpp +++ b/src/Mod/Part/App/TopoShapeSolidPyImp.cpp @@ -281,7 +281,7 @@ PyObject* TopoShapeSolidPy::offsetFaces(PyObject *args) } bool paramOK = false; - if (!paramOK && PyArg_ParseTuple(args, "Od", &obj,&offset)) { + if (PyArg_ParseTuple(args, "Od", &obj,&offset)) { paramOK = true; Py::Sequence list(obj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index a36abf1a1b..8dc2b0c591 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -758,7 +758,7 @@ void finishFeature(const Gui::Command* cmd, const std::string& FeatName, pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */false); } - if (hidePrevSolid && prevSolidFeature && (prevSolidFeature != NULL)) + if (hidePrevSolid && prevSolidFeature) cmd->doCommand(cmd->Gui,"Gui.activeDocument().hide(\"%s\")", prevSolidFeature->getNameInDocument()); if (updateDocument) diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index bf80d4d4f9..d49715a5ec 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -205,7 +205,7 @@ void ViewProvider::onChanged(const App::Property* prop) { return; Gui::ViewProviderDocumentObject* vpd = static_cast(vp); - if(vpd && vpd->Visibility.getValue()) + if (vpd->Visibility.getValue()) vpd->Visibility.setValue(false); } } diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index d8f78d74ed..6482ba9ae3 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -5425,7 +5425,7 @@ const Part::Geometry* SketchObject::getGeometry(int GeoId) const if (GeoId < int(geomlist.size())) return geomlist[GeoId]; } - else if (GeoId <= -1 && -GeoId <= int(ExternalGeo.size())) + else if (-GeoId <= int(ExternalGeo.size())) return ExternalGeo[-GeoId-1]; return 0;