[Libreoffice-commits] core.git: vcl/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 13 15:45:34 UTC 2019


 vcl/source/window/scrwnd.cxx  |   10 ++++++----
 vcl/source/window/window2.cxx |    6 ++++--
 2 files changed, 10 insertions(+), 6 deletions(-)

New commits:
commit 2abea7b8799f20ae2f47bb9f938670dea4f4f09f
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Aug 13 14:32:47 2019 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Aug 13 17:44:50 2019 +0200

    Fix Clang 10 -Werror,-Wimplicit-int-float-conversion
    
    > vcl/source/window/scrwnd.cxx:219:25: error: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion]
    >             if( fValX > LONG_MAX )
    >                       ~ ^~~~~~~~
    > vcl/source/window/scrwnd.cxx:226:25: error: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion]
    >             if( fValY > LONG_MAX )
    >                       ~ ^~~~~~~~
    
    > vcl/source/window/window2.cxx:603:30: error: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion]
    >             else if ( fVal > LONG_MAX )
    >                            ~ ^~~~~~~~
    
    Change-Id: Id7ad05ced920051d2698d42ab81ecd2690e34b35
    Reviewed-on: https://gerrit.libreoffice.org/77413
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/vcl/source/window/scrwnd.cxx b/vcl/source/window/scrwnd.cxx
index e81ad0205cca..85e9d20229ab 100644
--- a/vcl/source/window/scrwnd.cxx
+++ b/vcl/source/window/scrwnd.cxx
@@ -18,6 +18,8 @@
  */
 
 #include <limits.h>
+
+#include <o3tl/float_int_conversion.hxx>
 #include <tools/time.hxx>
 
 #include <strings.hrc>
@@ -216,16 +218,16 @@ void ImplWheelWindow::ImplRecalcScrollValues()
             double fValX = static_cast<double>(mnActDeltaX) * nMult;
             double fValY = static_cast<double>(mnActDeltaY) * nMult;
 
-            if( fValX > LONG_MAX )
+            if( !o3tl::convertsToAtMost(fValX, LONG_MAX) )
                 mnActDeltaX = LONG_MAX;
-            else if( fValX < LONG_MIN )
+            else if( !o3tl::convertsToAtLeast(fValX, LONG_MIN) )
                 mnActDeltaX = LONG_MIN;
             else
                 mnActDeltaX = static_cast<long>(fValX);
 
-            if( fValY > LONG_MAX )
+            if( !o3tl::convertsToAtMost(fValY, LONG_MAX) )
                 mnActDeltaY = LONG_MAX;
-            else if( fValY < LONG_MIN )
+            else if( !o3tl::convertsToAtLeast(fValY, LONG_MIN) )
                 mnActDeltaY = LONG_MIN;
             else
                 mnActDeltaY = static_cast<long>(fValY);
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index 636eb14b3854..701a8730ed87 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -18,6 +18,8 @@
  */
 
 #include <limits.h>
+
+#include <o3tl/float_int_conversion.hxx>
 #include <tools/poly.hxx>
 #include <sal/log.hxx>
 
@@ -598,9 +600,9 @@ static void lcl_HandleScrollHelper( ScrollBar* pScrl, double nN, bool isMultiply
 
             const double fVal = nNewPos - nN;
 
-            if ( fVal < LONG_MIN )
+            if ( !o3tl::convertsToAtMost(fVal, LONG_MIN) )
                 nNewPos = LONG_MIN;
-            else if ( fVal > LONG_MAX )
+            else if ( !o3tl::convertsToAtLeast(fVal, LONG_MAX) )
                 nNewPos = LONG_MAX;
             else
                 nNewPos = static_cast<long>(fVal);


More information about the Libreoffice-commits mailing list