[Libreoffice-commits] core.git: include/tools tools/source

Stephan Bergmann sbergman at redhat.com
Mon Oct 16 12:43:25 UTC 2017


 include/tools/fract.hxx        |    2 --
 tools/source/generic/fract.cxx |   31 +------------------------------
 2 files changed, 1 insertion(+), 32 deletions(-)

New commits:
commit cb19a1ab5b8e6f1a4fdd90e50d13c106512b4da0
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Oct 16 14:39:29 2017 +0200

    -Werror,-Wtautological-constant-compare (Clang 6)
    
    ...making Fraction::HasOverflowValue() always return false on all platforms,
    regardless of size of long, since 331e2e5ed3bf4e0b2c1fab3b7bca836170317827
    "long->sal_Int32 in Fraction" changed Fraction::Impl::value from
    boost::rational<sal_Int64> to boost::rational<sal_Int32>, and changed the limits
    to compare with in Fraction::HasOverflowValue from long to sal_Int32.
    
    Change-Id: I226ca240d6092ac803a1f65a363b1384903da17a

diff --git a/include/tools/fract.hxx b/include/tools/fract.hxx
index 95aa5f5e727b..74075e63cafc 100644
--- a/include/tools/fract.hxx
+++ b/include/tools/fract.hxx
@@ -32,8 +32,6 @@ class SAL_WARN_UNUSED TOOLS_DLLPUBLIC Fraction final
 
     std::unique_ptr<Impl> mpImpl;
 
-    bool            HasOverflowValue();
-
 public:
                     Fraction();
                     Fraction( const Fraction & rFrac );
diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx
index 1a78d4dfc654..d50cffc990aa 100644
--- a/tools/source/generic/fract.cxx
+++ b/tools/source/generic/fract.cxx
@@ -112,8 +112,6 @@ Fraction::Fraction( double dVal ) : mpImpl(new Impl)
     try
     {
         mpImpl->value = rational_FromDouble( dVal );
-        if ( HasOverflowValue() )
-            throw boost::bad_rational();
         mpImpl->valid = true;
     }
     catch (const boost::bad_rational&)
@@ -127,15 +125,6 @@ Fraction::~Fraction()
 {
 }
 
-bool Fraction::HasOverflowValue()
-{
-    //coverity[result_independent_of_operands]
-    return mpImpl->value.numerator() < std::numeric_limits<sal_Int32>::min() ||
-        mpImpl->value.numerator() > std::numeric_limits<sal_Int32>::max() ||
-        mpImpl->value.denominator() < std::numeric_limits<sal_Int32>::min() ||
-        mpImpl->value.denominator() > std::numeric_limits<sal_Int32>::max();
-}
-
 Fraction::operator double() const
 {
     if (!mpImpl->valid)
@@ -164,12 +153,6 @@ Fraction& Fraction::operator += ( const Fraction& rVal )
 
     mpImpl->value += rVal.mpImpl->value;
 
-    if ( HasOverflowValue() )
-    {
-        mpImpl->valid = false;
-        SAL_WARN( "tools.fraction", "'operator +=' detected overflow" );
-    }
-
     return *this;
 }
 
@@ -186,12 +169,6 @@ Fraction& Fraction::operator -= ( const Fraction& rVal )
 
     mpImpl->value -= rVal.mpImpl->value;
 
-    if ( HasOverflowValue() )
-    {
-        mpImpl->valid = false;
-        SAL_WARN( "tools.fraction", "'operator -=' detected overflow" );
-    }
-
     return *this;
 }
 
@@ -231,7 +208,7 @@ Fraction& Fraction::operator *= ( const Fraction& rVal )
 
     bool bFail = checked_multiply_by(mpImpl->value, rVal.mpImpl->value);
 
-    if (bFail || HasOverflowValue())
+    if (bFail)
     {
         mpImpl->valid = false;
     }
@@ -252,12 +229,6 @@ Fraction& Fraction::operator /= ( const Fraction& rVal )
 
     mpImpl->value /= rVal.mpImpl->value;
 
-    if ( HasOverflowValue() )
-    {
-        mpImpl->valid = false;
-        SAL_WARN( "tools.fraction", "'operator /=' detected overflow" );
-    }
-
     return *this;
 }
 


More information about the Libreoffice-commits mailing list