From 52aa2b5d24c560fb4d7a642971571ff9cbeabfcd Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 13 Mar 2024 09:20:34 -0300 Subject: [PATCH] Details - 'unsigned int' -> 'unsigned' - Some explicit casts to avoid warnings - Test avoids printing the value of 'fail' (which may not be nil) --- lauxlib.h | 2 +- ltablib.c | 2 +- lua.h | 3 +-- testes/main.lua | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lauxlib.h b/lauxlib.h index 0ee9a572..3c370686 100644 --- a/lauxlib.h +++ b/lauxlib.h @@ -100,7 +100,7 @@ LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); LUALIB_API lua_State *(luaL_newstate) (void); -LUALIB_API unsigned int luaL_makeseed (lua_State *L); +LUALIB_API unsigned luaL_makeseed (lua_State *L); LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx); diff --git a/ltablib.c b/ltablib.c index 2ba31a4f..4c3f6900 100644 --- a/ltablib.c +++ b/ltablib.c @@ -63,7 +63,7 @@ static int tcreate (lua_State *L) { lua_Unsigned sizerest = (lua_Unsigned)luaL_optinteger(L, 2, 0); luaL_argcheck(L, sizeseq <= UINT_MAX, 1, "out of range"); luaL_argcheck(L, sizerest <= UINT_MAX, 2, "out of range"); - lua_createtable(L, sizeseq, sizerest); + lua_createtable(L, (unsigned)sizeseq, (unsigned)sizerest); return 1; } diff --git a/lua.h b/lua.h index face93fa..b6934e68 100644 --- a/lua.h +++ b/lua.h @@ -160,8 +160,7 @@ extern const char lua_ident[]; /* ** state manipulation */ -LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud, - unsigned int seed); +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud, unsigned seed); LUA_API void (lua_close) (lua_State *L); LUA_API lua_State *(lua_newthread) (lua_State *L); LUA_API int (lua_closethread) (lua_State *L, lua_State *from); diff --git a/testes/main.lua b/testes/main.lua index dde72a74..5c7d0a10 100644 --- a/testes/main.lua +++ b/testes/main.lua @@ -312,7 +312,7 @@ setmetatable({}, {__gc = function () -- this finalizer should not be called, as object will be -- created after 'lua_close' has been called setmetatable({}, {__gc = function () print(3) end}) - print(collectgarbage()) -- cannot call collector here + print(collectgarbage() or false) -- cannot call collector here os.exit(0, true) end}) ]] @@ -322,7 +322,7 @@ creating 1 creating 2 2 creating 3 -nil +false 1 ]]