Help compilers/analyzers a bit with luaL_error()
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 7 Sep 2009 13:23:32 +0000 (16:23 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 7 Sep 2009 13:23:32 +0000 (16:23 +0300)
- luaL_error() never returns but as other tools dont know this it
  raises false alarms

luaext/lposix.c

index 270e246..cf609a5 100644 (file)
@@ -183,7 +183,7 @@ static int aux_files(lua_State *L)
 {
        DIR *d = lua_touserdata(L, lua_upvalueindex(1));
        struct dirent *entry;
-       if (d == NULL) luaL_error(L, "attempt to use closed dir");
+       if (d == NULL) return luaL_error(L, "attempt to use closed dir");
        entry = readdir(d);
        if (entry == NULL)
        {
@@ -319,7 +319,7 @@ static int Pexec(lua_State *L)                      /** exec(path,[args]) */
        const char *path = luaL_checkstring(L, 1);
        int i,n=lua_gettop(L);
        char **argv = malloc((n+1)*sizeof(char*));
-       if (argv==NULL) luaL_error(L,"not enough memory");
+       if (argv==NULL) return luaL_error(L,"not enough memory");
        argv[0] = (char*)path;
        for (i=1; i<n; i++) argv[i] = (char*)luaL_checkstring(L, i+1);
        argv[i] = NULL;
@@ -782,7 +782,7 @@ static int Pmkstemp(lua_State *L)
        luaL_getmetatable(L, "FILE*");
        if (lua_isnil(L, -1)) {
                lua_pop(L, 1);
-               luaL_error(L, "FILE* metatable not available "
+               return luaL_error(L, "FILE* metatable not available "
                              "(io not loaded?)");
        } else {
                lua_setmetatable(L, -3);