From: Otto Moerbeek Date: Wed, 12 Jan 2022 12:49:53 +0000 (+0100) Subject: Work around a compiler bug seen on OpenBSD/amd64 using clang-13 and make the code... X-Git-Tag: auth-4.7.0-alpha1~79^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F11176%2Fhead;p=thirdparty%2Fpdns.git Work around a compiler bug seen on OpenBSD/amd64 using clang-13 and make the code a tiny bit more pretty. Fixes #11113. --- 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 */