lua: remove pointless double check of autoload flag
[project/uci.git] / lua / uci.c
index 8ace746eabf0dc22f751154e2b08b634b47b8d66..47d59c883ab9320b39304fdd46297576c3550fa1 100644 (file)
--- a/lua/uci.c
+++ b/lua/uci.c
@@ -113,11 +113,8 @@ find_package(lua_State *L, struct uci_context *ctx, const char *str, bool al)
                goto done;
        }
 
-       if (al == true)
+       if (al)
                uci_load(ctx, name, &p);
-       else if (al) {
-               uci_load(ctx, name, &p);
-       }
 
 done:
        if (name != str)
@@ -303,7 +300,7 @@ uci_lua_foreach(lua_State *L)
        ctx = find_context(L, &offset);
        package = luaL_checkstring(L, 1 + offset);
 
-       if (lua_isnil(L, 2))
+       if (lua_isnil(L, 2 + offset))
                type = NULL;
        else
                type = luaL_checkstring(L, 2 + offset);
@@ -994,8 +991,9 @@ luaopen_uci(lua_State *L)
 
        /* create module */
        lua_newtable(L);
+       lua_pushvalue(L, -1);
        luaL_setfuncs(L, uci, 0);
        lua_setglobal(L, MODNAME);
 
-       return 0;
+       return 1;
 }