From: Remi Gacogne Date: Tue, 1 Jul 2025 08:01:06 +0000 (+0200) Subject: dnsdist: Add an explicit return type to getObjectFromYAMLConfiguration X-Git-Tag: dnsdist-2.0.0-rc1~1^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F15784%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Add an explicit return type to getObjectFromYAMLConfiguration As suggested by Otto. Signed-off-by: Remi Gacogne (cherry picked from commit 9263b481855ffc6e3324f2d342ce66b57e4ac0fa) Signed-off-by: Remi Gacogne --- diff --git a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc index 6aa29ab2b2..53a72c27d1 100644 --- a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc +++ b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc @@ -1187,12 +1187,11 @@ void addLuaBindingsForYAMLObjects([[maybe_unused]] LuaContext& luaCtx) #if defined(HAVE_YAML_CONFIGURATION) using ReturnValue = boost::optional, std::shared_ptr, std::shared_ptr, std::shared_ptr, std::shared_ptr, std::shared_ptr, std::shared_ptr, std::shared_ptr, std::shared_ptr, std::shared_ptr>>; - luaCtx.writeFunction("getObjectFromYAMLConfiguration", [](const std::string& name) { - ReturnValue object{boost::none}; + luaCtx.writeFunction("getObjectFromYAMLConfiguration", [](const std::string& name) -> ReturnValue { auto map = s_registeredTypesMap.lock(); auto item = map->find(name); if (item == map->end()) { - return object; + return boost::none; } if (auto* ptr = std::get_if>(&item->second)) { return ReturnValue(*ptr); @@ -1225,7 +1224,7 @@ void addLuaBindingsForYAMLObjects([[maybe_unused]] LuaContext& luaCtx) return ReturnValue(*ptr); } - return object; + return boost::none; }); #endif /* HAVE_YAML_CONFIGURATION */ }