diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-10-19 16:29:54 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-10-19 16:29:54 -0300 |
commit | 14d2803e55f0bbc2b09890a3b30afbb063ec973d (patch) | |
tree | fd99577f3745763e67e02b34cb842f2604ce5aac | |
parent | 7f12bf40c401ea465c792156be31bf4a38a7499f (diff) | |
download | lua-14d2803e55f0bbc2b09890a3b30afbb063ec973d.tar.gz lua-14d2803e55f0bbc2b09890a3b30afbb063ec973d.tar.bz2 lua-14d2803e55f0bbc2b09890a3b30afbb063ec973d.zip |
Details
Some cast operations rewritten to use respective macros.
-rw-r--r-- | ltable.c | 4 | ||||
-rw-r--r-- | ltests.c | 10 |
2 files changed, 7 insertions, 7 deletions
@@ -107,7 +107,7 @@ static const TValue absentkey = {ABSTKEYCONSTANT}; | |||
107 | */ | 107 | */ |
108 | static Node *hashint (const Table *t, lua_Integer i) { | 108 | static Node *hashint (const Table *t, lua_Integer i) { |
109 | lua_Unsigned ui = l_castS2U(i); | 109 | lua_Unsigned ui = l_castS2U(i); |
110 | if (ui <= (unsigned int)INT_MAX) | 110 | if (ui <= cast_uint(INT_MAX)) |
111 | return hashmod(t, cast_int(ui)); | 111 | return hashmod(t, cast_int(ui)); |
112 | else | 112 | else |
113 | return hashmod(t, ui); | 113 | return hashmod(t, ui); |
@@ -488,7 +488,7 @@ static void setnodevector (lua_State *L, Table *t, unsigned int size) { | |||
488 | luaG_runerror(L, "table overflow"); | 488 | luaG_runerror(L, "table overflow"); |
489 | size = twoto(lsize); | 489 | size = twoto(lsize); |
490 | t->node = luaM_newvector(L, size, Node); | 490 | t->node = luaM_newvector(L, size, Node); |
491 | for (i = 0; i < (int)size; i++) { | 491 | for (i = 0; i < cast_int(size); i++) { |
492 | Node *n = gnode(t, i); | 492 | Node *n = gnode(t, i); |
493 | gnext(n) = 0; | 493 | gnext(n) = 0; |
494 | setnilkey(n); | 494 | setnilkey(n); |
@@ -533,7 +533,7 @@ static void checkobject (global_State *g, GCObject *o, int maybedead, | |||
533 | 533 | ||
534 | static lu_mem checkgraylist (global_State *g, GCObject *o) { | 534 | static lu_mem checkgraylist (global_State *g, GCObject *o) { |
535 | int total = 0; /* count number of elements in the list */ | 535 | int total = 0; /* count number of elements in the list */ |
536 | ((void)g); /* better to keep it available if we need to print an object */ | 536 | cast_void(g); /* better to keep it if we need to print an object */ |
537 | while (o) { | 537 | while (o) { |
538 | assert(!!isgray(o) ^ (getage(o) == G_TOUCHED2)); | 538 | assert(!!isgray(o) ^ (getage(o) == G_TOUCHED2)); |
539 | assert(!testbit(o->marked, TESTBIT)); | 539 | assert(!testbit(o->marked, TESTBIT)); |
@@ -1055,7 +1055,7 @@ static int tref (lua_State *L) { | |||
1055 | luaL_checkany(L, 1); | 1055 | luaL_checkany(L, 1); |
1056 | lua_pushvalue(L, 1); | 1056 | lua_pushvalue(L, 1); |
1057 | lua_pushinteger(L, luaL_ref(L, LUA_REGISTRYINDEX)); | 1057 | lua_pushinteger(L, luaL_ref(L, LUA_REGISTRYINDEX)); |
1058 | (void)level; /* to avoid warnings */ | 1058 | cast_void(level); /* to avoid warnings */ |
1059 | lua_assert(lua_gettop(L) == level+1); /* +1 for result */ | 1059 | lua_assert(lua_gettop(L) == level+1); /* +1 for result */ |
1060 | return 1; | 1060 | return 1; |
1061 | } | 1061 | } |
@@ -1063,7 +1063,7 @@ static int tref (lua_State *L) { | |||
1063 | static int getref (lua_State *L) { | 1063 | static int getref (lua_State *L) { |
1064 | int level = lua_gettop(L); | 1064 | int level = lua_gettop(L); |
1065 | lua_rawgeti(L, LUA_REGISTRYINDEX, luaL_checkinteger(L, 1)); | 1065 | lua_rawgeti(L, LUA_REGISTRYINDEX, luaL_checkinteger(L, 1)); |
1066 | (void)level; /* to avoid warnings */ | 1066 | cast_void(level); /* to avoid warnings */ |
1067 | lua_assert(lua_gettop(L) == level+1); | 1067 | lua_assert(lua_gettop(L) == level+1); |
1068 | return 1; | 1068 | return 1; |
1069 | } | 1069 | } |
@@ -1071,7 +1071,7 @@ static int getref (lua_State *L) { | |||
1071 | static int unref (lua_State *L) { | 1071 | static int unref (lua_State *L) { |
1072 | int level = lua_gettop(L); | 1072 | int level = lua_gettop(L); |
1073 | luaL_unref(L, LUA_REGISTRYINDEX, cast_int(luaL_checkinteger(L, 1))); | 1073 | luaL_unref(L, LUA_REGISTRYINDEX, cast_int(luaL_checkinteger(L, 1))); |
1074 | (void)level; /* to avoid warnings */ | 1074 | cast_void(level); /* to avoid warnings */ |
1075 | lua_assert(lua_gettop(L) == level); | 1075 | lua_assert(lua_gettop(L) == level); |
1076 | return 0; | 1076 | return 0; |
1077 | } | 1077 | } |
@@ -1740,7 +1740,7 @@ static struct X { int x; } x; | |||
1740 | else if EQ("tostring") { | 1740 | else if EQ("tostring") { |
1741 | const char *s = lua_tostring(L1, getindex); | 1741 | const char *s = lua_tostring(L1, getindex); |
1742 | const char *s1 = lua_pushstring(L1, s); | 1742 | const char *s1 = lua_pushstring(L1, s); |
1743 | (void)s1; /* to avoid warnings */ | 1743 | cast_void(s1); /* to avoid warnings */ |
1744 | lua_longassert((s == NULL && s1 == NULL) || strcmp(s, s1) == 0); | 1744 | lua_longassert((s == NULL && s1 == NULL) || strcmp(s, s1) == 0); |
1745 | } | 1745 | } |
1746 | else if EQ("Ltolstring") { | 1746 | else if EQ("Ltolstring") { |