diff options
Diffstat (limited to 'lib/frrscript.c')
| -rw-r--r-- | lib/frrscript.c | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/lib/frrscript.c b/lib/frrscript.c index d00b84ccbb..0e0d3c030c 100644 --- a/lib/frrscript.c +++ b/lib/frrscript.c @@ -281,48 +281,23 @@ int frrscript_load(struct frrscript *fs, const char *function_name, scriptdir, fs->name); goto fail; } - int ret = luaL_dofile(L, script_name); - switch (ret) { - case LUA_OK: - break; - case LUA_ERRSYNTAX: - zlog_err( - "frrscript: failed loading script '%s.lua': syntax error: %s", - script_name, lua_tostring(L, -1)); - break; - case LUA_ERRMEM: - zlog_err( - "frrscript: failed loading script '%s.lua': out-of-memory error: %s", - script_name, lua_tostring(L, -1)); - break; - case LUA_ERRGCMM: - zlog_err( - "frrscript: failed loading script '%s.lua': garbage collector error: %s", - script_name, lua_tostring(L, -1)); - break; - case LUA_ERRFILE: - zlog_err( - "frrscript: failed loading script '%s.lua': file read error: %s", - script_name, lua_tostring(L, -1)); - break; - default: - zlog_err( - "frrscript: failed loading script '%s.lua': unknown error: %s", - script_name, lua_tostring(L, -1)); - break; - } - - if (ret != LUA_OK) + if (luaL_dofile(L, script_name) != 0) { + zlog_err("frrscript: failed loading script '%s.lua': error: %s", + script_name, lua_tostring(L, -1)); goto fail; + } - /* Push the Lua function we want */ + /* To check the Lua function, we get it from the global table */ lua_getglobal(L, function_name); if (lua_isfunction(L, lua_gettop(L)) == 0) { zlog_err("frrscript: loaded script '%s.lua' but %s not found", script_name, function_name); goto fail; } + /* Then pop the function (frrscript_call will push it when it needs it) + */ + lua_pop(L, 1); if (load_cb && (*load_cb)(fs) != 0) { zlog_err( |
