]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Avoid label and goto in loop
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 11 Mar 2024 09:18:15 +0000 (10:18 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 13 Mar 2024 09:23:23 +0000 (10:23 +0100)
pdns/recursordist/lua-recursor4.cc

index a9d6850b592bb042d482ad2d2e4a1249303c091b..fce57eb37813e565469cc13a39389b7fe2e831f5 100644 (file)
@@ -749,8 +749,11 @@ bool RecursorLua4::genhook(const luacall_t& func, DNSQuestion& dnsQuestion, int&
   dnsQuestion.rcode = ret;
   bool handled = func(&dnsQuestion);
 
-  if (handled) {
-  loop:;
+  if (!handled) {
+    return false;
+  }
+
+  while (true) {
     ret = dnsQuestion.rcode;
 
     if (!dnsQuestion.followupFunction.empty()) {
@@ -765,7 +768,7 @@ bool RecursorLua4::genhook(const luacall_t& func, DNSQuestion& dnsQuestion, int&
       }
       else if (dnsQuestion.followupFunction == "udpQueryResponse") {
         PacketBuffer packetBuffer = GenUDPQueryResponse(dnsQuestion.udpQueryDest, dnsQuestion.udpQuery);
-        dnsQuestion.udpAnswer = std::string(reinterpret_cast<const char*>(packetBuffer.data()), packetBuffer.size());
+        dnsQuestion.udpAnswer = std::string(reinterpret_cast<const char *>(packetBuffer.data()), packetBuffer.size()); //NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
         // coverity[auto_causes_copy] not copying produces a dangling ref
         const auto cbFunc = d_lw->readVariable<boost::optional<luacall_t>>(dnsQuestion.udpCallback).get_value_or(nullptr);
         if (!cbFunc) {
@@ -777,16 +780,17 @@ bool RecursorLua4::genhook(const luacall_t& func, DNSQuestion& dnsQuestion, int&
         if (!result) {
           return false;
         }
-        goto loop;
+        continue;
       }
     }
     if (dnsQuestion.currentRecords != nullptr) {
       *dnsQuestion.currentRecords = dnsQuestion.records;
     }
+    break;
   }
 
   // see if they added followup work for us too
-  return handled;
+return true;
 }
 
 RecursorLua4::~RecursorLua4() = default;