From: Arnaud Giersch Date: Wed, 9 Jan 2019 20:34:29 +0000 (+0100) Subject: [sonar] Misc issues in bindings/lua. X-Git-Tag: v3_22~616 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/43cd7caf1b55127976ff2615651f7d6c28ffff33 [sonar] Misc issues in bindings/lua. --- diff --git a/src/bindings/lua/lua_debug.cpp b/src/bindings/lua/lua_debug.cpp index 3693fa674b..1d7ed695e6 100644 --- a/src/bindings/lua/lua_debug.cpp +++ b/src/bindings/lua/lua_debug.cpp @@ -70,6 +70,10 @@ const char* sglua_tostring(lua_State* L, int index) { case LUA_TTHREAD: snprintf(buff, 7, "thread"); break; + + default: + snprintf(buff, 64, "unknown(%d)", lua_type(L, index)); + break; } return buff; } @@ -212,7 +216,7 @@ void* sglua_checkudata_debug(lua_State* L, int ud, const char* tname) * @param size number of bytes of data * @param userdata the memory buffer to write */ -int sglua_memory_writer(lua_State* L, const void* source, size_t size, void* userdata) +int sglua_memory_writer(lua_State* /*L*/, const void* source, size_t size, void* userdata) { sglua_buffer_t buffer = static_cast(userdata); while (buffer->capacity < buffer->size + size) { diff --git a/src/bindings/lua/lua_host.cpp b/src/bindings/lua/lua_host.cpp index 7f42752c52..f2188fdd50 100644 --- a/src/bindings/lua/lua_host.cpp +++ b/src/bindings/lua/lua_host.cpp @@ -143,8 +143,8 @@ static int l_host_get_property_value(lua_State * L) */ static int l_host_destroy(lua_State *L) { - //sg_host_t ht = sglua_check_host(L, 1); - //FIXME: not working..__MSG_host_priv_free(MSG_host_priv(ht)); + sg_host_t ht = sglua_check_host(L, 1); + ht->destroy(); return 0; } diff --git a/src/bindings/lua/lua_platf.cpp b/src/bindings/lua/lua_platf.cpp index f2c24af3f4..7e29d3600a 100644 --- a/src/bindings/lua/lua_platf.cpp +++ b/src/bindings/lua/lua_platf.cpp @@ -60,14 +60,16 @@ static simgrid::s4u::Link::SharingPolicy link_policy_get_by_name(const char* pol } } -int console_open(lua_State *L) { +int console_open(lua_State*) +{ sg_platf_init(); simgrid::s4u::on_platform_creation(); return 0; } -int console_close(lua_State *L) { +int console_close(lua_State*) +{ simgrid::s4u::on_platform_created(); sg_platf_exit(); return 0; @@ -390,16 +392,16 @@ int console_add_ASroute(lua_State *L) { lua_pushstring(L, "gw_src"); lua_gettable(L, -2); - const char *name = lua_tostring(L, -1); - ASroute.gw_src = sg_netpoint_by_name_or_null(name); - lua_ensure(ASroute.gw_src, "Attribute 'gw_src=%s' of AS route does not name a valid node", name); + const char* pname = lua_tostring(L, -1); + ASroute.gw_src = sg_netpoint_by_name_or_null(pname); + lua_ensure(ASroute.gw_src, "Attribute 'gw_src=%s' of AS route does not name a valid node", pname); lua_pop(L, 1); lua_pushstring(L, "gw_dst"); lua_gettable(L, -2); - name = lua_tostring(L, -1); - ASroute.gw_dst = sg_netpoint_by_name_or_null(name); - lua_ensure(ASroute.gw_dst, "Attribute 'gw_dst=%s' of AS route does not name a valid node", name); + pname = lua_tostring(L, -1); + ASroute.gw_dst = sg_netpoint_by_name_or_null(pname); + lua_ensure(ASroute.gw_dst, "Attribute 'gw_dst=%s' of AS route does not name a valid node", pname); lua_pop(L, 1); lua_pushstring(L,"links"); @@ -489,7 +491,9 @@ int console_AS_open(lua_State *L) { return 1; } -int console_AS_seal(lua_State *L) { + +int console_AS_seal(lua_State*) +{ XBT_DEBUG("Sealing AS"); sg_platf_new_Zone_seal(); return 0; diff --git a/src/bindings/lua/simgrid_lua.cpp b/src/bindings/lua/simgrid_lua.cpp index 093e5f5258..071111594d 100644 --- a/src/bindings/lua/simgrid_lua.cpp +++ b/src/bindings/lua/simgrid_lua.cpp @@ -9,12 +9,10 @@ #include "lua_private.hpp" #include "lua_utils.hpp" #include "src/surf/xml/platf.hpp" - +#include XBT_LOG_NEW_DEFAULT_CATEGORY(lua, "Lua Bindings"); -#include - extern "C" int luaopen_simgrid(lua_State* L); /* ********************************************************************************* */