From 5d1807e1d14348a6906c5bb471fd39a2df412286 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 5 Nov 2024 10:48:54 +0100 Subject: [PATCH] rec: Coverity-20241105 and one log level change --- pdns/recursordist/lua-recursor4.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pdns/recursordist/lua-recursor4.cc b/pdns/recursordist/lua-recursor4.cc index 3ad86491ef..2a31ec8b0c 100644 --- a/pdns/recursordist/lua-recursor4.cc +++ b/pdns/recursordist/lua-recursor4.cc @@ -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(); 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>>(func).get_value_or(nullptr); + // coverity[auto_causes_copy] does not work with &, despite what coverity thinks + const auto call = d_lw->readVariable>>(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"); } } -- 2.47.2