]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Add an explicit return type to getObjectFromYAMLConfiguration 15747/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 1 Jul 2025 08:01:06 +0000 (10:01 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 1 Jul 2025 08:01:06 +0000 (10:01 +0200)
As suggested by Otto.

Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-configuration-yaml.cc

index 49743a17c4a55dae3d79e44dc126f8f75a106b8a..0c7113b0d6130cb2cc44fa04dc4086a18dc7bcc6 100644 (file)
@@ -1172,12 +1172,11 @@ void addLuaBindingsForYAMLObjects([[maybe_unused]] LuaContext& luaCtx)
 #if defined(HAVE_YAML_CONFIGURATION)
   using ReturnValue = boost::optional<boost::variant<std::shared_ptr<DNSDistPacketCache>, std::shared_ptr<DNSRule>, std::shared_ptr<DNSAction>, std::shared_ptr<DNSResponseAction>, std::shared_ptr<NetmaskGroup>, std::shared_ptr<KeyValueStore>, std::shared_ptr<KeyValueLookupKey>, std::shared_ptr<RemoteLoggerInterface>, std::shared_ptr<ServerPolicy>, std::shared_ptr<XSKMap>>>;
 
-  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<std::shared_ptr<DNSDistPacketCache>>(&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 */
 }