From db80ce4d1b94d51f31d3055b91cababa6fb0e642 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Tue, 24 Jan 2017 11:31:40 +0100 Subject: [PATCH] fixed issues reported by coverity scan --- lib/Basics/VelocyPackHelper.h | 2 +- lib/ProgramOptions/Parameters.h | 20 +++++++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/Basics/VelocyPackHelper.h b/lib/Basics/VelocyPackHelper.h index 25de7f95cc..797ef95c1f 100644 --- a/lib/Basics/VelocyPackHelper.h +++ b/lib/Basics/VelocyPackHelper.h @@ -444,7 +444,7 @@ struct hash { template <> struct equal_to { bool operator()(arangodb::basics::VPackHashedSlice const& lhs, - arangodb::basics::VPackHashedSlice const& rhs) const noexcept { + arangodb::basics::VPackHashedSlice const& rhs) const { return lhs.slice.equals(rhs.slice); } }; diff --git a/lib/ProgramOptions/Parameters.h b/lib/ProgramOptions/Parameters.h index 0111ddf0a7..0fd03d6a3e 100644 --- a/lib/ProgramOptions/Parameters.h +++ b/lib/ProgramOptions/Parameters.h @@ -42,8 +42,8 @@ namespace options { template inline typename std::enable_if::value, T>::type toNumber( std::string const& value) { - auto v = static_cast(std::stoll(value)); - if (v < (std::numeric_limits::min)() || v > (std::numeric_limits::max)()) { + auto v = static_cast(std::stoll(value)); + if (v < static_cast((std::numeric_limits::min)()) || v > static_cast((std::numeric_limits::max)())) { throw std::out_of_range(value); } return static_cast(v); @@ -53,8 +53,8 @@ inline typename std::enable_if::value, T>::type toNumber( template inline typename std::enable_if::value, T>::type toNumber( std::string const& value) { - auto v = static_cast(std::stoull(value)); - if (v < (std::numeric_limits::min)() || v > (std::numeric_limits::max)()) { + auto v = static_cast(std::stoull(value)); + if (v < static_cast((std::numeric_limits::min)()) || v > static_cast((std::numeric_limits::max)())) { throw std::out_of_range(value); } return static_cast(v); @@ -210,15 +210,11 @@ struct NumericParameter : public Parameter { std::string set(std::string const& value) override { try { ValueType v = toNumber(value); - if (v >= (std::numeric_limits::min)() && - v <= (std::numeric_limits::max)()) { - *ptr = v; - return ""; - } + *ptr = v; + return ""; } catch (...) { return "invalid numeric value"; } - return "number out of range"; } void toVPack(VPackBuilder& builder) const override { @@ -291,9 +287,7 @@ struct BoundedParameter : public T { std::string set(std::string const& value) override { try { typename T::ValueType v = toNumber(value); - if (v >= (std::numeric_limits::min)() && - v <= (std::numeric_limits::max)() && v >= minValue && - v <= maxValue) { + if (v >= minValue && v <= maxValue) { *this->ptr = v; return ""; }