From: Remi Gacogne Date: Fri, 29 Jan 2021 15:59:35 +0000 (+0100) Subject: dnsdist: Remove a construct that cppcheck is choking on X-Git-Tag: dnsdist-1.6.0-alpha1~1^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=870dee495dc376d5147a8037ab3f4d6f90780991;p=thirdparty%2Fpdns.git dnsdist: Remove a construct that cppcheck is choking on --- diff --git a/pdns/dnsdist-lua-inspection.cc b/pdns/dnsdist-lua-inspection.cc index 9b31d29379..70e92f06f3 100644 --- a/pdns/dnsdist-lua-inspection.cc +++ b/pdns/dnsdist-lua-inspection.cc @@ -75,7 +75,14 @@ static std::unordered_map>> g else ret.insert({count++, {rc.second.toString(), rc.first, 100.0*rc.first/total}}); } - ret.insert({count, {"Rest", rest, total > 0 ? 100.0*rest/total : 100.0}}); + + if (total > 0) { + ret.insert({count, {"Rest", rest, 100.0*rest/total}}); + } + else { + ret.insert({count, {"Rest", rest, 100.0 }}); + } + return ret; } @@ -302,7 +309,14 @@ void setupLuaInspection(LuaContext& luaCtx) else ret.insert({count++, {rc.second.toString(), rc.first, 100.0*rc.first/total}}); } - ret.insert({count, {"Rest", rest, total > 0 ? 100.0*rest/total : 100.0}}); + + if (total > 0) { + ret.insert({count, {"Rest", rest, 100.0*rest/total}}); + } + else { + ret.insert({count, {"Rest", rest, 100.0}}); + } + return ret; }); diff --git a/pdns/dnsdist-rings.cc b/pdns/dnsdist-rings.cc index 29da4431b4..03f7f14792 100644 --- a/pdns/dnsdist-rings.cc +++ b/pdns/dnsdist-rings.cc @@ -78,7 +78,14 @@ std::unordered_map>> Rings::getTopBand ret.insert({count++, {rc.second.toString(), rc.first, 100.0*rc.first/total}}); } } - ret.insert({count, {"Rest", rest, total > 0 ? 100.0*rest/total : 100.0}}); + + if (total > 0) { + ret.insert({count, {"Rest", rest, 100.0*rest/total}}); + } + else { + ret.insert({count, {"Rest", rest, 100.0 }}); + } + return ret; }