[Libreoffice-commits] core.git: include/o3tl

Caolán McNamara caolanm at redhat.com
Sun May 28 22:43:15 UTC 2017


 include/o3tl/strong_int.hxx |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

New commits:
commit 98a4aa7ca4c3277e81171a2597dc942e2bfaa2aa
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun May 28 21:20:27 2017 +0100

    coverity#1409892 silence Operands don't affect result
    
    this might work to make this appear deliberate to coverity
    
    Change-Id: Iad11e72feb154991b04cfb5960bd06d33c6b96a0
    Reviewed-on: https://gerrit.libreoffice.org/38116
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/o3tl/strong_int.hxx b/include/o3tl/strong_int.hxx
index 8a9d91dbfb8c..738d30f01a8b 100644
--- a/include/o3tl/strong_int.hxx
+++ b/include/o3tl/strong_int.hxx
@@ -36,33 +36,37 @@ template<typename T1, typename T2> constexpr
 typename std::enable_if<
     std::is_signed<T1>::value && std::is_signed<T2>::value, bool>::type
 isInRange(T2 value) {
-    return value >= std::numeric_limits<T1>::min()
-        && value <= std::numeric_limits<T1>::max();
+    const bool ret = value >= std::numeric_limits<T1>::min()
+                  && value <= std::numeric_limits<T1>::max();
+    return ret;
 }
 
 template<typename T1, typename T2> constexpr
 typename std::enable_if<
     std::is_signed<T1>::value && std::is_unsigned<T2>::value, bool>::type
 isInRange(T2 value) {
-    return value
+    const bool ret = value
         <= static_cast<typename std::make_unsigned<T1>::type>(
             std::numeric_limits<T1>::max());
+    return ret;
 }
 
 template<typename T1, typename T2> constexpr
 typename std::enable_if<
     std::is_unsigned<T1>::value && std::is_signed<T2>::value, bool>::type
 isInRange(T2 value) {
-    return value >= 0
+    const bool ret = value >= 0
         && (static_cast<typename std::make_unsigned<T2>::type>(value)
             <= std::numeric_limits<T1>::max());
+    return ret;
 }
 
 template<typename T1, typename T2> constexpr
 typename std::enable_if<
     std::is_unsigned<T1>::value && std::is_unsigned<T2>::value, bool>::type
 isInRange(T2 value) {
-    return value <= std::numeric_limits<T1>::max();
+    const bool ret = value <= std::numeric_limits<T1>::max();
+    return ret;
 }
 
 }


More information about the Libreoffice-commits mailing list