Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Misc issues in bindings/lua.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 9 Jan 2019 20:34:29 +0000 (21:34 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 10 Jan 2019 11:14:43 +0000 (12:14 +0100)
src/bindings/lua/lua_debug.cpp
src/bindings/lua/lua_host.cpp
src/bindings/lua/lua_platf.cpp
src/bindings/lua/simgrid_lua.cpp

index 3693fa6..1d7ed69 100644 (file)
@@ -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<sglua_buffer_t>(userdata);
   while (buffer->capacity < buffer->size + size) {
index 7f42752..f2188fd 100644 (file)
@@ -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;
 }
 
index f2c24af..7e29d36 100644 (file)
@@ -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;
index 093e5f5..0711115 100644 (file)
@@ -9,12 +9,10 @@
 #include "lua_private.hpp"
 #include "lua_utils.hpp"
 #include "src/surf/xml/platf.hpp"
-
+#include <lauxlib.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(lua, "Lua Bindings");
 
-#include <lauxlib.h>
-
 extern "C" int luaopen_simgrid(lua_State* L);
 
 /* ********************************************************************************* */