]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: hlua_fcn: fix Patref:set() force parameter
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 29 Nov 2024 06:33:51 +0000 (07:33 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Fri, 29 Nov 2024 06:39:38 +0000 (07:39 +0100)
Patref:set(key, val[, force]) takes optional "force" parameter (defaults
to false) to force the entry to be created if it doesn't already exist

To retrieve the value, lua_tointeger() was used in place of
lua_toboolean(), and because of that force is not enabled if "true"
is passed as parameter (only numbers were recognized) despite the
documentation mentioning that "force" is a boolean.

To fix the issue, we replace lua_tointeger by lua_toboolean.

Also, the doc was updated to rename "bool" to "boolean" for the "force"
parameter to stay consistent with historical naming in the file.

No backport needed unless 9ee37de5c ("MINOR: hlua_fcn: add Patref:set()")
is.

doc/lua-api/index.rst
src/hlua_fcn.c

index c16a07e6c7533dd40d71432f5f2c2b7a7eff3d3a..e0afaffcd136c9f7345cd5dcb6e9936399c3e928 100644 (file)
@@ -3558,7 +3558,7 @@ Patref class
 
   :param string key: the string used as a key
   :param string value: the string used as value
-  :param bool force: create the entry if it doesn't exist (optional,
+  :param boolean force: create the entry if it doesn't exist (optional,
    defaults to false)
   :returns: true on success and nil on failure (followed by an error message)
 
index 3118e40d56575dbe5ce12bade396def36c921f0d..b6252fbf1c770e36b5cf544bbfbb796a46b91aea 100644 (file)
@@ -2889,7 +2889,7 @@ int hlua_patref_set(lua_State *L)
        value = luaL_checkstring(L, 3);
 
        if (lua_gettop(L) == 4)
-               force = lua_tointeger(L, 4);
+               force = lua_toboolean(L, 4);
 
        HA_RWLOCK_WRLOCK(PATREF_LOCK, &ref->ptr->lock);
        if ((ref->flags & HLUA_PATREF_FL_GEN) &&