]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Remove a construct that cppcheck is choking on
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 29 Jan 2021 15:59:35 +0000 (16:59 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 29 Jan 2021 15:59:35 +0000 (16:59 +0100)
pdns/dnsdist-lua-inspection.cc
pdns/dnsdist-rings.cc

index 9b31d29379f7539b06a083901f6b6eb090824d9d..70e92f06f3c5582b00f9cef21425f894b8a9a554 100644 (file)
@@ -75,7 +75,14 @@ static std::unordered_map<unsigned int, vector<boost::variant<string,double>>> 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;
 
     });
index 29da4431b46c44f6608d116a45b40dd85349f674..03f7f14792ea7f53d300c4dae093b0761601d012 100644 (file)
@@ -78,7 +78,14 @@ std::unordered_map<int, vector<boost::variant<string,double>>> 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;
 }