MINOR: hlua: fix return type for hlua_checkfunction() and hlua_checktable()

hlua_checktable() and hlua_checkfunction() both return the raw
value of luaL_ref() function call.
As luaL_ref() returns a signed int, both functions should return a signed
int as well to prevent any misuse of the returned reference value.
This commit is contained in:
Aurelien DARRAGON 2023-03-20 18:36:08 +01:00 committed by Christopher Faulet
parent f8f8a2b872
commit 9ee0d04770

View File

@ -475,7 +475,7 @@ static inline int reg_flt_to_stack_id(struct hlua_reg_filter *reg_flt)
* error if the argument is not a "function". * error if the argument is not a "function".
* When no longer used, the ref must be released with hlua_unref() * When no longer used, the ref must be released with hlua_unref()
*/ */
__LJMP unsigned int hlua_checkfunction(lua_State *L, int argno) __LJMP int hlua_checkfunction(lua_State *L, int argno)
{ {
if (!lua_isfunction(L, argno)) { if (!lua_isfunction(L, argno)) {
const char *msg = lua_pushfstring(L, "function expected, got %s", luaL_typename(L, argno)); const char *msg = lua_pushfstring(L, "function expected, got %s", luaL_typename(L, argno));
@ -490,7 +490,7 @@ __LJMP unsigned int hlua_checkfunction(lua_State *L, int argno)
* error if the argument is not a "table". * error if the argument is not a "table".
* When no longer used, the ref must be released with hlua_unref() * When no longer used, the ref must be released with hlua_unref()
*/ */
__LJMP unsigned int hlua_checktable(lua_State *L, int argno) __LJMP int hlua_checktable(lua_State *L, int argno)
{ {
if (!lua_istable(L, argno)) { if (!lua_istable(L, argno)) {
const char *msg = lua_pushfstring(L, "table expected, got %s", luaL_typename(L, argno)); const char *msg = lua_pushfstring(L, "table expected, got %s", luaL_typename(L, argno));