avoid 'return' "to avoid warnings"

This commit is contained in:
Roberto Ierusalimschy 2011-11-30 10:42:49 -02:00
parent 0f388193b3
commit e21b26a964
4 changed files with 14 additions and 19 deletions

View File

@ -1,5 +1,5 @@
/*
** $Id: lbaselib.c,v 1.270 2011/11/23 17:29:04 roberto Exp roberto $
** $Id: lbaselib.c,v 1.271 2011/11/29 15:55:08 roberto Exp roberto $
** Basic library
** See Copyright Notice in lua.h
*/
@ -297,14 +297,10 @@ static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
*size = 0;
return NULL;
}
else if ((s = lua_tostring(L, -1)) != NULL) {
lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */
return lua_tolstring(L, RESERVEDSLOT, size);
}
else {
else if ((s = lua_tostring(L, -1)) == NULL)
luaL_error(L, "reader function must return a string");
return NULL; /* to avoid warnings */
}
lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */
return lua_tolstring(L, RESERVEDSLOT, size);
}

5
lmem.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lmem.c,v 1.81 2010/12/20 19:40:07 roberto Exp roberto $
** $Id: lmem.c,v 1.82 2011/09/20 19:25:23 roberto Exp roberto $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
@ -63,9 +63,8 @@ void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
}
void *luaM_toobig (lua_State *L) {
l_noret luaM_toobig (lua_State *L) {
luaG_runerror(L, "memory allocation error: block too big");
return NULL; /* to avoid warnings */
}

6
lmem.h
View File

@ -1,5 +1,5 @@
/*
** $Id: lmem.h,v 1.35 2009/12/16 16:42:58 roberto Exp roberto $
** $Id: lmem.h,v 1.36 2010/04/08 17:16:46 roberto Exp roberto $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
@ -17,7 +17,7 @@
#define luaM_reallocv(L,b,on,n,e) \
((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \
luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \
luaM_toobig(L))
(luaM_toobig(L), NULL))
#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
@ -37,7 +37,7 @@
#define luaM_reallocvector(L, v,oldn,n,t) \
((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
LUAI_FUNC void *luaM_toobig (lua_State *L);
LUAI_FUNC l_noret luaM_toobig (lua_State *L);
/* not to be called directly */
LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,

View File

@ -1,5 +1,5 @@
/*
** $Id: ltable.c,v 2.65 2011/09/30 12:45:27 roberto Exp roberto $
** $Id: ltable.c,v 2.66 2011/11/28 17:25:48 roberto Exp roberto $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
@ -141,7 +141,7 @@ static int findindex (lua_State *L, Table *t, StkId key) {
return i-1; /* yes; that's the index (corrected to C) */
else {
Node *n = mainposition(t, key);
do { /* check whether `key' is somewhere in the chain */
for (;;) { /* check whether `key' is somewhere in the chain */
/* key may be dead already, but it is ok to use it in `next' */
if (luaV_rawequalobj(gkey(n), key) ||
(ttisdeadkey(gkey(n)) && iscollectable(key) &&
@ -151,9 +151,9 @@ static int findindex (lua_State *L, Table *t, StkId key) {
return i + t->sizearray;
}
else n = gnext(n);
} while (n);
luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */
return 0; /* to avoid warnings */
if (n == NULL)
luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */
}
}
}