From 1ecbb4c88462e9ec9be0c830a257da6e9b774a25 Mon Sep 17 00:00:00 2001 From: navarrop Date: Thu, 17 Feb 2011 17:14:29 +0000 Subject: [PATCH] Remove all xbt_assert.*(0,FALSE or NULL for xbt_die git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9657 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- .../alias/masterslave_forwarder_with_alias.c | 2 +- examples/msg/chord/chord.c | 2 +- examples/msg/gtnets/gtnets.c | 2 +- examples/msg/masterslave/masterslave_bypass.c | 2 +- .../msg/masterslave/masterslave_cluster.c | 4 +-- .../msg/masterslave/masterslave_failure.c | 10 +++---- .../msg/masterslave/masterslave_forwarder.c | 2 +- examples/msg/sendrecv/sendrecv.c | 4 +-- src/msg/host.c | 2 +- src/simdag/sd_task.c | 2 +- src/surf/gtnets/gtnets_topology.cc | 2 +- src/surf/network_gtnets.c | 29 +++++++++---------- src/surf/surf.c | 4 +-- src/surf/surf_routing.c | 11 ++++--- src/xbt/config.c | 24 +++++++-------- src/xbt/dynar.c | 2 +- testsuite/surf/lmm_usage.c | 6 ++-- tools/gras/stub_generator.c | 2 +- 18 files changed, 54 insertions(+), 58 deletions(-) diff --git a/examples/msg/alias/masterslave_forwarder_with_alias.c b/examples/msg/alias/masterslave_forwarder_with_alias.c index 807d775d6d..b1aae7fb80 100644 --- a/examples/msg/alias/masterslave_forwarder_with_alias.c +++ b/examples/msg/alias/masterslave_forwarder_with_alias.c @@ -180,7 +180,7 @@ int forwarder(int argc, char *argv[]) i++; } else { XBT_INFO("Hey ?! What's up ? "); - xbt_assert0(0, "Unexpected behavior"); + xbt_die( "Unexpected behavior"); } } diff --git a/examples/msg/chord/chord.c b/examples/msg/chord/chord.c index 51cf97c8dd..90dd6988fe 100644 --- a/examples/msg/chord/chord.c +++ b/examples/msg/chord/chord.c @@ -915,7 +915,7 @@ int main(int argc, char *argv[]) XBT_DEBUG("Set timeout to %d", timeout); } else { - xbt_assert1(0, "Invalid chord option '%s'", options[0]); + xbt_die(bprintf("Invalid chord option '%s'", options[0])); } } options++; diff --git a/examples/msg/gtnets/gtnets.c b/examples/msg/gtnets/gtnets.c index bd00faf78e..f63ab5828e 100644 --- a/examples/msg/gtnets/gtnets.c +++ b/examples/msg/gtnets/gtnets.c @@ -111,7 +111,7 @@ int slave(int argc, char *argv[]) if (a != MSG_OK) { XBT_INFO("Hey?! What's up?"); - xbt_assert0(0, "Unexpected behavior."); + xbt_die("Unexpected behavior."); } elapsed_time = MSG_get_clock() - start_time; diff --git a/examples/msg/masterslave/masterslave_bypass.c b/examples/msg/masterslave/masterslave_bypass.c index bd81da8e57..be9403fe86 100644 --- a/examples/msg/masterslave/masterslave_bypass.c +++ b/examples/msg/masterslave/masterslave_bypass.c @@ -252,7 +252,7 @@ int slave(int argc, char *argv[]) MSG_task_destroy(task); } else { XBT_INFO("Hey ?! What's up ? "); - xbt_assert0(0, "Unexpected behavior"); + xbt_die( "Unexpected behavior"); } } XBT_INFO("I'm done. See you!"); diff --git a/examples/msg/masterslave/masterslave_cluster.c b/examples/msg/masterslave/masterslave_cluster.c index 15a2ecd37d..3a1cb0c79a 100644 --- a/examples/msg/masterslave/masterslave_cluster.c +++ b/examples/msg/masterslave/masterslave_cluster.c @@ -124,8 +124,8 @@ int slave(int argc, char *argv[]) MSG_task_destroy(task); } else { XBT_INFO("Hey ?! What's up ? "); - xbt_assert0(0, "Unexpected behavior"); - } + xbt_die("Unexpected behavior"); + } } XBT_INFO("I'm done. See you!"); return 0; diff --git a/examples/msg/masterslave/masterslave_failure.c b/examples/msg/masterslave/masterslave_failure.c index 901d08c229..604af1852b 100644 --- a/examples/msg/masterslave/masterslave_failure.c +++ b/examples/msg/masterslave/masterslave_failure.c @@ -96,7 +96,7 @@ int master(int argc, char *argv[]) MSG_task_destroy(task); } else { XBT_INFO("Hey ?! What's up ? "); - xbt_assert0(0, "Unexpected behavior"); + xbt_die( "Unexpected behavior"); } } @@ -124,8 +124,8 @@ int master(int argc, char *argv[]) MSG_task_destroy(task); } else { XBT_INFO("Hey ?! What's up ? "); - xbt_assert2(0, "Unexpected behavior with '%s': %d", slaves[i]->name, - a); + xbt_die(bprintf("Unexpected behavior with '%s': %d", slaves[i]->name, + a)); } } @@ -166,7 +166,7 @@ int slave(int argc, char *argv[]) return 0; } else { XBT_INFO("Hey ?! What's up ? "); - xbt_assert0(0, "Unexpected behavior"); + xbt_die("Unexpected behavior"); } } else if (a == MSG_HOST_FAILURE) { XBT_INFO @@ -176,7 +176,7 @@ int slave(int argc, char *argv[]) XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!"); } else { XBT_INFO("Hey ?! What's up ? "); - xbt_assert0(0, "Unexpected behavior"); + xbt_die("Unexpected behavior"); } } XBT_INFO("I'm done. See you!"); diff --git a/examples/msg/masterslave/masterslave_forwarder.c b/examples/msg/masterslave/masterslave_forwarder.c index efcb433585..4055876afe 100644 --- a/examples/msg/masterslave/masterslave_forwarder.c +++ b/examples/msg/masterslave/masterslave_forwarder.c @@ -166,7 +166,7 @@ int forwarder(int argc, char *argv[]) i++; } else { XBT_INFO("Hey ?! What's up ? "); - xbt_assert0(0, "Unexpected behavior"); + xbt_die("Unexpected behavior"); } } xbt_free(slaves); diff --git a/examples/msg/sendrecv/sendrecv.c b/examples/msg/sendrecv/sendrecv.c index 97f162d644..cd5ea884ea 100644 --- a/examples/msg/sendrecv/sendrecv.c +++ b/examples/msg/sendrecv/sendrecv.c @@ -102,7 +102,7 @@ int receiver(int argc, char *argv[]) XBT_INFO("Communic. time %le", communication_time); XBT_INFO("--- la %f ----", communication_time); } else { - xbt_assert0(0, "Unexpected behavior"); + xbt_die("Unexpected behavior"); } @@ -119,7 +119,7 @@ int receiver(int argc, char *argv[]) XBT_INFO("Communic. time %le", communication_time); XBT_INFO("--- bw %f ----", task_comm_size_bw / communication_time); } else { - xbt_assert0(0, "Unexpected behavior"); + xbt_die("Unexpected behavior"); } diff --git a/src/msg/host.c b/src/msg/host.c index f5cbf871e1..20541bc96a 100644 --- a/src/msg/host.c +++ b/src/msg/host.c @@ -180,7 +180,7 @@ m_host_t *MSG_get_host_table(void) int MSG_get_host_msgload(m_host_t h) { xbt_assert0((h != NULL), "Invalid parameters"); - xbt_assert0(0, "Not implemented yet"); + xbt_die( "Not implemented yet"); return (0); } diff --git a/src/simdag/sd_task.c b/src/simdag/sd_task.c index d1d9f1adcd..57a59959d4 100644 --- a/src/simdag/sd_task.c +++ b/src/simdag/sd_task.c @@ -158,7 +158,7 @@ void __SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state) task->state_set = sd_global->failed_task_set; break; default: - xbt_assert0(0, "Invalid state"); + xbt_die( "Invalid state"); } xbt_swag_insert(task, task->state_set); task->state = new_state; diff --git a/src/surf/gtnets/gtnets_topology.cc b/src/surf/gtnets/gtnets_topology.cc index b022bc71c2..7df843cf4e 100644 --- a/src/surf/gtnets/gtnets_topology.cc +++ b/src/surf/gtnets/gtnets_topology.cc @@ -358,7 +358,7 @@ int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){ } else{ - xbt_assert0(0, "Shouldn't be here"); + xbt_die("Shouldn't be here"); } return 0; diff --git a/src/surf/network_gtnets.c b/src/surf/network_gtnets.c index 804a20ab28..dd73d52b27 100644 --- a/src/surf/network_gtnets.c +++ b/src/surf/network_gtnets.c @@ -42,7 +42,7 @@ static void link_new(char *name, double bw, double lat, xbt_dict_t props) link_count, name, lat, bw); if (gtnets_add_link(link_count, bw, lat)) { - xbt_assert0(0, "Cannot create GTNetS link"); + xbt_die("Cannot create GTNetS link"); } gtnets_link->id = link_count; @@ -69,7 +69,7 @@ static void route_new(int src_id, int dst_id, xbt_dynar_t links, } if (gtnets_add_route(src_id, dst_id, gtnets_links, nb_link)) { - xbt_assert0(0, "Cannot create GTNetS route"); + xbt_die("Cannot create GTNetS route"); } XBT_OUT(); } @@ -78,7 +78,7 @@ static void route_onehop_new(int src_id, int dst_id, network_link_GTNETS_t link) { if (gtnets_add_onehop_route(src_id, dst_id, link->id)) { - xbt_assert0(0, "Cannot create GTNetS route"); + xbt_die("Cannot create GTNetS route"); } } @@ -174,8 +174,7 @@ static void define_callbacks(const char *file) static int resource_used(void *resource_id) { - xbt_assert0(0, - "The resource_used feature is not implemented in GTNets model"); + xbt_die("The resource_used feature is not implemented in GTNets model"); } static int action_unref(surf_action_t action) @@ -195,13 +194,13 @@ static int action_unref(surf_action_t action) static void action_cancel(surf_action_t action) { - xbt_assert0(0, "Cannot cancel GTNetS flow"); + xbt_die("Cannot cancel GTNetS flow"); return; } static void action_recycle(surf_action_t action) { - xbt_assert0(0, "Cannot recycle GTNetS flow"); + xbt_die("Cannot recycle GTNetS flow"); return; } @@ -255,12 +254,10 @@ static void update_actions_state(double now, double delta) num_flows = 0; if (gtnets_run_until_next_flow_completion(&metadata, &num_flows)) { - xbt_assert0(0, - "Cannot run GTNetS simulation until next flow completion"); + xbt_die("Cannot run GTNetS simulation until next flow completion"); } if (num_flows < 1) { - xbt_assert0(0, - "GTNetS simulation couldn't find a flow that would complete"); + xbt_die("GTNetS simulation couldn't find a flow that would complete"); } xbt_swag_foreach(action, running_actions) { @@ -315,7 +312,7 @@ static void update_actions_state(double now, double delta) } else { /* run for a given number of seconds */ if (gtnets_run(delta)) { - xbt_assert0(0, "Cannot run GTNetS simulation"); + xbt_die("Cannot run GTNetS simulation"); } } @@ -326,7 +323,7 @@ static void update_resource_state(void *id, tmgr_trace_event_t event_type, double value, double date) { - xbt_assert0(0, "Cannot update model state for GTNetS simulation"); + xbt_die("Cannot update model state for GTNetS simulation"); } /* Max durations are not supported */ @@ -357,8 +354,8 @@ static surf_action_t communicate(const char *src_name, /* Add a flow to the GTNets Simulation, associated to this action */ if (gtnets_create_flow(src, dst, size, (void *) action) < 0) { - xbt_assert2(0, "Not route between host %s and host %s", src_name, - dst_name); + xbt_die(bprintf("Not route between host %s and host %s", src_name, + dst_name)); } #ifdef HAVE_TRACING TRACE_surf_gtnets_communicate(action, src, dst); @@ -417,7 +414,7 @@ static void surf_network_model_init_internal(void) /* Added the initialization for GTNetS interface */ if (gtnets_initialize(sg_tcp_gamma)) { - xbt_assert0(0, "Impossible to initialize GTNetS interface"); + xbt_die("Impossible to initialize GTNetS interface"); } routing_model_create(sizeof(network_link_GTNETS_t), NULL, NULL); diff --git a/src/surf/surf.c b/src/surf/surf.c index 0ef93c9b8e..2135195e1a 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -203,8 +203,8 @@ int find_model_description(s_surf_model_description_t * table, strcat(name_list, ", "); strcat(name_list, table[i].name); } - xbt_assert2(0, "Model '%s' is invalid! Valid models are: %s.", name, - name_list); + xbt_die(bprintf("Model '%s' is invalid! Valid models are: %s.", name, + name_list)); return -1; } diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 8f84e71f5e..3b6d3081b3 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -2504,9 +2504,9 @@ static char *remplace(char *value, const char **src_list, int src_size, param_list = dst_list; param_size = dst_size; } else { - xbt_assert2(0, + xbt_die(bprintf( "bad string parameter, support only \"src\" and \"dst\", at offset: %d (\"%s\")", - i, value); + i, value)); } i = i + 3; @@ -2594,7 +2594,7 @@ static route_extended_t rulebased_get_route(routing_component_t rc, (routing_component_rulebased_t) rc; int are_processing_units=0; - xbt_dynar_t rule_list = NULL; + xbt_dynar_t rule_list; if (xbt_dict_get_or_null(routing->dict_processing_units, src) && xbt_dict_get_or_null(routing->dict_processing_units, dst)) { are_processing_units = 1; @@ -2605,9 +2605,8 @@ static route_extended_t rulebased_get_route(routing_component_t rc, are_processing_units = 0; rule_list = routing->list_ASroute; } else - xbt_assert2(NULL, - "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table", - src, dst); + xbt_die(bprintf("Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table", + src, dst)); int rc_src = -1; int rc_dst = -1; diff --git a/src/xbt/config.c b/src/xbt/config.c index e1b21e3e24..138076c7c6 100644 --- a/src/xbt/config.c +++ b/src/xbt/config.c @@ -547,8 +547,8 @@ void xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name, va_list pa) break; default: - xbt_assert2(0, "Config element variable %s not valid (type=%d)", name, - type); + xbt_die(bprintf("Config element variable %s not valid (type=%d)", name, + type)); } } @@ -645,9 +645,9 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) val = strchr(name, ':'); if (!val) { free(optionlist_cpy); - xbt_assert1(FALSE, + xbt_die(bprintf( "Option '%s' badly formated. Should be of the form 'name:value'", - name); + name)); } *(val++) = '\0'; @@ -679,9 +679,9 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) i = strtol(val, &val, 0); if (val == NULL) { free(optionlist_cpy); - xbt_assert1(FALSE, + xbt_die(bprintf( "Value of option %s not valid. Should be an integer", - name); + name)); } xbt_cfg_set_int(cfg, name, i); /* throws */ @@ -691,9 +691,9 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) d = strtod(val, &val); if (val == NULL) { free(optionlist_cpy); - xbt_assert1(FALSE, + xbt_die(bprintf( "Value of option %s not valid. Should be a double", - name); + name)); } xbt_cfg_set_double(cfg, name, d); /* throws */ @@ -704,18 +704,18 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) val = strchr(val, ':'); if (!val) { free(optionlist_cpy); - xbt_assert1(FALSE, + xbt_die(bprintf( "Value of option %s not valid. Should be an peer (machine:port)", - name); + name)); } *(val++) = '\0'; i = strtol(val, &val, 0); if (val == NULL) { free(optionlist_cpy); - xbt_assert1(FALSE, + xbt_die(bprintf( "Value of option %s not valid. Should be an peer (machine:port)", - name); + name)); } xbt_cfg_set_peer(cfg, name, str, i); /* throws */ diff --git a/src/xbt/dynar.c b/src/xbt/dynar.c index 47bf4aa6f7..22eb8d27a4 100644 --- a/src/xbt/dynar.c +++ b/src/xbt/dynar.c @@ -818,7 +818,7 @@ XBT_TEST_UNIT("int", test_dynar_int, "Dynars of integers") xbt_test_add0("==== Traverse the empty dynar"); d = xbt_dynar_new(sizeof(int), NULL); xbt_dynar_foreach(d, cursor, i) { - xbt_assert0(0, "Damnit, there is something in the empty dynar"); + xbt_die( "Damnit, there is something in the empty dynar"); } xbt_dynar_free(&d); /* This code is used both as example and as regression test, so we try to */ xbt_dynar_free(&d); /* free the struct twice here to check that it's ok, but freeing it only once */ diff --git a/testsuite/surf/lmm_usage.c b/testsuite/surf/lmm_usage.c index e6c60cf9b0..2c978181ea 100644 --- a/testsuite/surf/lmm_usage.c +++ b/testsuite/surf/lmm_usage.c @@ -221,7 +221,7 @@ void test1(method_t method) a - x, lmm_variable_getvalue(R_1_2_3) - (a - x)); } } else { - xbt_assert0(0, "Invalid method"); + xbt_die( "Invalid method"); } PRINT_VAR(R_1_2_3); @@ -273,7 +273,7 @@ void test2(method_t method) } else if (method == LAGRANGE_RENO) { lagrange_solve(Sys); } else { - xbt_assert0(0, "Invalid method"); + xbt_die("Invalid method"); } PRINT_VAR(T1); @@ -445,7 +445,7 @@ void test3(method_t method) } else if (method == LAGRANGE_RENO) { lagrange_solve(Sys); } else { - xbt_assert0(0, "Invalid method"); + xbt_die("Invalid method"); } for (j = 0; j < 16; j++) { diff --git a/tools/gras/stub_generator.c b/tools/gras/stub_generator.c index 4d89eaf2d1..8e3caa70ef 100644 --- a/tools/gras/stub_generator.c +++ b/tools/gras/stub_generator.c @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) deployment_file = argv[i]; surf_parse_open(deployment_file); if (surf_parse()) - xbt_assert1(0, "Parse error in %s", deployment_file); + xbt_die(bprintf("Parse error in %s", deployment_file)); surf_parse_close(); } -- 2.20.1