avoid warning about -unsigned value

This commit is contained in:
Roberto Ierusalimschy
2011-06-16 11:14:31 -03:00
parent cf0562e1e7
commit 817f8674af
2 changed files with 4 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: ltable.c,v 2.58 2011/06/02 19:31:40 roberto Exp roberto $
** $Id: ltable.c,v 2.59 2011/06/09 18:23:27 roberto Exp roberto $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
@@ -88,7 +88,7 @@ static Node *hashnum (const Table *t, lua_Number n) {
int i;
luai_hashnum(i, n);
if (i < 0) {
if ((unsigned int)i == -(unsigned int)i)
if (cast(unsigned int, i) == 0u - i) /* use unsigned to avoid overflows */
i = 0; /* handle INT_MIN */
i = -i; /* must be a positive value */
}