Archived issue #0023132
Suspicious code snippets
Description
I'm sending you a bunch of suspicios lines found some time ago while removing warnings. I didn't know the 100% proper fix, maybe you could take a look. Probably the "dead code" ones are intended, and the code was left there unused.
---
src\Aspect\Aspect.cxx , line 116
"cast truncates constant value" warning.
Changing to 0xFEE0u is warning-clean, but I don't know if it works.
--
if you search all around the code RWStepBasic for the string
ent->Init(hasAprefix,aPrefix,aName);
you will see that in all these functions, in case of error, the failure message is added, but the values are used anyway.
In case of error the used variables have an undefined value.
--
TopOpeBRepTool\TopOpeBRepTool_mkTondgE.cxx , line 367
the return statement makes the remaining code in the scope never executed. Is this intended?
---
GeomFill\GeomFill_LocationGuide.cxx, line 745
the return statement makes the whole scope dead code. Is this intended?
----
src\IntTools\IntTools_EdgeFace.cxx
Line 901 : you see there's a return 0 in a scope, that makes the remaining of the function dead code. Is it intended?
---------
src\BRepFill\BRepFill_OffsetWire.cxx , line 622
if (CT2d->BasisCurve()->IsKind(STANDARD_TYPE(Geom2d_Circle)) &&
( Abs(f-l) >= M_PI) ) {
return 0; //
the return makes the remaining scope dead code. Is it intended?
--------
src\TopOpeBRep\TopOpeBRep_ShapeIntersector2d.cxx , line 281
the NextFFCouple() line is never executed
---
src\V2d\V2d_RectangularGraphicGrid.cxx , line 71
alpha = Standard_ShortReal ( alpha - 1.57/2.0 );
that is probably PI / 4
and in the line above the two 1.57 are just PI / 2
maybe the 1.41 is sqrt(2) ?
---
src\IFSelect\IFSelect_WorkSession.cxx , line 2825
thecheckana = TCollection_AsciiString (' ',nb+1);
probably the constructor parameters are reversed, should be nb+1,' '
---
---
src\Aspect\Aspect.cxx , line 116
"cast truncates constant value" warning.
Changing to 0xFEE0u is warning-clean, but I don't know if it works.
--
if you search all around the code RWStepBasic for the string
ent->Init(hasAprefix,aPrefix,aName);
you will see that in all these functions, in case of error, the failure message is added, but the values are used anyway.
In case of error the used variables have an undefined value.
--
TopOpeBRepTool\TopOpeBRepTool_mkTondgE.cxx , line 367
the return statement makes the remaining code in the scope never executed. Is this intended?
---
GeomFill\GeomFill_LocationGuide.cxx, line 745
the return statement makes the whole scope dead code. Is this intended?
----
src\IntTools\IntTools_EdgeFace.cxx
Line 901 : you see there's a return 0 in a scope, that makes the remaining of the function dead code. Is it intended?
---------
src\BRepFill\BRepFill_OffsetWire.cxx , line 622
if (CT2d->BasisCurve()->IsKind(STANDARD_TYPE(Geom2d_Circle)) &&
( Abs(f-l) >= M_PI) ) {
return 0; //
the return makes the remaining scope dead code. Is it intended?
--------
src\TopOpeBRep\TopOpeBRep_ShapeIntersector2d.cxx , line 281
the NextFFCouple() line is never executed
---
src\V2d\V2d_RectangularGraphicGrid.cxx , line 71
alpha = Standard_ShortReal ( alpha - 1.57/2.0 );
that is probably PI / 4
and in the line above the two 1.57 are just PI / 2
maybe the 1.41 is sqrt(2) ?
---
src\IFSelect\IFSelect_WorkSession.cxx , line 2825
thecheckana = TCollection_AsciiString (' ',nb+1);
probably the constructor parameters are reversed, should be nb+1,' '
---
Public activity
11 archived notes
Participants are labeled by their role within this record.
I suggest we create separate issues (children of this one) per problem type / OCCT module, to simplify code review.
should I do that?
how can I create a "child" issue? or the relationship is assigned after the creation?
how can I create a "child" issue? or the relationship is assigned after the creation?
Author: I hope Dmitry will create child issues, though if you wish you can do this as well. The relationships between issues are set after the issues are created (see block 'Relationships').
I cannot set the relashionships, probably I don't have the rights.
I have added other issues related to this one, you may want to set these related to this one too.
I have added other issues related to this one, you may want to set these related to this one too.
Dear OAN,
Fix is is integrated into branch CR23132.
Please, review.
Fix is is integrated into branch CR23132.
Please, review.
Dear JGV,
please review the changes.
please review the changes.
No remarks
Dear Commenter 2,
Branch CR23132(and products from GIT master) was compiled on Linux and Windows platforms and tested.
Regression:
boolean bfuse_complex Q8 Q9
caf named_shape E8
caf driver A8
Improvements:
Not detected
Testing case:
Not needed
Branch CR23132(and products from GIT master) was compiled on Linux and Windows platforms and tested.
Regression:
boolean bfuse_complex Q8 Q9
caf named_shape E8
caf driver A8
Improvements:
Not detected
Testing case:
Not needed
Dear apn,
I've fixed the mistake that led to fails in test cases, that you mentioned.
Please, test.
I've fixed the mistake that led to fails in test cases, that you mentioned.
Please, test.
Dear Commenter 2,
Branch CR23132 (and products from occt GIT master) was compiled on Linux and Windows platforms and tested.
Regressions:
Not detected
Improvements:
Not detected
Testing cases:
Not needed
Branch CR23132 (and products from occt GIT master) was compiled on Linux and Windows platforms and tested.
Regressions:
Not detected
Improvements:
Not detected
Testing cases:
Not needed
Dear Commenter 2,
Branch CR23132 (and products from occt GIT master) was compiled on Linux and Windows platforms and retested.
Regressions:
Not detected
Improvements:
Not detected
Testing cases:
Not needed
Branch CR23132 (and products from occt GIT master) was compiled on Linux and Windows platforms and retested.
Regressions:
Not detected
Improvements:
Not detected
Testing cases:
Not needed
Related records
- #0023140 · parent of · closedSuspicious if
- #0023141 · parent of · closedSuspicious if (2)
- #0023142 · parent of · closedGccAna : suspicious else
- #0023143 · parent of · closedSuspicious else
- #0023144 · parent of · closedSuspicious if (3)
- #0023145 · parent of · closedSuspicious else (2)
- #0023146 · parent of · closedSuspicious if (4)
- #0023147 · parent of · closedSuspicious if (5)
- #0023288 · parent of · closedIntCurve_IntConicConic_1.cxx: if(A) {...} else if (A){...} pattern detected
- #0023289 · parent of · closedIntCurve_IntPolyPolyGen.gxx, suspicious else
- #0023290 · parent of · closedIntCurve_IntPolyPolyGen.gxx, suspicious if/for
- #0023291 · parent of · closedGccAna_Circ2d3Tan_8.cxx, suspicious if
- #0023293 · parent of · closedboptools_tools2d.cxx 333 suspicious if/else
- #0023309 · parent of · closedThe 'then' statement is equivalent to the 'else' statement in TopOpeBRep_EdgesFiller.cxx
- #0023312 · parent of · closedSuspicious for loop in BiTgte_Blend.cxx