mirror of https://github.com/rusefi/lua.git
avoid warning about -unsigned value
This commit is contained in:
parent
cf0562e1e7
commit
817f8674af
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lstrlib.c,v 1.167 2011/05/03 16:01:57 roberto Exp roberto $
|
** $Id: lstrlib.c,v 1.168 2011/06/09 18:22:47 roberto Exp roberto $
|
||||||
** Standard library for string operations and pattern-matching
|
** Standard library for string operations and pattern-matching
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -45,7 +45,7 @@ static int str_len (lua_State *L) {
|
||||||
/* translate a relative string position: negative means back from end */
|
/* translate a relative string position: negative means back from end */
|
||||||
static size_t posrelat (ptrdiff_t pos, size_t len) {
|
static size_t posrelat (ptrdiff_t pos, size_t len) {
|
||||||
if (pos >= 0) return (size_t)pos;
|
if (pos >= 0) return (size_t)pos;
|
||||||
else if (-(size_t)pos > len) return 0;
|
else if (0u - (size_t)pos > len) return 0;
|
||||||
else return len - ((size_t)-pos) + 1;
|
else return len - ((size_t)-pos) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
ltable.c
4
ltable.c
|
@ -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)
|
** Lua tables (hash)
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -88,7 +88,7 @@ static Node *hashnum (const Table *t, lua_Number n) {
|
||||||
int i;
|
int i;
|
||||||
luai_hashnum(i, n);
|
luai_hashnum(i, n);
|
||||||
if (i < 0) {
|
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 = 0; /* handle INT_MIN */
|
||||||
i = -i; /* must be a positive value */
|
i = -i; /* must be a positive value */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue