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: rec-5.3.0-alpha2~22^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F15747%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Add an explicit return type to getObjectFromYAMLConfiguration As suggested by Otto. Signed-off-by: Remi Gacogne --- diff --git a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc index 49743a17c4..0c7113b0d6 100644 --- a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc +++ b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc @@ -1172,12 +1172,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); @@ -1210,7 +1209,7 @@ void addLuaBindingsForYAMLObjects([[maybe_unused]] LuaContext& luaCtx) return ReturnValue(*ptr); } - return object; + return boost::none; }); #endif /* HAVE_YAML_CONFIGURATION */ }