corrected warnings from different compilers (mostly casts and small

details)
This commit is contained in:
Roberto Ierusalimschy 2010-10-25 17:01:37 -02:00
parent 1475cb59bf
commit 4590a89b32
9 changed files with 21 additions and 22 deletions

8
lapi.c
View file

@ -1,5 +1,5 @@
/*
** $Id: lapi.c,v 2.136 2010/09/07 19:21:39 roberto Exp roberto $
** $Id: lapi.c,v 2.137 2010/09/07 19:35:04 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@ -85,7 +85,7 @@ LUA_API int lua_checkstack (lua_State *L, int size) {
if (L->stack_last - L->top > size) /* stack large enough? */
res = 1; /* yes; check is OK */
else { /* no; need to grow stack */
int inuse = L->top - L->stack + EXTRA_STACK;
int inuse = cast_int(L->top - L->stack) + EXTRA_STACK;
if (inuse > LUAI_MAXSTACK - size) /* can grow without overflow? */
res = 0; /* no */
else /* try to grow stack */
@ -1155,13 +1155,11 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
static UpVal **getupvalref (lua_State *L, int fidx, int n, Closure **pf) {
Closure *f;
Proto *p;
StkId fi = index2addr(L, fidx);
api_check(L, ttisclosure(fi), "Lua function expected");
f = clvalue(fi);
api_check(L, !f->c.isC, "Lua function expected");
p = f->l.p;
api_check(L, (1 <= n && n <= p->sizeupvalues), "invalid upvalue index");
api_check(L, (1 <= n && n <= f->l.p->sizeupvalues), "invalid upvalue index");
if (pf) *pf = f;
return &f->l.upvals[n - 1]; /* get its upvalue pointer */
}

View file

@ -1,5 +1,5 @@
/*
** $Id: lauxlib.c,v 1.220 2010/08/03 20:21:16 roberto Exp roberto $
** $Id: lauxlib.c,v 1.221 2010/10/01 18:53:00 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@ -641,7 +641,7 @@ LUALIB_API int luaL_len (lua_State *L, int idx) {
int l;
int isnum;
lua_len(L, idx);
l = lua_tointegerx(L, -1, &isnum);
l = (int)lua_tointegerx(L, -1, &isnum);
if (!isnum)
luaL_error(L, "object length is not a number");
lua_pop(L, 1); /* remove object */

4
ldo.c
View file

@ -1,5 +1,5 @@
/*
** $Id: ldo.c,v 2.88 2010/06/04 13:06:15 roberto Exp roberto $
** $Id: ldo.c,v 2.89 2010/09/30 17:21:31 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@ -177,7 +177,7 @@ void luaD_growstack (lua_State *L, int n) {
if (size > LUAI_MAXSTACK) /* error after extra size? */
luaD_throw(L, LUA_ERRERR);
else {
int needed = L->top - L->stack + n + EXTRA_STACK;
int needed = cast_int(L->top - L->stack) + n + EXTRA_STACK;
int newsize = 2 * size;
if (newsize > LUAI_MAXSTACK) newsize = LUAI_MAXSTACK;
if (newsize < needed) newsize = needed;

4
lgc.c
View file

@ -1,5 +1,5 @@
/*
** $Id: lgc.c,v 2.101 2010/06/30 14:11:17 roberto Exp roberto $
** $Id: lgc.c,v 2.102 2010/09/03 14:14:01 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@ -449,7 +449,7 @@ static int traverseproto (global_State *g, Proto *f) {
}
static l_mem traverseclosure (global_State *g, Closure *cl) {
static int traverseclosure (global_State *g, Closure *cl) {
if (cl->c.isC) {
int i;
for (i=0; i<cl->c.nupvalues; i++) /* mark its upvalues */

View file

@ -1,5 +1,5 @@
/*
** $Id: liolib.c,v 2.90 2010/07/25 15:18:19 roberto Exp roberto $
** $Id: liolib.c,v 2.91 2010/07/28 15:51:59 roberto Exp roberto $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@ -453,7 +453,7 @@ static int f_read (lua_State *L) {
static int io_readline (lua_State *L) {
FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1));
int i;
int n = lua_tointeger(L, lua_upvalueindex(2));
int n = (int)lua_tointeger(L, lua_upvalueindex(2));
if (f == NULL) /* file is already closed? */
luaL_error(L, "file is already closed");
lua_settop(L , 1);

View file

@ -1,5 +1,5 @@
/*
** $Id: lstrlib.c,v 1.153 2010/05/24 19:34:57 roberto Exp roberto $
** $Id: lstrlib.c,v 1.154 2010/07/02 11:38:13 roberto Exp roberto $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
@ -758,9 +758,9 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
else if (*s == '\0' || iscntrl(uchar(*s))) {
char buff[10];
if (!isdigit(uchar(*(s+1))))
sprintf(buff, "\\%d", uchar(*s));
sprintf(buff, "\\%d", (int)uchar(*s));
else
sprintf(buff, "\\%03d", uchar(*s));
sprintf(buff, "\\%03d", (int)uchar(*s));
luaL_addstring(b, buff);
}
else

View file

@ -1,5 +1,5 @@
/*
** $Id: ltablib.c,v 1.55 2010/03/13 03:57:46 roberto Exp roberto $
** $Id: ltablib.c,v 1.56 2010/07/02 11:38:13 roberto Exp roberto $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/
@ -16,7 +16,8 @@
#include "lualib.h"
#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), lua_rawlen(L, n))
#define aux_getn(L,n) \
(luaL_checktype(L, n, LUA_TTABLE), (int)lua_rawlen(L, n))
static int foreachi (lua_State *L) {

4
lua.c
View file

@ -1,5 +1,5 @@
/*
** $Id: lua.c,v 1.192 2010/07/25 15:03:37 roberto Exp roberto $
** $Id: lua.c,v 1.193 2010/10/18 16:06:33 roberto Exp roberto $
** Lua stand-alone interpreter
** See Copyright Notice in lua.h
*/
@ -428,7 +428,7 @@ static int handle_luainit (lua_State *L) {
static int pmain (lua_State *L) {
int argc = lua_tointeger(L, 1);
int argc = (int)lua_tointeger(L, 1);
char **argv = (char **)lua_touserdata(L, 2);
int script;
int has_i = 0, has_v = 0, has_e = 0;

4
lvm.c
View file

@ -1,5 +1,5 @@
/*
** $Id: lvm.c,v 2.122 2010/06/07 16:55:34 roberto Exp roberto $
** $Id: lvm.c,v 2.123 2010/06/30 14:11:17 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@ -421,7 +421,7 @@ void luaV_finishOp (lua_State *L) {
case OP_CONCAT: {
StkId top = L->top - 1; /* top when 'call_binTM' was called */
int b = GETARG_B(inst); /* first element to concatenate */
int total = top - 1 - (base + b); /* elements yet to concatenate */
int total = cast_int(top - 1 - (base + b)); /* yet to concatenate */
setobj2s(L, top - 2, top); /* put TM result in proper position */
if (total > 1) { /* are there elements to concat? */
L->top = top - 1; /* top is one after last element (at top-2) */