diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-10-25 17:01:37 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-10-25 17:01:37 -0200 |
| commit | 4590a89b32b62c75fca7ced96c282c7793b8885c (patch) | |
| tree | 99ec05f9ba4ca157cbc8736d0b923d479065bf54 | |
| parent | 1475cb59bf16c6af7ecd937e13da0ca0f451a191 (diff) | |
| download | lua-4590a89b32b62c75fca7ced96c282c7793b8885c.tar.gz lua-4590a89b32b62c75fca7ced96c282c7793b8885c.tar.bz2 lua-4590a89b32b62c75fca7ced96c282c7793b8885c.zip | |
corrected warnings from different compilers (mostly casts and small
details)
| -rw-r--r-- | lapi.c | 8 | ||||
| -rw-r--r-- | lauxlib.c | 4 | ||||
| -rw-r--r-- | ldo.c | 4 | ||||
| -rw-r--r-- | lgc.c | 4 | ||||
| -rw-r--r-- | liolib.c | 4 | ||||
| -rw-r--r-- | lstrlib.c | 6 | ||||
| -rw-r--r-- | ltablib.c | 5 | ||||
| -rw-r--r-- | lua.c | 4 | ||||
| -rw-r--r-- | lvm.c | 4 |
9 files changed, 21 insertions, 22 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 2.136 2010/09/07 19:21:39 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.137 2010/09/07 19:35:04 roberto Exp roberto $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -85,7 +85,7 @@ LUA_API int lua_checkstack (lua_State *L, int size) { | |||
| 85 | if (L->stack_last - L->top > size) /* stack large enough? */ | 85 | if (L->stack_last - L->top > size) /* stack large enough? */ |
| 86 | res = 1; /* yes; check is OK */ | 86 | res = 1; /* yes; check is OK */ |
| 87 | else { /* no; need to grow stack */ | 87 | else { /* no; need to grow stack */ |
| 88 | int inuse = L->top - L->stack + EXTRA_STACK; | 88 | int inuse = cast_int(L->top - L->stack) + EXTRA_STACK; |
| 89 | if (inuse > LUAI_MAXSTACK - size) /* can grow without overflow? */ | 89 | if (inuse > LUAI_MAXSTACK - size) /* can grow without overflow? */ |
| 90 | res = 0; /* no */ | 90 | res = 0; /* no */ |
| 91 | else /* try to grow stack */ | 91 | else /* try to grow stack */ |
| @@ -1155,13 +1155,11 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { | |||
| 1155 | 1155 | ||
| 1156 | static UpVal **getupvalref (lua_State *L, int fidx, int n, Closure **pf) { | 1156 | static UpVal **getupvalref (lua_State *L, int fidx, int n, Closure **pf) { |
| 1157 | Closure *f; | 1157 | Closure *f; |
| 1158 | Proto *p; | ||
| 1159 | StkId fi = index2addr(L, fidx); | 1158 | StkId fi = index2addr(L, fidx); |
| 1160 | api_check(L, ttisclosure(fi), "Lua function expected"); | 1159 | api_check(L, ttisclosure(fi), "Lua function expected"); |
| 1161 | f = clvalue(fi); | 1160 | f = clvalue(fi); |
| 1162 | api_check(L, !f->c.isC, "Lua function expected"); | 1161 | api_check(L, !f->c.isC, "Lua function expected"); |
| 1163 | p = f->l.p; | 1162 | api_check(L, (1 <= n && n <= f->l.p->sizeupvalues), "invalid upvalue index"); |
| 1164 | api_check(L, (1 <= n && n <= p->sizeupvalues), "invalid upvalue index"); | ||
| 1165 | if (pf) *pf = f; | 1163 | if (pf) *pf = f; |
| 1166 | return &f->l.upvals[n - 1]; /* get its upvalue pointer */ | 1164 | return &f->l.upvals[n - 1]; /* get its upvalue pointer */ |
| 1167 | } | 1165 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.220 2010/08/03 20:21:16 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.221 2010/10/01 18:53:00 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -641,7 +641,7 @@ LUALIB_API int luaL_len (lua_State *L, int idx) { | |||
| 641 | int l; | 641 | int l; |
| 642 | int isnum; | 642 | int isnum; |
| 643 | lua_len(L, idx); | 643 | lua_len(L, idx); |
| 644 | l = lua_tointegerx(L, -1, &isnum); | 644 | l = (int)lua_tointegerx(L, -1, &isnum); |
| 645 | if (!isnum) | 645 | if (!isnum) |
| 646 | luaL_error(L, "object length is not a number"); | 646 | luaL_error(L, "object length is not a number"); |
| 647 | lua_pop(L, 1); /* remove object */ | 647 | lua_pop(L, 1); /* remove object */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 2.88 2010/06/04 13:06:15 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.89 2010/09/30 17:21:31 roberto Exp roberto $ |
| 3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -177,7 +177,7 @@ void luaD_growstack (lua_State *L, int n) { | |||
| 177 | if (size > LUAI_MAXSTACK) /* error after extra size? */ | 177 | if (size > LUAI_MAXSTACK) /* error after extra size? */ |
| 178 | luaD_throw(L, LUA_ERRERR); | 178 | luaD_throw(L, LUA_ERRERR); |
| 179 | else { | 179 | else { |
| 180 | int needed = L->top - L->stack + n + EXTRA_STACK; | 180 | int needed = cast_int(L->top - L->stack) + n + EXTRA_STACK; |
| 181 | int newsize = 2 * size; | 181 | int newsize = 2 * size; |
| 182 | if (newsize > LUAI_MAXSTACK) newsize = LUAI_MAXSTACK; | 182 | if (newsize > LUAI_MAXSTACK) newsize = LUAI_MAXSTACK; |
| 183 | if (newsize < needed) newsize = needed; | 183 | if (newsize < needed) newsize = needed; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.c,v 2.101 2010/06/30 14:11:17 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.102 2010/09/03 14:14:01 roberto Exp roberto $ |
| 3 | ** Garbage Collector | 3 | ** Garbage Collector |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -449,7 +449,7 @@ static int traverseproto (global_State *g, Proto *f) { | |||
| 449 | } | 449 | } |
| 450 | 450 | ||
| 451 | 451 | ||
| 452 | static l_mem traverseclosure (global_State *g, Closure *cl) { | 452 | static int traverseclosure (global_State *g, Closure *cl) { |
| 453 | if (cl->c.isC) { | 453 | if (cl->c.isC) { |
| 454 | int i; | 454 | int i; |
| 455 | for (i=0; i<cl->c.nupvalues; i++) /* mark its upvalues */ | 455 | for (i=0; i<cl->c.nupvalues; i++) /* mark its upvalues */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: liolib.c,v 2.90 2010/07/25 15:18:19 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.91 2010/07/28 15:51:59 roberto Exp roberto $ |
| 3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -453,7 +453,7 @@ static int f_read (lua_State *L) { | |||
| 453 | static int io_readline (lua_State *L) { | 453 | static int io_readline (lua_State *L) { |
| 454 | FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); | 454 | FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); |
| 455 | int i; | 455 | int i; |
| 456 | int n = lua_tointeger(L, lua_upvalueindex(2)); | 456 | int n = (int)lua_tointeger(L, lua_upvalueindex(2)); |
| 457 | if (f == NULL) /* file is already closed? */ | 457 | if (f == NULL) /* file is already closed? */ |
| 458 | luaL_error(L, "file is already closed"); | 458 | luaL_error(L, "file is already closed"); |
| 459 | lua_settop(L , 1); | 459 | lua_settop(L , 1); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstrlib.c,v 1.153 2010/05/24 19:34:57 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.154 2010/07/02 11:38:13 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 | */ |
| @@ -758,9 +758,9 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { | |||
| 758 | else if (*s == '\0' || iscntrl(uchar(*s))) { | 758 | else if (*s == '\0' || iscntrl(uchar(*s))) { |
| 759 | char buff[10]; | 759 | char buff[10]; |
| 760 | if (!isdigit(uchar(*(s+1)))) | 760 | if (!isdigit(uchar(*(s+1)))) |
| 761 | sprintf(buff, "\\%d", uchar(*s)); | 761 | sprintf(buff, "\\%d", (int)uchar(*s)); |
| 762 | else | 762 | else |
| 763 | sprintf(buff, "\\%03d", uchar(*s)); | 763 | sprintf(buff, "\\%03d", (int)uchar(*s)); |
| 764 | luaL_addstring(b, buff); | 764 | luaL_addstring(b, buff); |
| 765 | } | 765 | } |
| 766 | else | 766 | else |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltablib.c,v 1.55 2010/03/13 03:57:46 roberto Exp roberto $ | 2 | ** $Id: ltablib.c,v 1.56 2010/07/02 11:38:13 roberto Exp roberto $ |
| 3 | ** Library for Table Manipulation | 3 | ** Library for Table Manipulation |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -16,7 +16,8 @@ | |||
| 16 | #include "lualib.h" | 16 | #include "lualib.h" |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | #define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), lua_rawlen(L, n)) | 19 | #define aux_getn(L,n) \ |
| 20 | (luaL_checktype(L, n, LUA_TTABLE), (int)lua_rawlen(L, n)) | ||
| 20 | 21 | ||
| 21 | 22 | ||
| 22 | static int foreachi (lua_State *L) { | 23 | static int foreachi (lua_State *L) { |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.c,v 1.192 2010/07/25 15:03:37 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.193 2010/10/18 16:06:33 roberto Exp roberto $ |
| 3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -428,7 +428,7 @@ static int handle_luainit (lua_State *L) { | |||
| 428 | 428 | ||
| 429 | 429 | ||
| 430 | static int pmain (lua_State *L) { | 430 | static int pmain (lua_State *L) { |
| 431 | int argc = lua_tointeger(L, 1); | 431 | int argc = (int)lua_tointeger(L, 1); |
| 432 | char **argv = (char **)lua_touserdata(L, 2); | 432 | char **argv = (char **)lua_touserdata(L, 2); |
| 433 | int script; | 433 | int script; |
| 434 | int has_i = 0, has_v = 0, has_e = 0; | 434 | int has_i = 0, has_v = 0, has_e = 0; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.122 2010/06/07 16:55:34 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.123 2010/06/30 14:11:17 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -421,7 +421,7 @@ void luaV_finishOp (lua_State *L) { | |||
| 421 | case OP_CONCAT: { | 421 | case OP_CONCAT: { |
| 422 | StkId top = L->top - 1; /* top when 'call_binTM' was called */ | 422 | StkId top = L->top - 1; /* top when 'call_binTM' was called */ |
| 423 | int b = GETARG_B(inst); /* first element to concatenate */ | 423 | int b = GETARG_B(inst); /* first element to concatenate */ |
| 424 | int total = top - 1 - (base + b); /* elements yet to concatenate */ | 424 | int total = cast_int(top - 1 - (base + b)); /* yet to concatenate */ |
| 425 | setobj2s(L, top - 2, top); /* put TM result in proper position */ | 425 | setobj2s(L, top - 2, top); /* put TM result in proper position */ |
| 426 | if (total > 1) { /* are there elements to concat? */ | 426 | if (total > 1) { /* are there elements to concat? */ |
| 427 | L->top = top - 1; /* top is one after last element (at top-2) */ | 427 | L->top = top - 1; /* top is one after last element (at top-2) */ |
