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

Caolán McNamara caolanm at redhat.com
Tue Jun 6 13:10:01 UTC 2017


 include/o3tl/strong_int.hxx |   16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

New commits:
commit d8ea0efb037b1cf2e19cecba464d2fd915dff814
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jun 6 13:42:35 2017 +0100

    coverity#1409892 silence Operands don't affect result
    
    Change-Id: I283701880ea9e0a8485ef131afc93438c77451e1

diff --git a/include/o3tl/strong_int.hxx b/include/o3tl/strong_int.hxx
index 738d30f01a8b..2c9177b405e0 100644
--- a/include/o3tl/strong_int.hxx
+++ b/include/o3tl/strong_int.hxx
@@ -36,37 +36,33 @@ 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) {
-    const bool ret = value >= std::numeric_limits<T1>::min()
-                  && value <= std::numeric_limits<T1>::max();
-    return ret;
+    return value >= std::numeric_limits<T1>::min()
+        && value <= std::numeric_limits<T1>::max();
 }
 
 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) {
-    const bool ret = value
+    return 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) {
-    const bool ret = value >= 0
+    return 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) {
-    const bool ret = value <= std::numeric_limits<T1>::max();
-    return ret;
+    return value <= std::numeric_limits<T1>::max();
 }
 
 }
@@ -93,7 +89,7 @@ public:
         typename std::enable_if<std::is_integral<T>::value, int>::type = 0):
         m_value(value)
     {
-#if HAVE_CXX14_CONSTEXPR
+#if !defined __COVERITY__ && HAVE_CXX14_CONSTEXPR
         // catch attempts to pass in out-of-range values early
         assert(detail::isInRange<UNDERLYING_TYPE>(value)
                && "out of range");


More information about the Libreoffice-commits mailing list