]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hlua: Fix two functions that return nothing useful
authorThierry Fournier <tfournier@arpalert.org>
Fri, 30 Sep 2022 08:40:39 +0000 (10:40 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Apr 2023 06:58:16 +0000 (08:58 +0200)
Two lua init function seems to return something useful, but it
is not the case. The function "hlua_concat_init" seems to return
a failure status, but the function never fails. The function
"hlua_fcn_reg_core_fcn" seems to return a number of elements in
the stack, but it is not the case.

include/haproxy/hlua_fcn.h
src/hlua_fcn.c

index 0ee21835945a79b1187b14a33ab40fd4e3e2ea56..dca345a2f22b88ca026e4437dbf750ce591ce97f 100644 (file)
@@ -31,8 +31,8 @@ void hlua_class_const_str(lua_State *L, const char *name, const char *value);
 void hlua_class_function(lua_State *L, const char *name, int (*function)(lua_State *L));
 void *hlua_checkudata(lua_State *L, int ud, int class_ref);
 int hlua_register_metatable(struct lua_State *L, char *name);
+void hlua_fcn_reg_core_fcn(lua_State *L);
 int hlua_fcn_post_init(lua_State *L);
-int hlua_fcn_reg_core_fcn(lua_State *L);
 int hlua_dump_object(lua_State *L);
 
 #endif /* _HAPROXY_HLUA_FCN_H */
index 975ed246ea2c7654b9cd530534294b52a575b7e1..af5fdf4a89585c2bfc6b9c714cf8300d6e67d403 100644 (file)
@@ -462,7 +462,7 @@ static int concat_tostring(lua_State *L)
        return 1;
 }
 
-static int hlua_concat_init(lua_State *L)
+static void hlua_concat_init(lua_State *L)
 {
        /* Creates the buffered concat object. */
        lua_newtable(L);
@@ -484,8 +484,6 @@ static int hlua_concat_init(lua_State *L)
 
        lua_settable(L, -3); /* Sets the __index entry. */
        class_concat_ref = luaL_ref(L, LUA_REGISTRYINDEX);
-
-       return 1;
 }
 
 int hlua_fcn_new_stktable(lua_State *L, struct stktable *tbl)
@@ -1682,10 +1680,9 @@ static int hlua_regex_free(struct lua_State *L)
        return 0;
 }
 
-int hlua_fcn_reg_core_fcn(lua_State *L)
+void hlua_fcn_reg_core_fcn(lua_State *L)
 {
-       if (!hlua_concat_init(L))
-               return 0;
+       hlua_concat_init(L);
 
        hlua_class_function(L, "now", hlua_now);
        hlua_class_function(L, "http_date", hlua_http_date);
@@ -1776,5 +1773,4 @@ int hlua_fcn_reg_core_fcn(lua_State *L)
        lua_settable(L, -3); /* -> META["__index"] = TABLE */
        class_proxy_ref = hlua_register_metatable(L, CLASS_PROXY);
 
-       return 5;
 }