Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix xbt_assert with side effects.
[simgrid.git] / src / kernel / resource / profile / trace_mgr.cpp
index 7a27383..a796657 100644 (file)
@@ -79,7 +79,7 @@ DatedValue Profile::next(Event* event)
   return dateVal;
 }
 
-Profile* Profile::from_string(std::string name, std::string input, double periodicity)
+Profile* Profile::from_string(const std::string& name, const std::string& input, double periodicity)
 {
   int linecount                                    = 0;
   simgrid::kernel::profile::Profile* profile       = new simgrid::kernel::profile::Profile();
@@ -100,8 +100,8 @@ Profile* Profile::from_string(std::string name, std::string input, double period
     if (sscanf(val.c_str(), "LOOPAFTER %lg\n", &periodicity) == 1)
       continue;
 
-    xbt_assert(sscanf(val.c_str(), "%lg  %lg\n", &event.date_, &event.value_) == 2, "%s:%d: Syntax error in trace\n%s",
-               name.c_str(), linecount, input.c_str());
+    XBT_ATTRIB_UNUSED int res = sscanf(val.c_str(), "%lg  %lg\n", &event.date_, &event.value_);
+    xbt_assert(res == 2, "%s:%d: Syntax error in trace\n%s", name.c_str(), linecount, input.c_str());
 
     xbt_assert(last_event->date_ <= event.date_,
                "%s:%d: Invalid trace: Events must be sorted, but time %g > time %g.\n%s", name.c_str(), linecount,
@@ -123,7 +123,7 @@ Profile* Profile::from_string(std::string name, std::string input, double period
 
   return profile;
 }
-Profile* Profile::from_file(std::string path)
+Profile* Profile::from_file(const std::string& path)
 {
   xbt_assert(not path.empty(), "Cannot parse a trace from an empty filename");
   xbt_assert(trace_list.find(path) == trace_list.end(), "Refusing to define trace %s twice", path.c_str());