From: Otto Moerbeek Date: Fri, 15 Nov 2024 14:48:18 +0000 (+0100) Subject: clang-tidy X-Git-Tag: dnsdist-2.0.0-alpha1~195^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3e00b6a53d9fb382d7a88abac2524e113bdbeda6;p=thirdparty%2Fpdns.git clang-tidy --- diff --git a/pdns/recursordist/test-syncres_cc.cc b/pdns/recursordist/test-syncres_cc.cc index 25ff8e09e0..87ce8d8de5 100644 --- a/pdns/recursordist/test-syncres_cc.cc +++ b/pdns/recursordist/test-syncres_cc.cc @@ -80,35 +80,39 @@ LWResult::Result asyncresolve(const ComboAddress& /* ip */, const DNSName& /* do bool primeHints(time_t now) { vector nsset; - if (!g_recCache) + if (!g_recCache) { g_recCache = std::make_unique(); - if (!g_negCache) + } + if (!g_negCache) { g_negCache = std::make_unique(); + } - DNSRecord arr, aaaarr, nsrr; + DNSRecord arr; + DNSRecord aaaarr; + DNSRecord nsrr; nsrr.d_name = g_rootdnsname; arr.d_type = QType::A; aaaarr.d_type = QType::AAAA; nsrr.d_type = QType::NS; arr.d_ttl = aaaarr.d_ttl = nsrr.d_ttl = now + 3600000; - for (char c = 'a'; c <= 'm'; ++c) { - char templ[40]; - strncpy(templ, "a.root-servers.net.", sizeof(templ) - 1); - templ[sizeof(templ) - 1] = '\0'; - *templ = c; - aaaarr.d_name = arr.d_name = DNSName(templ); - nsrr.setContent(std::make_shared(DNSName(templ))); - arr.setContent(std::make_shared(ComboAddress(rootIps4[c - 'a']))); + for (char character = 'a'; character <= 'm'; ++character) { + std::array templ{}; + strncpy(templ.data(), "a.root-servers.net.", sizeof(templ) - 1); + templ[templ.size() - 1] = '\0'; + templ.at(0) = character; + aaaarr.d_name = arr.d_name = DNSName(templ.data()); + nsrr.setContent(std::make_shared(DNSName(templ.data()))); + arr.setContent(std::make_shared(ComboAddress(rootIps4.at(character - 'a')))); vector aset; aset.push_back(arr); - g_recCache->replace(now, DNSName(templ), QType(QType::A), aset, vector>(), {}, false, g_rootdnsname); - if (!rootIps6[c - 'a'].empty()) { - aaaarr.setContent(std::make_shared(ComboAddress(rootIps6[c - 'a']))); + g_recCache->replace(now, DNSName(templ.data()), QType(QType::A), aset, vector>(), {}, false, g_rootdnsname); + if (!rootIps6.at(character - 'a').empty()) { + aaaarr.setContent(std::make_shared(ComboAddress(rootIps6.at(character - 'a')))); vector aaaaset; aaaaset.push_back(aaaarr); - g_recCache->replace(now, DNSName(templ), QType(QType::AAAA), aaaaset, vector>(), {}, false, g_rootdnsname); + g_recCache->replace(now, DNSName(templ.data()), QType(QType::AAAA), aaaaset, vector>(), {}, false, g_rootdnsname); } nsset.push_back(nsrr);