From: Otto Moerbeek Date: Mon, 11 Mar 2024 09:18:15 +0000 (+0100) Subject: Avoid label and goto in loop X-Git-Tag: rec-5.1.0-alpha1~130^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e7929f4207f3bac217896f697214a9fa107780fb;p=thirdparty%2Fpdns.git Avoid label and goto in loop --- diff --git a/pdns/recursordist/lua-recursor4.cc b/pdns/recursordist/lua-recursor4.cc index a9d6850b59..fce57eb378 100644 --- a/pdns/recursordist/lua-recursor4.cc +++ b/pdns/recursordist/lua-recursor4.cc @@ -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(packetBuffer.data()), packetBuffer.size()); + dnsQuestion.udpAnswer = std::string(reinterpret_cast(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>(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;