From: Victor Julien Date: Sun, 6 Feb 2022 12:56:35 +0000 (+0100) Subject: output/lua: minor cleanups X-Git-Tag: suricata-7.0.0-beta1~925 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39b1f1aca60c876c30e9941a608f2735e0dbcb0f;p=thirdparty%2Fsuricata.git output/lua: minor cleanups --- diff --git a/src/output-lua.c b/src/output-lua.c index 2fd4727165..09bafc5ac3 100644 --- a/src/output-lua.c +++ b/src/output-lua.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2020 Open Information Security Foundation +/* Copyright (C) 2014-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -435,31 +435,16 @@ typedef struct LogLuaScriptOptions_ { * \retval errcode 0 ok, -1 error */ static int LuaScriptInit(const char *filename, LogLuaScriptOptions *options) { - int status; - lua_State *luastate = LuaGetState(); if (luastate == NULL) goto error; luaL_openlibs(luastate); - /* hackish, needed to allow unittests to pass buffers as scripts instead of files */ -#if 0//def UNITTESTS - if (ut_script != NULL) { - status = luaL_loadbuffer(luastate, ut_script, strlen(ut_script), "unittest"); - if (status) { - SCLogError(SC_ERR_LUA_ERROR, "couldn't load file: %s", lua_tostring(luastate, -1)); - goto error; - } - } else { -#endif - status = luaL_loadfile(luastate, filename); - if (status) { - SCLogError(SC_ERR_LUA_ERROR, "couldn't load file: %s", lua_tostring(luastate, -1)); - goto error; - } -#if 0//def UNITTESTS + int status = luaL_loadfile(luastate, filename); + if (status) { + SCLogError(SC_ERR_LUA_ERROR, "couldn't load file: %s", lua_tostring(luastate, -1)); + goto error; } -#endif /* prime the script (or something) */ if (lua_pcall(luastate, 0, 0, 0) != 0) { @@ -587,25 +572,11 @@ static lua_State *LuaScriptSetup(const char *filename) luaL_openlibs(luastate); - int status; - /* hackish, needed to allow unittests to pass buffers as scripts instead of files */ -#if 0//def UNITTESTS - if (ut_script != NULL) { - status = luaL_loadbuffer(t->luastate, ut_script, strlen(ut_script), "unittest"); - if (status) { - SCLogError(SC_ERR_LUA_ERROR, "couldn't load file: %s", lua_tostring(t->luastate, -1)); - goto error; - } - } else { -#endif - status = luaL_loadfile(luastate, filename); - if (status) { - SCLogError(SC_ERR_LUA_ERROR, "couldn't load file: %s", lua_tostring(luastate, -1)); - goto error; - } -#if 0//def UNITTESTS + int status = luaL_loadfile(luastate, filename); + if (status) { + SCLogError(SC_ERR_LUA_ERROR, "couldn't load file: %s", lua_tostring(luastate, -1)); + goto error; } -#endif /* prime the script */ if (lua_pcall(luastate, 0, 0, 0) != 0) { @@ -942,10 +913,10 @@ void LuaLogRegister(void) { OutputRegisterModule(MODULE_NAME, "lua", OutputLuaLogInit); } -#else +#else /* HAVE_LUA */ void LuaLogRegister (void) { /* no-op */ } -#endif +#endif /* HAVE_LUA */