]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix clang-tidy warnings
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 5 Dec 2023 09:54:37 +0000 (10:54 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 5 Dec 2023 10:06:37 +0000 (11:06 +0100)
pdns/dnsdist-lua-actions.cc
pdns/dnsdist-lua-bindings-dnsquestion.cc
pdns/dnsdist.cc
pdns/dnsdistdist/dnsdist-lua-ffi.cc

index 736d9aef867a15b6bb02d22806aeca6fcd4d46ea..66c2889bcf526f3e4d899c514423454cf41f4f54 100644 (file)
@@ -2497,11 +2497,11 @@ void setupLuaActions(LuaContext& luaCtx)
 
   luaCtx.writeFunction("SpoofRawAction", [](LuaTypeOrArrayOf<std::string> inp, boost::optional<responseParams_t> vars) {
       vector<string> raws;
-      if (auto str = boost::get<std::string>(&inp)) {
+      if (const auto* str = boost::get<std::string>(&inp)) {
         raws.push_back(*str);
       } else {
         const auto& vect = boost::get<LuaArray<std::string>>(inp);
-        for(const auto& raw: vect) {
+        for (const auto& raw: vect) {
           raws.push_back(raw.second);
         }
       }
index 377f463062bdaca9e02283be053dd10bf14c545f..4512fc5ef4f81b4a6d8e06da64005a931f22b5c0 100644 (file)
@@ -227,7 +227,7 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx)
     return true;
   });
 
-  luaCtx.registerFunction<void(DNSQuestion::*)(const boost::variant<LuaArray<ComboAddress>, LuaArray<std::string>>&, boost::optional<uint16_t>)>("spoof", [](DNSQuestion& dq, const boost::variant<LuaArray<ComboAddress>, LuaArray<std::string>>& response, boost::optional<uint16_t> typeForAny) {
+  luaCtx.registerFunction<void(DNSQuestion::*)(const boost::variant<LuaArray<ComboAddress>, LuaArray<std::string>>&, boost::optional<uint16_t>)>("spoof", [](DNSQuestion& dnsQuestion, const boost::variant<LuaArray<ComboAddress>, LuaArray<std::string>>& response, boost::optional<uint16_t> typeForAny) {
       if (response.type() == typeid(LuaArray<ComboAddress>)) {
           std::vector<ComboAddress> data;
           auto responses = boost::get<LuaArray<ComboAddress>>(response);
@@ -236,8 +236,8 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx)
             data.push_back(resp.second);
           }
           std::string result;
-          SpoofAction sa(data);
-          sa(&dq, &result);
+          SpoofAction tempSpoofAction(data);
+          tempSpoofAction(&dnsQuestion, &result);
          return;
       }
       if (response.type() == typeid(LuaArray<std::string>)) {
@@ -248,8 +248,8 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx)
             data.push_back(resp.second);
           }
           std::string result;
-          SpoofAction sa(data, typeForAny ? *typeForAny : std::optional<uint16_t>());
-          sa(&dq, &result);
+          SpoofAction tempSpoofAction(data, typeForAny ? *typeForAny : std::optional<uint16_t>());
+          tempSpoofAction(&dnsQuestion, &result);
          return;
       }
   });
index 205afff95374df3008262951c604d07bdc8a4bf3..cf96c126532cea5e6f40982bf13b7b093663f3fe 100644 (file)
@@ -863,8 +863,8 @@ static void spoofResponseFromString(DNSQuestion& dq, const string& spoofContent,
   if (raw) {
     std::vector<std::string> raws;
     stringtok(raws, spoofContent, ",");
-    SpoofAction sa(raws, std::nullopt);
-    sa(&dq, &result);
+    SpoofAction tempSpoofAction(raws, std::nullopt);
+    tempSpoofAction(&dq, &result);
   }
   else {
     std::vector<std::string> addrs;
@@ -873,13 +873,13 @@ static void spoofResponseFromString(DNSQuestion& dq, const string& spoofContent,
     if (addrs.size() == 1) {
       try {
         ComboAddress spoofAddr(spoofContent);
-        SpoofAction sa({spoofAddr});
-        sa(&dq, &result);
+        SpoofAction tempSpoofAction({spoofAddr});
+        tempSpoofAction(&dq, &result);
       }
       catch(const PDNSException &e) {
         DNSName cname(spoofContent);
-        SpoofAction sa(cname); // CNAME then
-        sa(&dq, &result);
+        SpoofAction tempSpoofAction(cname); // CNAME then
+        tempSpoofAction(&dq, &result);
       }
     } else {
       std::vector<ComboAddress> cas;
@@ -890,8 +890,8 @@ static void spoofResponseFromString(DNSQuestion& dq, const string& spoofContent,
         catch (...) {
         }
       }
-      SpoofAction sa(cas);
-      sa(&dq, &result);
+      SpoofAction tempSpoofAction(cas);
+      tempSpoofAction(&dq, &result);
     }
   }
 }
@@ -900,8 +900,8 @@ static void spoofPacketFromString(DNSQuestion& dq, const string& spoofContent)
 {
   string result;
 
-  SpoofAction sa(spoofContent.c_str(), spoofContent.size());
-  sa(&dq, &result);
+  SpoofAction tempSpoofAction(spoofContent.c_str(), spoofContent.size());
+  tempSpoofAction(&dq, &result);
 }
 
 bool processRulesResult(const DNSAction::Action& action, DNSQuestion& dq, std::string& ruleresult, bool& drop)
index 98e373159a6379443f9a6412b8f33cb2552cf2fc..14f47e6ad381c5e6abe95a637173b80de742733e 100644 (file)
@@ -588,8 +588,8 @@ void dnsdist_ffi_dnsquestion_send_trap(dnsdist_ffi_dnsquestion_t* dq, const char
 void dnsdist_ffi_dnsquestion_spoof_packet(dnsdist_ffi_dnsquestion_t* dq, const char* raw, size_t len)
 {
   std::string result;
-  SpoofAction sa(raw, len);
-  sa(dq->dq, &result);
+  SpoofAction tempSpoofAction(raw, len);
+  tempSpoofAction(dq->dq, &result);
 }
 
 void dnsdist_ffi_dnsquestion_spoof_raw(dnsdist_ffi_dnsquestion_t* dq, const dnsdist_ffi_raw_value_t* values, size_t valuesCount)
@@ -602,8 +602,8 @@ void dnsdist_ffi_dnsquestion_spoof_raw(dnsdist_ffi_dnsquestion_t* dq, const dnsd
   }
 
   std::string result;
-  SpoofAction sa(data, std::nullopt);
-  sa(dq->dq, &result);
+  SpoofAction tempSpoofAction(data, std::nullopt);
+  tempSpoofAction(dq->dq, &result);
 }
 
 void dnsdist_ffi_dnsquestion_spoof_addrs(dnsdist_ffi_dnsquestion_t* dq, const dnsdist_ffi_raw_value_t* values, size_t valuesCount)
@@ -631,8 +631,8 @@ void dnsdist_ffi_dnsquestion_spoof_addrs(dnsdist_ffi_dnsquestion_t* dq, const dn
   }
 
   std::string result;
-  SpoofAction sa(data);
-  sa(dq->dq, &result);
+  SpoofAction tempSpoofAction(data);
+  tempSpoofAction(dq->dq, &result);
 }
 
 void dnsdist_ffi_dnsquestion_set_max_returned_ttl(dnsdist_ffi_dnsquestion_t* dq, uint32_t max)