]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Coverity-20241105 and one log level change 14824/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 5 Nov 2024 09:48:54 +0000 (10:48 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 5 Nov 2024 09:48:54 +0000 (10:48 +0100)
pdns/recursordist/lua-recursor4.cc

index 3ad86491ef94239d84903b31fb3b9b4ab5c10f38..2a31ec8b0c040a2342e037022f6ec4378186c6ed 100644 (file)
@@ -507,7 +507,7 @@ void RecursorLua4::postPrepareContext() // NOLINT(readability-function-cognitive
   d_lw->writeFunction("spawnThread", [](const string& scriptName) {
     auto log = g_slog->withName("lua")->withValues("script", Logging::Loggable(scriptName));
     log->info(Logr::Info, "Starting Lua script in separate thread");
-    std::thread thread([=]() {
+    std::thread thread([log = std::move(log), scriptName]() {
       auto lua = std::make_shared<RecursorLua4>();
       lua->loadFile(scriptName);
       log->info(Logr::Notice, "Lua thread exiting");
@@ -555,14 +555,15 @@ void RecursorLua4::runStartStopFunction(const string& script, bool start, Logr::
   const string func = start ? "on_recursor_start" : "on_recursor_stop";
   auto mylog = log->withValues("script", Logging::Loggable(script), "function", Logging::Loggable(func));
   loadFile(script);
-  auto call = d_lw->readVariable<boost::optional<std::function<void()>>>(func).get_value_or(nullptr);
+  // coverity[auto_causes_copy] does not work with &, despite what coverity thinks
+  const auto call = d_lw->readVariable<boost::optional<std::function<void()>>>(func).get_value_or(nullptr);
   if (call) {
     mylog->info(Logr::Info, "Starting Lua function");
     call();
     mylog->info(Logr::Info, "Lua function done");
   }
   else {
-    mylog->info(Logr::Info, "No Lua function found");
+    mylog->info(Logr::Notice, "No Lua function found");
   }
 }