mirror of
https://github.com/lua/lua
synced 2024-11-22 04:41:23 +03:00
Details
Some cast operations rewritten to use respective macros.
This commit is contained in:
parent
7f12bf40c4
commit
14d2803e55
4
ltable.c
4
ltable.c
@ -107,7 +107,7 @@ static const TValue absentkey = {ABSTKEYCONSTANT};
|
||||
*/
|
||||
static Node *hashint (const Table *t, lua_Integer i) {
|
||||
lua_Unsigned ui = l_castS2U(i);
|
||||
if (ui <= (unsigned int)INT_MAX)
|
||||
if (ui <= cast_uint(INT_MAX))
|
||||
return hashmod(t, cast_int(ui));
|
||||
else
|
||||
return hashmod(t, ui);
|
||||
@ -488,7 +488,7 @@ static void setnodevector (lua_State *L, Table *t, unsigned int size) {
|
||||
luaG_runerror(L, "table overflow");
|
||||
size = twoto(lsize);
|
||||
t->node = luaM_newvector(L, size, Node);
|
||||
for (i = 0; i < (int)size; i++) {
|
||||
for (i = 0; i < cast_int(size); i++) {
|
||||
Node *n = gnode(t, i);
|
||||
gnext(n) = 0;
|
||||
setnilkey(n);
|
||||
|
10
ltests.c
10
ltests.c
@ -533,7 +533,7 @@ static void checkobject (global_State *g, GCObject *o, int maybedead,
|
||||
|
||||
static lu_mem checkgraylist (global_State *g, GCObject *o) {
|
||||
int total = 0; /* count number of elements in the list */
|
||||
((void)g); /* better to keep it available if we need to print an object */
|
||||
cast_void(g); /* better to keep it if we need to print an object */
|
||||
while (o) {
|
||||
assert(!!isgray(o) ^ (getage(o) == G_TOUCHED2));
|
||||
assert(!testbit(o->marked, TESTBIT));
|
||||
@ -1055,7 +1055,7 @@ static int tref (lua_State *L) {
|
||||
luaL_checkany(L, 1);
|
||||
lua_pushvalue(L, 1);
|
||||
lua_pushinteger(L, luaL_ref(L, LUA_REGISTRYINDEX));
|
||||
(void)level; /* to avoid warnings */
|
||||
cast_void(level); /* to avoid warnings */
|
||||
lua_assert(lua_gettop(L) == level+1); /* +1 for result */
|
||||
return 1;
|
||||
}
|
||||
@ -1063,7 +1063,7 @@ static int tref (lua_State *L) {
|
||||
static int getref (lua_State *L) {
|
||||
int level = lua_gettop(L);
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, luaL_checkinteger(L, 1));
|
||||
(void)level; /* to avoid warnings */
|
||||
cast_void(level); /* to avoid warnings */
|
||||
lua_assert(lua_gettop(L) == level+1);
|
||||
return 1;
|
||||
}
|
||||
@ -1071,7 +1071,7 @@ static int getref (lua_State *L) {
|
||||
static int unref (lua_State *L) {
|
||||
int level = lua_gettop(L);
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, cast_int(luaL_checkinteger(L, 1)));
|
||||
(void)level; /* to avoid warnings */
|
||||
cast_void(level); /* to avoid warnings */
|
||||
lua_assert(lua_gettop(L) == level);
|
||||
return 0;
|
||||
}
|
||||
@ -1740,7 +1740,7 @@ static struct X { int x; } x;
|
||||
else if EQ("tostring") {
|
||||
const char *s = lua_tostring(L1, getindex);
|
||||
const char *s1 = lua_pushstring(L1, s);
|
||||
(void)s1; /* to avoid warnings */
|
||||
cast_void(s1); /* to avoid warnings */
|
||||
lua_longassert((s == NULL && s1 == NULL) || strcmp(s, s1) == 0);
|
||||
}
|
||||
else if EQ("Ltolstring") {
|
||||
|
Loading…
Reference in New Issue
Block a user