summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-10-19 16:29:54 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-10-19 16:29:54 -0300
commit14d2803e55f0bbc2b09890a3b30afbb063ec973d (patch)
treefd99577f3745763e67e02b34cb842f2604ce5aac
parent7f12bf40c401ea465c792156be31bf4a38a7499f (diff)
downloadlua-github-14d2803e55f0bbc2b09890a3b30afbb063ec973d.tar.gz
Details
Some cast operations rewritten to use respective macros.
-rw-r--r--ltable.c4
-rw-r--r--ltests.c10
2 files changed, 7 insertions, 7 deletions
diff --git a/ltable.c b/ltable.c
index 1b1cd241..d03e7486 100644
--- a/ltable.c
+++ b/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);
diff --git a/ltests.c b/ltests.c
index 97834e38..9a887f98 100644
--- a/ltests.c
+++ b/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") {