From: Arnaud Giersch Date: Tue, 7 Jun 2011 14:48:50 +0000 (+0200) Subject: Reindent TRY/TRY_CLEANUP/CATCH constructs. X-Git-Tag: v3_6_1~9 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/e566c09daba9ad67b31f3992da9172eb04b807a8?ds=sidebyside Reindent TRY/TRY_CLEANUP/CATCH constructs. --- diff --git a/doc/gtut-files/10-rpc.c b/doc/gtut-files/10-rpc.c index a428e8d7de..bc01cbfe47 100644 --- a/doc/gtut-files/10-rpc.c +++ b/doc/gtut-files/10-rpc.c @@ -128,7 +128,8 @@ int client(int argc, char *argv[]) TRY { gras_msg_rpccall(toserver, 60, "convert a2i", &string_to_convert, &long_result); - } CATCH(e) { + } + CATCH(e) { XBT_INFO ("The server refuses to convert %s. Here is the received exception:", string_to_convert); diff --git a/doc/gtut-tour-08-exceptions.doc b/doc/gtut-tour-08-exceptions.doc index 6a9c15c525..057e9bf7fd 100644 --- a/doc/gtut-tour-08-exceptions.doc +++ b/doc/gtut-tour-08-exceptions.doc @@ -54,7 +54,8 @@ its own arguments. So, you may have something like the following: Then, you simply add a #TRY/#CATCH block around your code: \verbatim TRY{ /* your code */ -} CATCH(e) { +} +CATCH(e) { /* error handling code */ } \endverbatim diff --git a/examples/amok/bandwidth/bandwidth.c b/examples/amok/bandwidth/bandwidth.c index 533b03a7ae..d2e232544f 100644 --- a/examples/amok/bandwidth/bandwidth.c +++ b/examples/amok/bandwidth/bandwidth.c @@ -39,7 +39,8 @@ int sensor(int argc, char *argv[]) TRY { master = gras_socket_client_from_string(argv[1]); connected = 1; - } CATCH(e) { + } + CATCH(e) { xbt_ex_free(e); } if (!connected) { diff --git a/examples/gras/spawn/spawn.c b/examples/gras/spawn/spawn.c index 001abd7e6b..f2d74b1831 100644 --- a/examples/gras/spawn/spawn.c +++ b/examples/gras/spawn/spawn.c @@ -33,7 +33,8 @@ int worker(int argc, char *argv[]) { xbt_ex_t e; TRY { xbt_queue_shift_timed(todo,&chunk,0); - } CATCH(e) { + } + CATCH(e) { if (e.category != timeout_error) { RETHROW; } diff --git a/src/gras/DataDesc/cbps.c b/src/gras/DataDesc/cbps.c index f5d1d13d5a..4584b19ea5 100644 --- a/src/gras/DataDesc/cbps.c +++ b/src/gras/DataDesc/cbps.c @@ -87,7 +87,8 @@ gras_cbps_v_push(gras_cbps_t ps, TRY { varstack = xbt_dict_get(ps->space, name); - } CATCH(e) { + } + CATCH(e) { if (e.category != mismatch_error) RETHROW; @@ -128,7 +129,8 @@ gras_cbps_v_pop(gras_cbps_t ps, XBT_DEBUG("pop(%s)", name); TRY { varstack = xbt_dict_get(ps->space, name); - } CATCH(e) { + } + CATCH(e) { if (e.category != mismatch_error) RETHROW; diff --git a/src/gras/DataDesc/ddt_create.c b/src/gras/DataDesc/ddt_create.c index 51f37af1f7..05eb79e766 100644 --- a/src/gras/DataDesc/ddt_create.c +++ b/src/gras/DataDesc/ddt_create.c @@ -55,7 +55,8 @@ gras_datadesc_type_t gras_datadesc_by_name_or_null(const char *name) TRY { res = gras_datadesc_by_name(name); - } CATCH(e) { + } + CATCH(e) { res = NULL; xbt_ex_free(e); } @@ -75,7 +76,8 @@ gras_datadesc_type_t gras_datadesc_by_name(const char *name) (gras_datadesc_type_t) xbt_set_get_by_name(gras_datadesc_set_local, name); found = 1; - } CATCH(e) { + } + CATCH(e) { if (e.category != not_found_error) RETHROW; xbt_ex_free(e); @@ -98,7 +100,8 @@ gras_datadesc_type_t gras_datadesc_by_id(long int code) res = (gras_datadesc_type_t) xbt_set_get_by_id(gras_datadesc_set_local, code); - } CATCH(e) { + } + CATCH(e) { if (e.category != not_found_error) RETHROW; xbt_ex_free(e); diff --git a/src/gras/DataDesc/ddt_exchange.c b/src/gras/DataDesc/ddt_exchange.c index 5834d34d0c..60b19436e9 100644 --- a/src/gras/DataDesc/ddt_exchange.c +++ b/src/gras/DataDesc/ddt_exchange.c @@ -402,7 +402,8 @@ int gras_datadesc_memcpy(gras_datadesc_type_t type, void *src, void *dst) size = gras_datadesc_memcpy_rec(state, refs, type, (char *) src, (char *) dst, 0, type->cycle); - } TRY_CLEANUP { + } + TRY_CLEANUP { xbt_dict_reset(refs); gras_cbps_reset(state); } @@ -643,7 +644,8 @@ void gras_datadesc_send(gras_socket_t sock, TRY { gras_datadesc_send_rec(sock, state, refs, type, (char *) src, type->cycle); - } TRY_CLEANUP { + } + TRY_CLEANUP { xbt_dict_reset(refs); gras_cbps_reset(state); } @@ -981,7 +983,8 @@ gras_datadesc_recv(gras_socket_t sock, TRY { gras_datadesc_recv_rec(sock, state, refs, type, r_arch, NULL, 0, (char *) dst, -1, type->cycle); - } TRY_CLEANUP { + } + TRY_CLEANUP { xbt_dict_reset(refs); gras_cbps_reset(state); } diff --git a/src/gras/Msg/gras_msg_types.c b/src/gras/Msg/gras_msg_types.c index 2c2aef2701..fbf04a74a5 100644 --- a/src/gras/Msg/gras_msg_types.c +++ b/src/gras/Msg/gras_msg_types.c @@ -85,7 +85,8 @@ gras_msgtype_declare_ext(const char *name, msgtype = (gras_msgtype_t) xbt_set_get_by_name(_gras_msgtype_set, namev); found = 1; - } CATCH(e) { + } + CATCH(e) { if (e.category != not_found_error) { xbt_free(namev); RETHROW; @@ -182,7 +183,8 @@ gras_msgtype_t gras_msgtype_by_name_or_null(const char *name) TRY { res = gras_msgtype_by_namev(name, 0); - } CATCH(e) { + } + CATCH(e) { res = NULL; xbt_ex_free(e); } @@ -200,7 +202,8 @@ gras_msgtype_t gras_msgtype_by_namev(const char *name, short int version) TRY { res = (gras_msgtype_t) xbt_set_get_by_name(_gras_msgtype_set, namev); found = 1; - } CATCH(e) { + } + CATCH(e) { xbt_ex_free(e); } if (!found) diff --git a/src/gras/Msg/rl_msg.c b/src/gras/Msg/rl_msg.c index 37b6fd13bf..d3953714e1 100644 --- a/src/gras/Msg/rl_msg.c +++ b/src/gras/Msg/rl_msg.c @@ -155,7 +155,8 @@ void gras_msg_recv(gras_socket_t sock, gras_msg_t msg) TRY { msg->type = (gras_msgtype_t) xbt_set_get_by_name(_gras_msgtype_set, msg_name); - } CATCH(e) { + } + CATCH(e) { /* FIXME: Survive unknown messages */ if (e.category == not_found_error) { xbt_ex_free(e); diff --git a/src/gras/Transport/transport.c b/src/gras/Transport/transport.c index 7c3c4e952a..ef7e7ccaf2 100644 --- a/src/gras/Transport/transport.c +++ b/src/gras/Transport/transport.c @@ -38,7 +38,8 @@ static void gras_trp_plugin_new(const char *name, gras_trp_setup_t setup) TRY { setup(plug); - } CATCH(e) { + } + CATCH(e) { if (e.category == mismatch_error) { /* SG plugin raise mismatch when in RL mode (and vice versa) */ free(plug->name); diff --git a/src/simix/smx_synchro.c b/src/simix/smx_synchro.c index 8ea578fd8a..ca8f8dc7a7 100644 --- a/src/simix/smx_synchro.c +++ b/src/simix/smx_synchro.c @@ -99,7 +99,8 @@ static void SIMIX_synchro_finish(smx_action_t action) case SIMIX_SRC_TIMEOUT: TRY { THROWF(timeout_error, 0, "Synchro's wait timeout"); - } CATCH(req->issuer->running_ctx->exception) { + } + CATCH(req->issuer->running_ctx->exception) { req->issuer->doexception = 1; } break; @@ -107,7 +108,8 @@ static void SIMIX_synchro_finish(smx_action_t action) case SIMIX_FAILED: TRY { THROWF(host_error, 0, "Host failed"); - } CATCH(req->issuer->running_ctx->exception) { + } + CATCH(req->issuer->running_ctx->exception) { req->issuer->doexception = 1; } break; diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index e531e85913..c9d2c8b4ab 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -240,7 +240,8 @@ int smpi_shared_known_call(const char* func, const char* input) { TRY { xbt_dict_get(calls, loc); /* Succeed or throw */ known = 1; - } CATCH(ex) { + } + CATCH(ex) { if(ex.category == not_found_error) { known = 0; xbt_ex_free(ex); diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 9309801f5e..9244f2da95 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -456,7 +456,8 @@ void surfxml_del_callback(xbt_dynar_t cb_list, void_f_void_t function) TRY { it = xbt_dynar_search(cb_list,&function); - } CATCH(e) { + } + CATCH(e) { if (e.category == not_found_error) { xbt_ex_free(e); xbt_die("Trying to remove a callback that is not here! This should not happen"); diff --git a/src/xbt/config.c b/src/xbt/config.c index b0e9ef81d6..a9071df134 100644 --- a/src/xbt/config.c +++ b/src/xbt/config.c @@ -515,7 +515,8 @@ void xbt_cfg_set_vargs(xbt_cfg_t cfg, const char *name, va_list pa) TRY { type = xbt_cfg_get_type(cfg, name); - } CATCH(e) { + } + CATCH(e) { if (e.category == not_found_error) { xbt_ex_free(e); THROWF(not_found_error, 0, @@ -1132,7 +1133,8 @@ void xbt_cfg_empty(xbt_cfg_t cfg, const char *name) TRY { variable = xbt_dict_get((xbt_dict_t) cfg, name); - } CATCH(e) { + } + CATCH(e) { if (e.category != not_found_error) RETHROW; @@ -1293,7 +1295,8 @@ xbt_dynar_t xbt_cfg_get_dynar(xbt_cfg_t cfg, const char *name) TRY { variable = xbt_dict_get((xbt_dict_t) cfg, name); - } CATCH(e) { + } + CATCH(e) { if (e.category == not_found_error) { xbt_ex_free(e); THROWF(not_found_error, 0, @@ -1472,7 +1475,8 @@ XBT_TEST_UNIT("use", test_config_use, "Data retrieving tests") TRY { xbt_cfg_set_parse(myset, "color:blue"); - } CATCH(e) { + } + CATCH(e) { if (e.category != not_found_error) xbt_test_exception(e); xbt_ex_free(e); diff --git a/src/xbt/dict.c b/src/xbt/dict.c index 5bf48fabb0..d4320000f1 100644 --- a/src/xbt/dict.c +++ b/src/xbt/dict.c @@ -941,7 +941,8 @@ static void search_not_found(xbt_dict_t head, const char *data) data = xbt_dict_get(head, data); THROWF(unknown_error, 0, "Found something which shouldn't be there (%s)", data); - } CATCH(e) { + } + CATCH(e) { if (e.category != not_found_error) xbt_test_exception(e); xbt_ex_free(e); @@ -1014,7 +1015,8 @@ XBT_TEST_UNIT("basic", test_dict_basic, "Basic usage: change, retrieve, traverse traverse(head); TRY { debuged_remove(head, "12346"); - } CATCH(e) { + } + CATCH(e) { if (e.category != not_found_error) xbt_test_exception(e); xbt_ex_free(e); diff --git a/src/xbt/dict_multi.c b/src/xbt/dict_multi.c index f196c66922..6dc05e09f2 100644 --- a/src/xbt/dict_multi.c +++ b/src/xbt/dict_multi.c @@ -95,7 +95,8 @@ xbt_multidict_set(xbt_dict_t mdict, TRY { xbt_multidict_set_ext(mdict, keys, lens, data, free_ctn); - } TRY_CLEANUP { + } + TRY_CLEANUP { xbt_dynar_free(&lens); } CATCH_ANONYMOUS { @@ -232,7 +233,8 @@ void xbt_multidict_remove(xbt_dict_t mdict, xbt_dynar_t keys) TRY { xbt_multidict_remove_ext(mdict, keys, lens); - } TRY_CLEANUP { + } + TRY_CLEANUP { xbt_dynar_free(&lens); } CATCH_ANONYMOUS { diff --git a/src/xbt/dynar.c b/src/xbt/dynar.c index 20b9ec9d1e..b5468e3b9f 100644 --- a/src/xbt/dynar.c +++ b/src/xbt/dynar.c @@ -574,7 +574,8 @@ int xbt_dynar_member(xbt_dynar_t const dynar, void *const elem) TRY { xbt_dynar_search(dynar, elem); - } CATCH(e) { + } + CATCH(e) { if (e.category == not_found_error) { xbt_ex_free(e); return 0; diff --git a/src/xbt/ex.c b/src/xbt/ex.c index 3212457121..b2052e1c81 100644 --- a/src/xbt/ex.c +++ b/src/xbt/ex.c @@ -315,7 +315,8 @@ XBT_TEST_UNIT("variables", test_variables, "variable value preservation") r2 = 5678; v2 = 5678; THROWF(unknown_error, 0, "toto"); - } CATCH(ex) { + } + CATCH(ex) { xbt_test_add("variable preservation"); if (r1 != 1234) xbt_test_fail("r1=%d (!= 1234)", r1); @@ -341,7 +342,8 @@ XBT_TEST_UNIT("cleanup", test_cleanup, "cleanup handling") TRY { v1 = 5678; THROWF(1, 2, "blah"); - } TRY_CLEANUP { + } + TRY_CLEANUP { if (v1 != 5678) xbt_test_fail("v1 = %d (!= 5678)", v1); c = 1; @@ -389,7 +391,8 @@ static void bad_example(void) cp3 = mallocex(SMALLAMOUNT); strcpy(cp1, "foo"); strcpy(cp2, "bar"); - } TRY_CLEANUP { + } + TRY_CLEANUP { if (cp3 != NULL) free(cp3); if (cp2 != NULL) @@ -425,7 +428,8 @@ static void good_example(void) cp3 = mallocex(SMALLAMOUNT); strcpy(cp1, "foo"); strcpy(cp2, "bar"); - } TRY_CLEANUP { /*04 */ + } + TRY_CLEANUP { /*04 */ printf("cp3=%s", cp3 == NULL /*02 */ ? "" : cp3); if (cp3 != NULL) free(cp3); diff --git a/src/xbt/set.c b/src/xbt/set.c index f0d6b9082d..8b3efbfce0 100644 --- a/src/xbt/set.c +++ b/src/xbt/set.c @@ -434,7 +434,8 @@ static void search_not_found(xbt_set_t set, const char *data) xbt_set_get_by_name(set, data); THROWF(unknown_error, 0, "Found something which shouldn't be there (%s)", data); - } CATCH(e) { + } + CATCH(e) { if (e.category != not_found_error) xbt_test_exception(e); xbt_ex_free(e); diff --git a/teshsuite/gras/msg_handle/msg_handle.c b/teshsuite/gras/msg_handle/msg_handle.c index 158fd33a6d..08f00cef69 100644 --- a/teshsuite/gras/msg_handle/msg_handle.c +++ b/teshsuite/gras/msg_handle/msg_handle.c @@ -64,7 +64,8 @@ int server(int argc, char *argv[]) got_expected = 0; TRY { gras_msg_handle(0); - } CATCH(e) { + } + CATCH(e) { if (e.category == timeout_error) { got_expected = 1; xbt_ex_free(e); diff --git a/teshsuite/simdag/platforms/flatifier.c b/teshsuite/simdag/platforms/flatifier.c index 907169a93a..8b5fb69491 100644 --- a/teshsuite/simdag/platforms/flatifier.c +++ b/teshsuite/simdag/platforms/flatifier.c @@ -65,7 +65,8 @@ int main(int argc, char **argv) XBT_DEBUG("%s", platformFile); TRY { SD_create_environment(platformFile); - } CATCH(e) { + } + CATCH(e) { xbt_die("Error while loading %s: %s",platformFile,e.msg); }