From 36c5a9e7129d68a7c7334437965c2db127e10428 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Wed, 12 Jan 2022 13:49:53 +0100 Subject: [PATCH] Work around a compiler bug seen on OpenBSD/amd64 using clang-13 and make the code a tiny bit more pretty. Fixes #11113. --- pdns/dnsdist-lua-bindings.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pdns/dnsdist-lua-bindings.cc b/pdns/dnsdist-lua-bindings.cc index bc264ab67e..c5b66c6d18 100644 --- a/pdns/dnsdist-lua-bindings.cc +++ b/pdns/dnsdist-lua-bindings.cc @@ -69,12 +69,18 @@ void setupLuaBindings(LuaContext& luaCtx, bool client) luaCtx.registerFunction("toString", &ServerPolicy::toString); luaCtx.registerFunction("__tostring", &ServerPolicy::toString); - luaCtx.writeVariable("firstAvailable", ServerPolicy{"firstAvailable", firstAvailable, false}); - luaCtx.writeVariable("roundrobin", ServerPolicy{"roundrobin", roundrobin, false}); - luaCtx.writeVariable("wrandom", ServerPolicy{"wrandom", wrandom, false}); - luaCtx.writeVariable("whashed", ServerPolicy{"whashed", whashed, false}); - luaCtx.writeVariable("chashed", ServerPolicy{"chashed", chashed, false}); - luaCtx.writeVariable("leastOutstanding", ServerPolicy{"leastOutstanding", leastOutstanding, false}); + ServerPolicy policies[] = { + ServerPolicy{"firstAvailable", firstAvailable, false}, + ServerPolicy{"roundrobin", roundrobin, false}, + ServerPolicy{"wrandom", wrandom, false}, + ServerPolicy{"whashed", whashed, false}, + ServerPolicy{"chashed", chashed, false}, + ServerPolicy{"leastOutstanding", leastOutstanding, false} + }; + for (auto& policy : policies) { + luaCtx.writeVariable(policy.d_name, policy); + } + #endif /* DISABLE_POLICIES_BINDINGS */ /* ServerPool */ -- 2.47.2