From 98a4aa7ca4c3277e81171a2597dc942e2bfaa2aa Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 28 May 2017 21:20:27 +0100 Subject: coverity#1409892 silence Operands don't affect result MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this might work to make this appear deliberate to coverity Change-Id: Iad11e72feb154991b04cfb5960bd06d33c6b96a0 Reviewed-on: https://gerrit.libreoffice.org/38116 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/o3tl/strong_int.hxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'include/o3tl') 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 constexpr typename std::enable_if< std::is_signed::value && std::is_signed::value, bool>::type isInRange(T2 value) { - return value >= std::numeric_limits::min() - && value <= std::numeric_limits::max(); + const bool ret = value >= std::numeric_limits::min() + && value <= std::numeric_limits::max(); + return ret; } template constexpr typename std::enable_if< std::is_signed::value && std::is_unsigned::value, bool>::type isInRange(T2 value) { - return value + const bool ret = value <= static_cast::type>( std::numeric_limits::max()); + return ret; } template constexpr typename std::enable_if< std::is_unsigned::value && std::is_signed::value, bool>::type isInRange(T2 value) { - return value >= 0 + const bool ret = value >= 0 && (static_cast::type>(value) <= std::numeric_limits::max()); + return ret; } template constexpr typename std::enable_if< std::is_unsigned::value && std::is_unsigned::value, bool>::type isInRange(T2 value) { - return value <= std::numeric_limits::max(); + const bool ret = value <= std::numeric_limits::max(); + return ret; } } -- cgit