From: aml Date: Thu, 3 Oct 2013 10:07:10 +0000 (+0400) Subject: 0024167: Compiler warnings 'unreacheable code' and 'conditional expression is constan... X-Git-Tag: V6_7_0_beta~107 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=3ed30348aaa21b144b11fdac76aa93c9678ef6c4;p=occt-copy.git 0024167: Compiler warnings 'unreacheable code' and 'conditional expression is constant' in MOA Resolved some C4702 (unreachable code) and C4127 (conditional expression is constant). small corrections in NoSuchObject invoking. Macros names changing, deadcode deleting, re-writing "for" loops into equivalent "if" structures. changed condition in "if" block, deadcode deleted. Small changes in else statement. --- diff --git a/src/BOPTools/BOPTools_AlgoTools3D.cxx b/src/BOPTools/BOPTools_AlgoTools3D.cxx index 1ca2a76954..4b3365455f 100644 --- a/src/BOPTools/BOPTools_AlgoTools3D.cxx +++ b/src/BOPTools/BOPTools_AlgoTools3D.cxx @@ -739,7 +739,7 @@ void Add(const TopoDS_Shape& aS, Handle(BOPInt_Context)& theContext) { Standard_Boolean bIsDone, bHasFirstPoint, bHasSecondPoint; - Standard_Integer iErr, aIx, aNbDomains, i; + Standard_Integer iErr, aIx, aNbDomains; Standard_Real aUMin, aUMax, aVMin, aVMax; Standard_Real aVx = 0., aUx, aV1, aV2, aEpsT; gp_Dir2d aD2D (0., 1.); @@ -783,8 +783,8 @@ void Add(const TopoDS_Shape& aS, } // aNbDomains=aHatcher.NbDomains(aIx); - for (i=1; i<=aNbDomains; ++i) { - const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, i) ; + if (aNbDomains > 0) { + const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, 1) ; bHasFirstPoint=aDomain.HasFirstPoint(); if (!bHasFirstPoint) { iErr=3; @@ -803,7 +803,10 @@ void Add(const TopoDS_Shape& aS, // aVx=IntTools_Tools::IntermediatePoint(aV1, aV2); // - break; + } + else { + iErr=2; + return iErr; } // aS->D0(aUx, aVx, aPx); diff --git a/src/BRepAlgo/BRepAlgo_FaceRestrictor.cxx b/src/BRepAlgo/BRepAlgo_FaceRestrictor.cxx index 4b664b32c1..7a0f4b9c3a 100755 --- a/src/BRepAlgo/BRepAlgo_FaceRestrictor.cxx +++ b/src/BRepAlgo/BRepAlgo_FaceRestrictor.cxx @@ -259,9 +259,8 @@ static Standard_Boolean IsInside(const TopoDS_Wire& wir, BRepTopAdaptor_FClass2d& /*FClass2d*/) { TopExp_Explorer exp; - for (exp.Init(wir,TopAbs_EDGE); - exp.More(); - exp.Next()) { + exp.Init(wir,TopAbs_EDGE); + if (exp.More()) { const TopoDS_Edge& edg = TopoDS::Edge(exp.Current()); Standard_Real f,l; Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(edg,F,f,l); diff --git a/src/BRepCheck/BRepCheck_Face.cxx b/src/BRepCheck/BRepCheck_Face.cxx index 14a6e10e18..bfc9e45379 100755 --- a/src/BRepCheck/BRepCheck_Face.cxx +++ b/src/BRepCheck/BRepCheck_Face.cxx @@ -657,9 +657,8 @@ static Standard_Boolean IsInside(const TopoDS_Wire& wir, { // Standard_Real U,V; TopExp_Explorer exp; - for (exp.Init(wir,TopAbs_EDGE); - exp.More(); - exp.Next()) { + exp.Init(wir,TopAbs_EDGE); + if (exp.More()) { const TopoDS_Edge& edg = TopoDS::Edge(exp.Current()); Standard_Real f,l; diff --git a/src/BRepClass3d/BRepClass3d.cxx b/src/BRepClass3d/BRepClass3d.cxx index 74c760dae1..c7f2bd3d0b 100644 --- a/src/BRepClass3d/BRepClass3d.cxx +++ b/src/BRepClass3d/BRepClass3d.cxx @@ -118,11 +118,10 @@ Standard_Boolean IsInternal(const TopoDS_Shell& aSx) bInternal=Standard_False; // aIt.Initialize(aSx); - for (; aIt.More(); aIt.Next()) { + if (aIt.More()) { const TopoDS_Shape& aSy=aIt.Value(); aOr=aSy.Orientation(); bInternal=(aOr==TopAbs_INTERNAL); - break; } // return bInternal; diff --git a/src/BRepTools/BRepTools_GTrsfModification.cxx b/src/BRepTools/BRepTools_GTrsfModification.cxx index a5d9800b13..1d559f7aad 100755 --- a/src/BRepTools/BRepTools_GTrsfModification.cxx +++ b/src/BRepTools/BRepTools_GTrsfModification.cxx @@ -122,8 +122,9 @@ Standard_Boolean BRepTools_GTrsfModification::NewSurface S2->SetPole(i, j, P); } } - else - Standard_NoSuchObject_Raise_if(1,"BRepTools_GTrsfModification : Pb no BSpline/Bezier Type Surface"); + else{ + Standard_NoSuchObject::Raise("BRepTools_GTrsfModification : Pb no BSpline/Bezier Type Surface"); + } L.Identity(); return Standard_True; @@ -170,8 +171,9 @@ Standard_Boolean BRepTools_GTrsfModification::NewCurve C2->SetPole(i, P); } } - else - Standard_NoSuchObject_Raise_if(1,"BRepTools_GTrsfModification : Pb no BSpline/Bezier Type Curve"); + else { + Standard_NoSuchObject::Raise("BRepTools_GTrsfModification : Pb no BSpline/Bezier Type Curve"); + } C = new Geom_TrimmedCurve(C, f, l); } L.Identity() ; diff --git a/src/ChFi3d/ChFi3d_Builder_C1.cxx b/src/ChFi3d/ChFi3d_Builder_C1.cxx index 83cd64dbc2..4d3e380f5e 100755 --- a/src/ChFi3d/ChFi3d_Builder_C1.cxx +++ b/src/ChFi3d/ChFi3d_Builder_C1.cxx @@ -1221,7 +1221,7 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, // VARIANT 2 : extend Arcprol, not create new small edge // To do: modify for intcouture - const Standard_Boolean variant1 = Standard_True; + #define VARIANT1 // First of all the ponts are cut with the edge of the spine. Standard_Integer IArcspine = DStr.AddShape(Arcspine); @@ -1251,10 +1251,11 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, } Handle(Geom2d_Curve) Hc; - if (variant1) + #ifdef VARIANT1 parVtx = BRep_Tool::Parameter(Vtx,Arcprol); - else + #else parVtx = BRep_Tool::Parameter(V2,Arcprol); + #endif const ChFiDS_FaceInterference& Fiop = Fd->Interference(IFopArc); gp_Pnt2d pop1, pop2, pv1, pv2; Hc = BRep_Tool::CurveOnSurface(Arcprol,Fop,Ubid,Ubid); @@ -1376,26 +1377,31 @@ void ChFi3d_Builder::PerformOneCorner(const Standard_Integer Index, Interfop = ChFi3d_FilCurveInDS(IZob,Iop,zob2dop,Et); DStr.ChangeShapeInterferences(Iop).Append(Interfop); Handle(TopOpeBRepDS_CurvePointInterference) interfprol; - if (variant1) + #ifdef VARIANT1 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IVtx,Udeb); - else { + #else + { Standard_Integer IV2 = DStr.AddShape(V2); // VARIANT 2 interfprol = ChFi3d_FilVertexInDS(TopAbs_FORWARD,IZob,IV2,Udeb); } + #endif DStr.ChangeCurveInterferences(IZob).Append(interfprol); Standard_Integer icc = stripe->IndexPoint(isfirst,IFopArc); interfprol = ChFi3d_FilPointInDS(TopAbs_REVERSED,IZob,icc,Ufin); DStr.ChangeCurveInterferences(IZob).Append(interfprol); - if (variant1) { + #ifdef VARIANT1 + { if (IFopArc == 1) box1.Add( zob3d->Value(Ufin) ); else box2.Add( zob3d->Value(Ufin) ); } - else { + #else + { // cut off existing Arcprol Standard_Integer iArcprol = DStr.AddShape(Arcprol); interfprol = ChFi3d_FilPointInDS(OVtx,iArcprol,icc,Udeb); DStr.ChangeShapeInterferences(Arcprol).Append(interfprol); } + #endif } } ChFi3d_EnlargeBox(DStr,stripe,Fd,box1,box2,isfirst); diff --git a/src/math/math_FunctionRoots.cxx b/src/math/math_FunctionRoots.cxx index 7063fd6b10..187959dd18 100755 --- a/src/math/math_FunctionRoots.cxx +++ b/src/math/math_FunctionRoots.cxx @@ -201,7 +201,9 @@ static void Solve(math_FunctionWithDerivative& F, #define NEWSEQ 1 -static const Standard_Integer methode = 1; //-- 1:(Nv Traitement) 3:(Nv + Ancien +check) 2:(Ancien) +#define MATH_FUNCTIONROOTS_NEWCODE // Nv Traitement +//#define MATH_FUNCTIONROOTS_OLDCODE // Ancien +//#define MATH_FUNCTIONROOTS_CHECK // Check math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, const Standard_Real A, @@ -224,7 +226,8 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, #endif Sol.Clear(); NbStateSol.Clear(); - if(methode & 1) { + #ifdef MATH_FUNCTIONROOTS_NEWCODE + { Done = Standard_True; Standard_Real X0=A; Standard_Real XN=B; @@ -492,7 +495,8 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, } #if NEWSEQ - if(methode==3) { + #ifdef MATH_FUNCTIONROOTS_CHECK + { StaticSol.Clear(); Standard_Integer n=Sol.Length(); for(Standard_Integer ii=1;ii<=n;ii++) { @@ -501,9 +505,12 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, Sol.Clear(); NbStateSol.Clear(); } +#endif +#endif #endif } - if(methode & 2) { +#ifdef MATH_FUNCTIONROOTS_OLDCODE +{ //-- ******************************************************************************** //-- ANCIEN TRAITEMENT //-- ******************************************************************************** @@ -977,7 +984,8 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, } } #if NEWSEQ - if(methode == 3) { + #ifdef MATH_FUNCTIONROOTS_CHECK + { Standard_Integer n1=StaticSol.Length(); Standard_Integer n2=Sol.Length(); if(n1!=n2) { @@ -1003,7 +1011,9 @@ math_FunctionRoots::math_FunctionRoots(math_FunctionWithDerivative& F, } } #endif +#endif } +#endif }