From f2139a7f0fb5cb3851cbb192d585121c641270f6 Mon Sep 17 00:00:00 2001 From: abv Date: Wed, 11 Nov 2015 09:32:41 +0300 Subject: [PATCH] 0026780: Coding rules - eliminate warnings on Linux and Mac Fixed a few remaining warnings found by GCC, CLang, and VC++ 14 (recent changes) --- src/Draft/Draft_Modification_1.cxx | 22 +++++++++---------- src/Font/Font_TextFormatter.cxx | 10 --------- src/STEPCAFControl/STEPCAFControl_Reader.cxx | 21 +++++++++--------- src/ShapeFix/ShapeFix_Shape.cxx | 3 +-- src/Standard/Standard_ErrorHandler.hxx | 4 ++-- src/TopOpeBRep/TopOpeBRep_FFDumper.cxx | 7 +++++- .../TopOpeBRepTool_makeTransition.cxx | 12 ++++++---- src/ViewerTest/ViewerTest.cxx | 4 ++-- src/XDEDRAW/XDEDRAW_GDTs.cxx | 4 ++-- 9 files changed, 41 insertions(+), 46 deletions(-) diff --git a/src/Draft/Draft_Modification_1.cxx b/src/Draft/Draft_Modification_1.cxx index 1aec745833..08b053e0fb 100644 --- a/src/Draft/Draft_Modification_1.cxx +++ b/src/Draft/Draft_Modification_1.cxx @@ -801,18 +801,16 @@ void Draft_Modification::Perform () } // Calculate new edges. - - Handle(Geom_Surface) S1,S2; - Handle(Geom_Curve) C, newC; - Standard_Real f,l; - TopLoc_Location L; - for (Standard_Integer ii = 1; ii <= myEMap.Extent(); ii++) { Draft_EdgeInfo& Einf = myEMap.ChangeFromIndex(ii); const TopoDS_Edge& theEdge = TopoDS::Edge(myEMap.FindKey(ii)); + Handle(Geom_Surface) S1,S2; + Handle(Geom_Curve) C, newC; + Standard_Real f,l; + TopLoc_Location L; C = BRep_Tool::Curve(theEdge,L,f,l); C = Handle(Geom_Curve)::DownCast(C->Transformed(L.Transformation())); @@ -1414,8 +1412,8 @@ void Draft_Modification::Perform () Standard_Real param = Parameter(Einf2.Geometry(), pvt, done); if (done != 0) { - S1 = myFMap.FindFromKey(Einf2.FirstFace()).Geometry(); - S2 = myFMap.FindFromKey(Einf2.SecondFace()).Geometry(); + Handle(Geom_Surface) S1 = myFMap.FindFromKey(Einf2.FirstFace()).Geometry(); + Handle(Geom_Surface) S2 = myFMap.FindFromKey(Einf2.SecondFace()).Geometry(); Vinf.ChangeParameter(Edg2) = SmartParameter( Einf2, BRep_Tool::Tolerance(Edg2), pvt, done, S1, S2 ); } else @@ -1428,8 +1426,8 @@ void Draft_Modification::Perform () Standard_Real param = Parameter(Einf1.Geometry(), pvt, done); if (done != 0) { - S1 = myFMap.FindFromKey(Einf1.FirstFace()).Geometry(); - S2 = myFMap.FindFromKey(Einf1.SecondFace()).Geometry(); + Handle(Geom_Surface) S1 = myFMap.FindFromKey(Einf1.FirstFace()).Geometry(); + Handle(Geom_Surface) S2 = myFMap.FindFromKey(Einf1.SecondFace()).Geometry(); Vinf.ChangeParameter(Edg1) = SmartParameter( Einf1, BRep_Tool::Tolerance(Edg1), pvt, done, S1, S2 ); } else @@ -1516,8 +1514,8 @@ void Draft_Modification::Perform () Standard_Real param = Parameter(Einf.Geometry(), pvt, done); if (done != 0) { - S1 = myFMap.FindFromKey(Einf.FirstFace()).Geometry(); - S2 = myFMap.FindFromKey(Einf.SecondFace()).Geometry(); + Handle(Geom_Surface) S1 = myFMap.FindFromKey(Einf.FirstFace()).Geometry(); + Handle(Geom_Surface) S2 = myFMap.FindFromKey(Einf.SecondFace()).Geometry(); Vinf.ChangeParameter(Edg) = SmartParameter( Einf, BRep_Tool::Tolerance(Edg), pvt, done, S1, S2 ); } else diff --git a/src/Font/Font_TextFormatter.cxx b/src/Font/Font_TextFormatter.cxx index 6ed04745b1..c31e60f900 100644 --- a/src/Font/Font_TextFormatter.cxx +++ b/src/Font/Font_TextFormatter.cxx @@ -43,16 +43,6 @@ namespace } } - //! Apply floor to vector components. - //! @param theVec - vector to change (by reference!) - //! @return modified vector - inline Vec2f& floor (Vec2f& theVec) - { - theVec.x() = std::floor (theVec.x()); - theVec.y() = std::floor (theVec.y()); - return theVec; - } - } // ======================================================================= diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index 954e94802a..21eb2d22c8 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -1875,17 +1875,16 @@ static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat, { Handle(StepAP242_GeometricItemSpecificUsage) aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value()); - Handle(StepRepr_RepresentationItem) aRI; + Handle(StepRepr_RepresentationItem) anItem; if(aPGISU->NbIdentifiedItem() > 0) { - aRI = Handle(StepRepr_RepresentationItem)::DownCast(aPGISU->IdentifiedItemValue(1)); + anItem = Handle(StepRepr_RepresentationItem)::DownCast(aPGISU->IdentifiedItemValue(1)); } - if(aRI.IsNull()) continue; - Standard_Integer index = aTP->MapIndex(aRI); - TopoDS_Shape aSh; - if(index >0) { - Handle(Transfer_Binder) binder = aTP->MapItem(index); - aSh = TransferBRep::ShapeResult(binder); - aDatObj->SetDatumTarget(aSh); + if(anItem.IsNull()) continue; + Standard_Integer anItemIndex = aTP->MapIndex(anItem); + if(anItemIndex >0) { + Handle(Transfer_Binder) binder = aTP->MapItem(anItemIndex); + TopoDS_Shape anItemShape = TransferBRep::ShapeResult(binder); + aDatObj->SetDatumTarget(anItemShape); } } } @@ -2297,8 +2296,8 @@ static TDF_Label createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt, if(!DimCharR.IsNull()) { Handle(StepShape_ShapeDimensionRepresentation) SDimR = DimCharR->Representation(); if(!SDimR.IsNull() && SDimR->NbItems()>0) { - Handle(StepRepr_RepresentationItem) aRI = SDimR->ItemsValue(1); - Handle(StepRepr_ValueRange) VR = Handle(StepRepr_ValueRange)::DownCast(aRI); + Handle(StepRepr_RepresentationItem) anItem = SDimR->ItemsValue(1); + Handle(StepRepr_ValueRange) VR = Handle(StepRepr_ValueRange)::DownCast(anItem); if(!VR.IsNull()) { aName = VR->Name(); //StepRepr_CompoundItemDefinition CID = VR->ItemElement(); diff --git a/src/ShapeFix/ShapeFix_Shape.cxx b/src/ShapeFix/ShapeFix_Shape.cxx index cca527e530..5c884f03f9 100644 --- a/src/ShapeFix/ShapeFix_Shape.cxx +++ b/src/ShapeFix/ShapeFix_Shape.cxx @@ -258,8 +258,7 @@ Standard_Boolean ShapeFix_Shape::Perform(const Handle(Message_ProgressIndicator) //after all fixes. //This fix it should be performed for example for case when cutting edge was performed. Handle(ShapeFix_Edge) sfe = FixEdgeTool(); - TopExp_Explorer anExpF (myResult, TopAbs_FACE); - for ( ; anExpF.More(); anExpF.Next()) + for (anExpF.ReInit(); anExpF.More(); anExpF.Next()) { TopoDS_Face aF = TopoDS::Face(anExpF.Current()); TopExp_Explorer anExpE (aF, TopAbs_EDGE); diff --git a/src/Standard/Standard_ErrorHandler.hxx b/src/Standard/Standard_ErrorHandler.hxx index 968f8eb99f..115784d052 100644 --- a/src/Standard/Standard_ErrorHandler.hxx +++ b/src/Standard/Standard_ErrorHandler.hxx @@ -68,7 +68,7 @@ #define OCC_CATCH_SIGNALS // Suppress GCC warning "variable ... might be clobbered by 'longjmp' or 'vfork'" - #ifdef __GNUC__ + #if defined(__GNUC__) && ! defined(__INTEL_COMPILER) && ! defined(__clang__) #pragma GCC diagnostic ignored "-Wclobbered" #endif @@ -83,7 +83,7 @@ } // Suppress GCC warning "variable ... might be clobbered by 'longjmp' or 'vfork'" - #ifdef __GNUC__ + #if defined(__GNUC__) && ! defined(__INTEL_COMPILER) && ! defined(__clang__) #pragma GCC diagnostic ignored "-Wclobbered" #endif diff --git a/src/TopOpeBRep/TopOpeBRep_FFDumper.cxx b/src/TopOpeBRep/TopOpeBRep_FFDumper.cxx index 44f7e7310b..df35f575fc 100644 --- a/src/TopOpeBRep/TopOpeBRep_FFDumper.cxx +++ b/src/TopOpeBRep/TopOpeBRep_FFDumper.cxx @@ -65,6 +65,11 @@ TopOpeBRep_FFDumper::TopOpeBRep_FFDumper(const TopOpeBRep_PFacesFiller& PFF) #ifndef OCCT_DEBUG void TopOpeBRep_FFDumper::Init(const TopOpeBRep_PFacesFiller& ) { + // just shut up compiler warnings + (void)myEn1; + (void)myEn2; + (void)myLineIndex; +} #else void TopOpeBRep_FFDumper::Init(const TopOpeBRep_PFacesFiller& PFF) { @@ -84,8 +89,8 @@ void TopOpeBRep_FFDumper::Init(const TopOpeBRep_PFacesFiller& PFF) for (x.Init(myF2,TopAbs_EDGE);x.More();x.Next()) myEM2.Bind(x.Current(),++myEn2); myLineIndex = 0; } -#endif } +#endif //======================================================================= //function : DumpLine diff --git a/src/TopOpeBRepTool/TopOpeBRepTool_makeTransition.cxx b/src/TopOpeBRepTool/TopOpeBRepTool_makeTransition.cxx index a2ff4a17de..3ca65e0f3a 100644 --- a/src/TopOpeBRepTool/TopOpeBRepTool_makeTransition.cxx +++ b/src/TopOpeBRepTool/TopOpeBRepTool_makeTransition.cxx @@ -204,9 +204,11 @@ static Standard_Boolean FUN_tg(const TopoDS_Edge& e,const Standard_Real par,cons st = BEFORE; for (Standard_Integer nite = 1; nite <= 2; nite++) { if (nite == 2) st = AFTER; - Standard_Real pn; Standard_Boolean mkp = FUN_getnearpar(e,par,f,l,factor,st,pn); + Standard_Real pn = 0.; + Standard_Boolean mkp = FUN_getnearpar(e,par,f,l,factor,st,pn); if (!mkp) continue; - gp_Vec tmp; Standard_Boolean ok = TopOpeBRepTool_TOOL::TggeomE(pn,e,tmp); + gp_Vec tmp; + Standard_Boolean ok = TopOpeBRepTool_TOOL::TggeomE(pn,e,tmp); if (!ok) continue; tg = gp_Dir(tmp); return Standard_True; @@ -477,9 +479,11 @@ static Standard_Boolean FUN_staproj(const TopoDS_Edge& e,const Standard_Real pf, const Standard_Real factor, const Standard_Integer st, const TopoDS_Face& f, TopAbs_State& sta) { - Standard_Real par;Standard_Boolean ok = FUN_getnearpar(e,pe,pf,pl,factor,st, par); + Standard_Real par = 0.; + Standard_Boolean ok = FUN_getnearpar(e,pe,pf,pl,factor,st, par); if (!ok) return Standard_False; - gp_Pnt pt; ok = FUN_tool_value(par,e, pt); + gp_Pnt pt; + ok = FUN_tool_value(par,e, pt); if (!ok) return Standard_False; gp_Pnt2d uv; ok = TopOpeBRepTool_TOOL::Getstp3dF(pt,f,uv,sta); return ok; diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 96bcd5fa16..062256304b 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -5750,12 +5750,12 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands) theCommands.Add("vsetshading", "vsetshading : vsetshading name Quality(default=0.0008) " - "\n\t\t: Sets deflection coefficient that defines the quality of the shape’s representation in the shading mode.", + "\n\t\t: Sets deflection coefficient that defines the quality of the shape representation in the shading mode.", __FILE__,VShading,group); theCommands.Add("vunsetshading", "vunsetshading :vunsetshading name " - "\n\t\t: Sets default deflection coefficient (0.0008) that defines the quality of the shape’s representation in the shading mode.", + "\n\t\t: Sets default deflection coefficient (0.0008) that defines the quality of the shape representation in the shading mode.", __FILE__,VShading,group); theCommands.Add ("vtexture", diff --git a/src/XDEDRAW/XDEDRAW_GDTs.cxx b/src/XDEDRAW/XDEDRAW_GDTs.cxx index 2c13b0bb9a..8636f2054a 100644 --- a/src/XDEDRAW/XDEDRAW_GDTs.cxx +++ b/src/XDEDRAW/XDEDRAW_GDTs.cxx @@ -266,9 +266,9 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c if (!aModif.IsEmpty()) { di << ","; - for (Standard_Integer k = aModif.Lower(); k <= aModif.Upper(); k++) + for (Standard_Integer iModif = aModif.Lower(); iModif <= aModif.Upper(); iModif++) { - di << " M " << aModif.Value(k); + di << " M " << aModif.Value(iModif); } } XCAFDimTolObjects_DatumModifWithValue aM; -- 2.20.1