From: Otto Moerbeek Date: Wed, 21 Sep 2022 07:52:55 +0000 (+0200) Subject: Coverity fixes: auto_causes_copy and sprinkle const as well X-Git-Tag: rec-4.8.0-alpha1^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dacf2931a4abfd511fefa8864385bbc96ac4cffe;p=thirdparty%2Fpdns.git Coverity fixes: auto_causes_copy and sprinkle const as well Coverity 1491275, 1491274, 1491272, 1491271, 1491270, 1491269, 1491264, 1491263 --- diff --git a/pdns/dnswriter.cc b/pdns/dnswriter.cc index 0fd81b4d3d..ed239c80b1 100644 --- a/pdns/dnswriter.cc +++ b/pdns/dnswriter.cc @@ -432,7 +432,7 @@ template void GenericDNSPacketWriter::xfrSvcPara break; case SvcParam::ipv4hint: xfr16BitInt(param.getIPHints().size() * 4); // size - for (auto a: param.getIPHints()) { + for (const auto& a: param.getIPHints()) { xfrCAWithoutPort(param.getKey(), a); } break; diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index aa8449a7d3..37dcc1e2b1 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -500,7 +500,7 @@ static string doWipeCache(T begin, T end, uint16_t qtype) } int count = 0, pcount = 0, countNeg = 0; - for (auto wipe : toWipe) { + for (const auto& wipe : toWipe) { try { auto res = wipeCaches(wipe.first, wipe.second, qtype); count += res.record_count; @@ -697,7 +697,7 @@ static string getNTAs() string ret("Configured Negative Trust Anchors:\n"); auto luaconf = g_luaconfs.getLocal(); - for (auto negAnchor : luaconf->negAnchors) + for (const auto& negAnchor : luaconf->negAnchors) ret += negAnchor.first.toLogString() + "\t" + negAnchor.second + "\n"; return ret; } @@ -803,9 +803,9 @@ static string getTAs() string ret("Configured Trust Anchors:\n"); auto luaconf = g_luaconfs.getLocal(); - for (auto anchor : luaconf->dsAnchors) { + for (const auto& anchor : luaconf->dsAnchors) { ret += anchor.first.toLogString() + "\n"; - for (auto e : anchor.second) { + for (const auto& e : anchor.second) { ret += "\t\t" + e.getZoneRepresentation() + "\n"; } } diff --git a/pdns/recursordist/rec-zonetocache.cc b/pdns/recursordist/rec-zonetocache.cc index 07374eef55..a83dc43da8 100644 --- a/pdns/recursordist/rec-zonetocache.cc +++ b/pdns/recursordist/rec-zonetocache.cc @@ -430,7 +430,7 @@ void RecZoneToCache::maintainStates(const map& configs, mapsecond.d_generation != mygeneration) { diff --git a/pdns/ws-recursor.cc b/pdns/ws-recursor.cc index e34ffc228f..a1b0c57cad 100644 --- a/pdns/ws-recursor.cc +++ b/pdns/ws-recursor.cc @@ -90,7 +90,7 @@ static void apiServerConfigACL(const std::string& aclType, HttpRequest* req, Htt } NetmaskGroup nmg; - for (auto value : jlist.array_items()) { + for (const auto& value : jlist.array_items()) { try { nmg.addMask(value.string_value()); } @@ -225,7 +225,7 @@ static void doCreateZone(const Json document) } else if (kind == "FORWARDED") { string serverlist; - for (auto value : document["servers"].array_items()) { + for (const auto& value : document["servers"].array_items()) { string server = value.string_value(); if (server == "") { throw ApiException("Forwarded-to server must not be an empty string");