diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-08-13 14:32:47 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-08-13 17:44:50 +0200 |
commit | 2abea7b8799f20ae2f47bb9f938670dea4f4f09f (patch) | |
tree | 59707c1b6e03aedc852371b132597eb46cd56299 | |
parent | f8d6c00d4c6d2e5f63dc660069c858bdc8affec6 (diff) |
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@redhat.com>
-rw-r--r-- | vcl/source/window/scrwnd.cxx | 10 | ||||
-rw-r--r-- | vcl/source/window/window2.cxx | 6 |
2 files changed, 10 insertions, 6 deletions
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); |