From e08ed49381b98d5f9692bcee3e020bbf2f103195 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 10 Mar 2021 10:08:37 +0100 Subject: [PATCH] Prefer xbt_assert here. --- src/mc/mc_global.cpp | 8 +++----- src/surf/cpu_ti.cpp | 10 ++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/mc/mc_global.cpp b/src/mc/mc_global.cpp index 1549e4e1b6..7906df23d7 100644 --- a/src/mc/mc_global.cpp +++ b/src/mc/mc_global.cpp @@ -20,6 +20,8 @@ #include #include +#include +#include #include #endif @@ -61,11 +63,7 @@ FILE *dot_output = nullptr; void MC_init_dot_output() { dot_output = fopen(_sg_mc_dot_output_file.get().c_str(), "w"); - - if (dot_output == nullptr) { - perror("Error open dot output file"); - xbt_abort(); - } + xbt_assert(dot_output != nullptr, "Error open dot output file: %s", strerror(errno)); fprintf(dot_output, "digraph graphname{\n fixedsize=true; rankdir=TB; ranksep=.25; edge [fontsize=12]; node [fontsize=10, shape=circle,width=.5 ]; graph [resolution=20, fontsize=10];\n"); diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 1316a0f782..54756761f5 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -139,12 +139,10 @@ double CpuTiTmgr::solve(double a, double amount) const } /* Sanity checks */ - if ((a < 0.0) || (amount < 0.0)) { - XBT_CRITICAL("Error, invalid parameters [a = %.2f, amount = %.2f]. " - "You probably have a task executing with negative computation amount. Check your code.", - a, amount); - xbt_abort(); - } + xbt_assert(a >= 0.0 && amount >= 0.0, + "Error, invalid parameters [a = %.2f, amount = %.2f]. " + "You probably have a task executing with negative computation amount. Check your code.", + a, amount); /* At this point, a and amount are positive */ if (amount < EPSILON) -- 2.20.1