Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Needless XBT_ATTRIB_UNUSED.
[simgrid.git] / src / surf / xml / surfxml_sax_cb.cpp
index d46e18a..355cba0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -34,15 +34,15 @@ std::vector<simgrid::kernel::resource::DiskImpl*> parsed_disk_list; /* temporary
 /*
  * Helping functions
  */
-void surf_parse_assert(bool cond, std::string&& msg)
+void surf_parse_assert(bool cond, const std::string& msg)
 {
   if (not cond)
-    surf_parse_error(std::move(msg));
+    surf_parse_error(msg);
 }
 
-void surf_parse_error(std::string&& msg)
+void surf_parse_error(const std::string& msg)
 {
-  throw simgrid::ParseError(surf_parse_lineno, surf_parsed_filename, std::move(msg));
+  throw simgrid::ParseError(surf_parsed_filename, surf_parse_lineno, msg);
 }
 
 void surf_parse_assert_netpoint(const std::string& hostname, const std::string& pre, const std::string& post)
@@ -55,7 +55,7 @@ void surf_parse_assert_netpoint(const std::string& hostname, const std::string&
   std::vector<simgrid::kernel::routing::NetPoint*> netpoints =
       simgrid::s4u::Engine::get_instance()->get_all_netpoints();
   std::sort(netpoints.begin(), netpoints.end(),
-            [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
+            [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) {
               return a->get_name() < b->get_name();
             });
   bool first = true;
@@ -247,7 +247,6 @@ double surf_parse_get_speed(const char* string, const char* entity_kind, const s
 
 static std::vector<double> surf_parse_get_all_speeds(char* speeds, const char* entity_kind, const std::string& id)
 {
-
   std::vector<double> speed_per_pstate;
 
   if (strchr(speeds, ',') == nullptr){
@@ -351,9 +350,9 @@ void ETag_surfxml_include()
 
 /* Stag and Etag parse functions */
 void STag_surfxml_platform() {
-  XBT_ATTRIB_UNUSED double version = surf_parse_get_double(A_surfxml_platform_version);
+  double version = surf_parse_get_double(A_surfxml_platform_version);
 
-  xbt_assert((version >= 1.0), "******* BIG FAT WARNING *********\n "
+  surf_parse_assert((version >= 1.0), "******* BIG FAT WARNING *********\n "
       "You're using an ancient XML file.\n"
       "Since SimGrid 3.1, units are Bytes, Flops, and seconds "
       "instead of MBytes, MFlops and seconds.\n"
@@ -367,13 +366,13 @@ void STag_surfxml_platform() {
 
       "Last, do not forget to also update your values for "
       "the calls to MSG_task_create (if any).");
-  xbt_assert((version >= 3.0), "******* BIG FAT WARNING *********\n "
+  surf_parse_assert((version >= 3.0), "******* BIG FAT WARNING *********\n "
       "You're using an old XML file.\n"
       "Use simgrid_update_xml to update your file automatically. "
       "This program is installed automatically with SimGrid, or "
       "available in the tools/ directory of the source archive.");
-  xbt_assert((version >= 4.0),
-             "******* FILE %s IS TOO OLD (v:%.1f) *********\n "
+  surf_parse_assert((version >= 4.0),
+             std::string("******* THIS FILE IS TOO OLD (v:")+std::to_string(version)+") *********\n "
              "Changes introduced in SimGrid 3.13:\n"
              "  - 'power' attribute of hosts (and others) got renamed to 'speed'.\n"
              "  - In <trace_connect>, attribute kind=\"POWER\" is now kind=\"SPEED\".\n"
@@ -382,8 +381,7 @@ void STag_surfxml_platform() {
              "\n\n"
              "Use simgrid_update_xml to update your file automatically. "
              "This program is installed automatically with SimGrid, or "
-             "available in the tools/ directory of the source archive.",
-             surf_parsed_filename.c_str(), version);
+             "available in the tools/ directory of the source archive.");
   if (version < 4.1) {
     XBT_INFO("You're using a v%.1f XML file (%s) while the current standard is v4.1 "
              "That's fine, the new version is backward compatible. \n\n"
@@ -392,11 +390,10 @@ void STag_surfxml_platform() {
              "available in the tools/ directory of the source archive.",
              version, surf_parsed_filename.c_str());
   }
-  xbt_assert(version <= 4.1,
-             "******* FILE %s COMES FROM THE FUTURE (v:%.1f) *********\n "
+  surf_parse_assert(version <= 4.1,
+             std::string("******* THIS FILE COMES FROM THE FUTURE (v:")+std::to_string(version)+") *********\n "
              "The most recent formalism that this version of SimGrid understands is v4.1.\n"
-             "Please update your code, or use another, more adapted, file.",
-             surf_parsed_filename.c_str(), version);
+             "Please update your code, or use another, more adapted, file.");
 }
 void ETag_surfxml_platform(){
   simgrid::s4u::Engine::on_platform_created();
@@ -954,10 +951,10 @@ void ETag_surfxml_actor()
   switch (A_surfxml_actor_on___failure) {
   case AU_surfxml_actor_on___failure:
   case A_surfxml_actor_on___failure_DIE:
-    actor.on_failure = simgrid::kernel::routing::ActorOnFailure::DIE;
+    actor.restart_on_failure = false;
     break;
   case A_surfxml_actor_on___failure_RESTART:
-    actor.on_failure = simgrid::kernel::routing::ActorOnFailure::RESTART;
+    actor.restart_on_failure = true;
     break;
   default:
     surf_parse_error("Invalid on failure behavior");
@@ -1003,10 +1000,9 @@ void surf_parse_open(const std::string& file)
   surf_path.push_back(dir);
 
   surf_file_to_parse = surf_fopen(file, "r");
-  if (surf_file_to_parse == nullptr) {
-    std::string cwd = simgrid::xbt::Path().get_name();
-    xbt_die("Unable to open '%s' from '%s'\n", file.c_str(), cwd.c_str());
-  }
+  if (surf_file_to_parse == nullptr)
+    throw std::invalid_argument(std::string("Unable to open ')") + file + "' from '" + simgrid::xbt::Path().get_name() +
+                                "'. Does this file exist?");
   surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
   surf_parse__switch_to_buffer(surf_input_buffer);
   surf_parse_lineno = 1;