summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-10-22 12:54:16 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-10-22 16:45:11 +0100
commit73ffc462b9b7b1e48470c17d6fbffda66be76e67 (patch)
treeb8a1917508d9af9b0a975b660fbe852281dd9f84
parentd7f3eed145fa8220bb34de1f21403d80b2b3f5ae (diff)
coverity#1326120 try and silence Constant expression result
Change-Id: Iafd034dd51135ad99f56279ceee1c770f91436b0
-rw-r--r--basegfx/source/curve/b2dcubicbezier.cxx4
-rw-r--r--basegfx/source/polygon/b2dpolygoncutandtouch.cxx4
-rw-r--r--include/basegfx/numeric/ftools.hxx6
3 files changed, 10 insertions, 4 deletions
diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx
index bbafb7bbfa0d..ee87cbe7256b 100644
--- a/basegfx/source/curve/b2dcubicbezier.cxx
+++ b/basegfx/source/curve/b2dcubicbezier.cxx
@@ -446,7 +446,7 @@ namespace basegfx
: aVecA.getY() / aEdge.getY());
// relative end point of vector in edge range?
- if(fTools::moreOrEqual(fScale, 0.0) && fTools::lessOrEqual(fScale, 1.0))
+ if (fTools::betweenOrEqualEither(fScale, 0.0, 1.0))
{
bAIsTrivial = true;
}
@@ -468,7 +468,7 @@ namespace basegfx
: aVecB.getY() / aEdge.getY());
// end point of vector in edge range? Caution: controlB is directed AGAINST edge
- if(fTools::lessOrEqual(fScale, 0.0) && fTools::moreOrEqual(fScale, -1.0))
+ if (fTools::betweenOrEqualEither(fScale, -1.0, 0.0))
{
bBIsTrivial = true;
}
diff --git a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
index 25b05307f213..0ccebe9fb38d 100644
--- a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
+++ b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
@@ -229,7 +229,7 @@ namespace basegfx
const double fOne(1.0);
fCut = (aVecB.getY() * (rCurrB.getX() - rCurrA.getX()) + aVecB.getX() * (rCurrA.getY() - rCurrB.getY())) / fCut;
- if(fTools::moreOrEqual(fCut, fZero) && fTools::lessOrEqual(fCut, fOne))
+ if (fTools::betweenOrEqualEither(fCut, fZero, fOne))
{
// it's a candidate, but also need to test parameter value of cut on line 2
double fCut2;
@@ -244,7 +244,7 @@ namespace basegfx
fCut2 = (rCurrA.getY() + (fCut * aVecA.getY()) - rCurrB.getY()) / aVecB.getY();
}
- if(fTools::moreOrEqual(fCut2, fZero) && fTools::lessOrEqual(fCut2, fOne))
+ if (fTools::betweenOrEqualEither(fCut2, fZero, fOne))
{
// cut is in range, add point. Two edges can have only one cut, but
// add a cut point to each list. The lists may be the same for
diff --git a/include/basegfx/numeric/ftools.hxx b/include/basegfx/numeric/ftools.hxx
index b4ae0a484bd8..35a1a35111b2 100644
--- a/include/basegfx/numeric/ftools.hxx
+++ b/include/basegfx/numeric/ftools.hxx
@@ -196,6 +196,12 @@ namespace basegfx
{
return (rfValA > rfValB || equal(rfValA, rfValB));
}
+
+ static bool betweenOrEqualEither(const double& rfValA, const double& rfValB, const double& rfValC)
+ {
+ return (rfValA > rfValB && rfValA < rfValC) || equal(rfValA, rfValB) || equal(rfValA, rfValC);
+ }
+
};
} // end of namespace basegfx