diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-06-16 11:14:31 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-06-16 11:14:31 -0300 |
commit | 817f8674af64a82c6f9c8b855446800a5642764e (patch) | |
tree | ea1a171b0f0ccdc693d5fba0869044a14eb6f344 | |
parent | cf0562e1e720581f1b5c05dc9cc55a0857c94639 (diff) | |
download | lua-817f8674af64a82c6f9c8b855446800a5642764e.tar.gz lua-817f8674af64a82c6f9c8b855446800a5642764e.tar.bz2 lua-817f8674af64a82c6f9c8b855446800a5642764e.zip |
avoid warning about -unsigned value
-rw-r--r-- | lstrlib.c | 4 | ||||
-rw-r--r-- | ltable.c | 4 |
2 files changed, 4 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.167 2011/05/03 16:01:57 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.168 2011/06/09 18:22:47 roberto Exp roberto $ |
3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -45,7 +45,7 @@ static int str_len (lua_State *L) { | |||
45 | /* translate a relative string position: negative means back from end */ | 45 | /* translate a relative string position: negative means back from end */ |
46 | static size_t posrelat (ptrdiff_t pos, size_t len) { | 46 | static size_t posrelat (ptrdiff_t pos, size_t len) { |
47 | if (pos >= 0) return (size_t)pos; | 47 | if (pos >= 0) return (size_t)pos; |
48 | else if (-(size_t)pos > len) return 0; | 48 | else if (0u - (size_t)pos > len) return 0; |
49 | else return len - ((size_t)-pos) + 1; | 49 | else return len - ((size_t)-pos) + 1; |
50 | } | 50 | } |
51 | 51 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 2.58 2011/06/02 19:31:40 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.59 2011/06/09 18:23:27 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -88,7 +88,7 @@ static Node *hashnum (const Table *t, lua_Number n) { | |||
88 | int i; | 88 | int i; |
89 | luai_hashnum(i, n); | 89 | luai_hashnum(i, n); |
90 | if (i < 0) { | 90 | if (i < 0) { |
91 | if ((unsigned int)i == -(unsigned int)i) | 91 | if (cast(unsigned int, i) == 0u - i) /* use unsigned to avoid overflows */ |
92 | i = 0; /* handle INT_MIN */ | 92 | i = 0; /* handle INT_MIN */ |
93 | i = -i; /* must be a positive value */ | 93 | i = -i; /* must be a positive value */ |
94 | } | 94 | } |