diff --git a/lbaselib.c b/lbaselib.c index ccc3123a..ce868ef7 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -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); } diff --git a/lmem.c b/lmem.c index 1ee7f23d..2f5cddd5 100644 --- a/lmem.c +++ b/lmem.c @@ -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 */ } diff --git a/lmem.h b/lmem.h index 710a4904..276bb32a 100644 --- a/lmem.h +++ b/lmem.h @@ -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, diff --git a/ltable.c b/ltable.c index 6ded0d93..86bfa792 100644 --- a/ltable.c +++ b/ltable.c @@ -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 */ + } } }