Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix xbt_assert with side effects.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 9 Mar 2019 15:04:32 +0000 (16:04 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 9 Mar 2019 15:04:32 +0000 (16:04 +0100)
src/kernel/resource/profile/trace_mgr.cpp
teshsuite/simdag/flatifier/flatifier.cpp

index b0b40ca..a796657 100644 (file)
@@ -100,8 +100,8 @@ Profile* Profile::from_string(const std::string& name, const std::string& input,
     if (sscanf(val.c_str(), "LOOPAFTER %lg\n", &periodicity) == 1)
       continue;
 
     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,
 
     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,
index ac3b301..844e307 100644 (file)
@@ -210,8 +210,8 @@ int main(int argc, char** argv)
 
   SD_init(&argc, argv);
 
 
   SD_init(&argc, argv);
 
-  xbt_assert(parse_cmdline(&timings, &platformFile, argc, argv) && platformFile,
-             "Invalid command line arguments: expected [--timings] platformFile");
+  if (not parse_cmdline(&timings, &platformFile, argc, argv) || not platformFile)
+    xbt_die("Invalid command line arguments: expected [--timings] platformFile");
 
   XBT_DEBUG("%d,%s", timings, platformFile);
 
 
   XBT_DEBUG("%d,%s", timings, platformFile);