From c45dbb9b597755fafbf53aef93a752c57afc7028 Mon Sep 17 00:00:00 2001 From: alegrand Date: Tue, 7 Dec 2004 20:03:31 +0000 Subject: [PATCH 1/1] Martin wrote : > Then, you could rewrite this to: > > gras_assert1((f = fopen(filename, "r")), > "Cannot open file '%s'\n", filename); > > Since you have some core in the condition, you may want to leave the if, and > put a gras_assert2(0,"bla",bli) in it. Yes. I was not using assert because of the core in the condition. I hadn't thought to gras_assert2(0, Now that should be better. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@558 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/surf/trace_mgr.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/surf/trace_mgr.c b/src/surf/trace_mgr.c index d349c22efb..979a514cf2 100644 --- a/src/surf/trace_mgr.c +++ b/src/surf/trace_mgr.c @@ -52,8 +52,7 @@ tmgr_trace_t tmgr_trace_new(const char *filename) } if ((f = fopen(filename, "r")) == NULL) { - CRITICAL1("Cannot open file '%s'\n", filename); - xbt_abort(); + xbt_assert1(0,"Cannot open file '%s'", filename); } trace = xbt_new0(s_tmgr_trace_t, 1); @@ -67,9 +66,8 @@ tmgr_trace_t tmgr_trace_new(const char *filename) if (sscanf(line, "PERIODICITY " XBT_HEAP_FLOAT_T "\n", &(periodicity)) == 1) { if (periodicity <= 0) { - CRITICAL2("%s,%d: Syntax error. Periodicity has to be positive\n", - filename, linecount); - xbt_abort(); + xbt_assert2(0,"%s,%d: Syntax error. Periodicity has to be positive", + filename, linecount); } continue; } @@ -77,23 +75,19 @@ tmgr_trace_t tmgr_trace_new(const char *filename) if (sscanf (line, XBT_HEAP_FLOAT_T " " XBT_MAXMIN_FLOAT_T "\n", &event.delta, &event.value) != 2) { - CRITICAL2("%s,%d: Syntax error\n", filename, linecount); - xbt_abort(); + xbt_assert2(0,"%s,%d: Syntax error", filename, linecount); } if (last_event) { if ((last_event->delta = event.delta - last_event->delta) <= 0) { - CRITICAL2("%s,%d: Invalid trace value, events have to be sorted\n", - filename, linecount); - xbt_abort(); + xbt_assert2(0,"%s,%d: Invalid trace value, events have to be sorted", + filename, linecount); } } xbt_dynar_push(trace->event_list, &event); last_event = xbt_dynar_get_ptr(trace->event_list, xbt_dynar_length(trace->event_list) - 1); -/* printf(XBT_HEAP_FLOAT_T " " XBT_MAXMIN_FLOAT_T "\n", event.delta, */ -/* event.value); */ } if (periodicity > 0) { @@ -132,8 +126,8 @@ tmgr_trace_event_t tmgr_history_add_trace(tmgr_history_t history, tmgr_trace_t t trace_event->idx = offset; trace_event->resource = resource; - if (trace_event->idx >= xbt_dynar_length(trace->event_list)) - xbt_abort(); + xbt_assert0((trace_event->idx < xbt_dynar_length(trace->event_list)), + "You're refering an event that does not exist!"); xbt_heap_push(history->heap, trace_event, start_time); -- 2.20.1