From 599f2311a8893c7e19fef689ce30854720a9d0fe Mon Sep 17 00:00:00 2001 From: Thierry Fournier Date: Fri, 30 Sep 2022 10:40:39 +0200 Subject: [PATCH] MINOR: hlua: Fix two functions that return nothing useful 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 | 2 +- src/hlua_fcn.c | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/include/haproxy/hlua_fcn.h b/include/haproxy/hlua_fcn.h index 0ee218359..dca345a2f 100644 --- a/include/haproxy/hlua_fcn.h +++ b/include/haproxy/hlua_fcn.h @@ -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 */ diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c index 975ed246e..af5fdf4a8 100644 --- a/src/hlua_fcn.c +++ b/src/hlua_fcn.c @@ -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; }