Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reindent TRY/TRY_CLEANUP/CATCH constructs.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 7 Jun 2011 14:48:50 +0000 (16:48 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 23 Jun 2011 19:32:37 +0000 (21:32 +0200)
21 files changed:
doc/gtut-files/10-rpc.c
doc/gtut-tour-08-exceptions.doc
examples/amok/bandwidth/bandwidth.c
examples/gras/spawn/spawn.c
src/gras/DataDesc/cbps.c
src/gras/DataDesc/ddt_create.c
src/gras/DataDesc/ddt_exchange.c
src/gras/Msg/gras_msg_types.c
src/gras/Msg/rl_msg.c
src/gras/Transport/transport.c
src/simix/smx_synchro.c
src/smpi/smpi_bench.c
src/surf/surfxml_parse.c
src/xbt/config.c
src/xbt/dict.c
src/xbt/dict_multi.c
src/xbt/dynar.c
src/xbt/ex.c
src/xbt/set.c
teshsuite/gras/msg_handle/msg_handle.c
teshsuite/simdag/platforms/flatifier.c

index a428e8d..bc01cbf 100644 (file)
@@ -128,7 +128,8 @@ int client(int argc, char *argv[])
   TRY {
     gras_msg_rpccall(toserver, 60, "convert a2i", &string_to_convert,
                      &long_result);
   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);
     XBT_INFO
         ("The server refuses to convert %s. Here is the received exception:",
          string_to_convert);
index 6a9c15c..057e9bf 100644 (file)
@@ -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 */ 
 Then, you simply add a #TRY/#CATCH block around your code:
 \verbatim TRY{ 
   /* your code */ 
-} CATCH(e) { 
+}
+CATCH(e) {
   /* error handling code */
 } \endverbatim
 
   /* error handling code */
 } \endverbatim
 
index 533b03a..d2e2325 100644 (file)
@@ -39,7 +39,8 @@ int sensor(int argc, char *argv[])
     TRY {
       master = gras_socket_client_from_string(argv[1]);
       connected = 1;
     TRY {
       master = gras_socket_client_from_string(argv[1]);
       connected = 1;
-    } CATCH(e) {
+    }
+    CATCH(e) {
       xbt_ex_free(e);
     }
     if (!connected) {
       xbt_ex_free(e);
     }
     if (!connected) {
index 001abd7..f2d74b1 100644 (file)
@@ -33,7 +33,8 @@ int worker(int argc, char *argv[]) {
     xbt_ex_t e;
     TRY {
       xbt_queue_shift_timed(todo,&chunk,0);
     xbt_ex_t e;
     TRY {
       xbt_queue_shift_timed(todo,&chunk,0);
-    } CATCH(e) {
+    }
+    CATCH(e) {
       if (e.category != timeout_error) {
         RETHROW;
       }
       if (e.category != timeout_error) {
         RETHROW;
       }
index f5d1d13..4584b19 100644 (file)
@@ -87,7 +87,8 @@ gras_cbps_v_push(gras_cbps_t ps,
 
   TRY {
     varstack = xbt_dict_get(ps->space, name);
 
   TRY {
     varstack = xbt_dict_get(ps->space, name);
-  } CATCH(e) {
+  }
+  CATCH(e) {
     if (e.category != mismatch_error)
       RETHROW;
 
     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);
   XBT_DEBUG("pop(%s)", name);
   TRY {
     varstack = xbt_dict_get(ps->space, name);
-  } CATCH(e) {
+  }
+  CATCH(e) {
     if (e.category != mismatch_error)
       RETHROW;
 
     if (e.category != mismatch_error)
       RETHROW;
 
index 51f37af..05eb79e 100644 (file)
@@ -55,7 +55,8 @@ gras_datadesc_type_t gras_datadesc_by_name_or_null(const char *name)
 
   TRY {
     res = gras_datadesc_by_name(name);
 
   TRY {
     res = gras_datadesc_by_name(name);
-  } CATCH(e) {
+  }
+  CATCH(e) {
     res = NULL;
     xbt_ex_free(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;
         (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);
     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);
     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);
     if (e.category != not_found_error)
       RETHROW;
     xbt_ex_free(e);
index 5834d34..60b1943 100644 (file)
@@ -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);
     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);
   }
     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 {
     gras_datadesc_send_rec(sock, state, refs, type, (char *) src,
                            type->cycle);
-  } TRY_CLEANUP {
+  }
+  TRY_CLEANUP {
     xbt_dict_reset(refs);
     gras_cbps_reset(state);
   }
     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 {
     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);
   }
     xbt_dict_reset(refs);
     gras_cbps_reset(state);
   }
index 2c2aef2..fbf04a7 100644 (file)
@@ -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;
     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;
     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);
 
   TRY {
     res = gras_msgtype_by_namev(name, 0);
-  } CATCH(e) {
+  }
+  CATCH(e) {
     res = NULL;
     xbt_ex_free(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;
   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)
     xbt_ex_free(e);
   }
   if (!found)
index 37b6fd1..d395371 100644 (file)
@@ -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);
   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);
     /* FIXME: Survive unknown messages */
     if (e.category == not_found_error) {
       xbt_ex_free(e);
index 7c3c4e9..ef7e7cc 100644 (file)
@@ -38,7 +38,8 @@ static void gras_trp_plugin_new(const char *name, gras_trp_setup_t setup)
 
   TRY {
     setup(plug);
 
   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);
     if (e.category == mismatch_error) {
       /* SG plugin raise mismatch when in RL mode (and vice versa) */
       free(plug->name);
index 8ea578f..ca8f8dc 100644 (file)
@@ -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");
     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;
         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");
     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;
         req->issuer->doexception = 1;
       }
       break;
index e531e85..c9d2c8b 100644 (file)
@@ -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;
    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);
       if(ex.category == not_found_error) {
          known = 0;
          xbt_ex_free(ex);
index 9309801..9244f2d 100644 (file)
@@ -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);
 
   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");
     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");
index b0e9ef8..a9071df 100644 (file)
@@ -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);
 
   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,
     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);
 
   TRY {
     variable = xbt_dict_get((xbt_dict_t) cfg, name);
-  } CATCH(e) {
+  }
+  CATCH(e) {
     if (e.category != not_found_error)
       RETHROW;
 
     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);
 
   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,
     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");
 
     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);
       if (e.category != not_found_error)
         xbt_test_exception(e);
       xbt_ex_free(e);
index 5bf48fa..d432000 100644 (file)
@@ -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);
     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);
     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");
   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);
     if (e.category != not_found_error)
       xbt_test_exception(e);
     xbt_ex_free(e);
index f196c66..6dc05e0 100644 (file)
@@ -95,7 +95,8 @@ xbt_multidict_set(xbt_dict_t mdict,
 
   TRY {
     xbt_multidict_set_ext(mdict, keys, lens, data, free_ctn);
 
   TRY {
     xbt_multidict_set_ext(mdict, keys, lens, data, free_ctn);
-  } TRY_CLEANUP {
+  }
+  TRY_CLEANUP {
     xbt_dynar_free(&lens);
   }
   CATCH_ANONYMOUS {
     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 {
     xbt_multidict_remove_ext(mdict, keys, lens);
-  } TRY_CLEANUP {
+  }
+  TRY_CLEANUP {
     xbt_dynar_free(&lens);
   }
   CATCH_ANONYMOUS {
     xbt_dynar_free(&lens);
   }
   CATCH_ANONYMOUS {
index 20b9ec9..b5468e3 100644 (file)
@@ -574,7 +574,8 @@ int xbt_dynar_member(xbt_dynar_t const dynar, void *const elem)
 
   TRY {
     xbt_dynar_search(dynar, elem);
 
   TRY {
     xbt_dynar_search(dynar, elem);
-  } CATCH(e) {
+  }
+  CATCH(e) {
     if (e.category == not_found_error) {
       xbt_ex_free(e);
       return 0;
     if (e.category == not_found_error) {
       xbt_ex_free(e);
       return 0;
index 3212457..b2052e1 100644 (file)
@@ -315,7 +315,8 @@ XBT_TEST_UNIT("variables", test_variables, "variable value preservation")
     r2 = 5678;
     v2 = 5678;
     THROWF(unknown_error, 0, "toto");
     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);
     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 {
     v1 = 5678;
     THROWF(1, 2, "blah");
-  } TRY_CLEANUP {
+  }
+  TRY_CLEANUP {
     if (v1 != 5678)
       xbt_test_fail("v1 = %d (!= 5678)", v1);
     c = 1;
     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");
     cp3 = mallocex(SMALLAMOUNT);
     strcpy(cp1, "foo");
     strcpy(cp2, "bar");
-  } TRY_CLEANUP {
+  }
+  TRY_CLEANUP {
     if (cp3 != NULL)
       free(cp3);
     if (cp2 != NULL)
     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");
       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);
       printf("cp3=%s", cp3 == NULL /*02 */ ? "" : cp3);
       if (cp3 != NULL)
         free(cp3);
index f0d6b90..8b3efbf 100644 (file)
@@ -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);
     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);
     if (e.category != not_found_error)
       xbt_test_exception(e);
     xbt_ex_free(e);
index 158fd33..08f00ce 100644 (file)
@@ -64,7 +64,8 @@ int server(int argc, char *argv[])
   got_expected = 0;
   TRY {
     gras_msg_handle(0);
   got_expected = 0;
   TRY {
     gras_msg_handle(0);
-  } CATCH(e) {
+  }
+  CATCH(e) {
     if (e.category == timeout_error) {
       got_expected = 1;
       xbt_ex_free(e);
     if (e.category == timeout_error) {
       got_expected = 1;
       xbt_ex_free(e);
index 907169a..8b5fb69 100644 (file)
@@ -65,7 +65,8 @@ int main(int argc, char **argv)
   XBT_DEBUG("%s", platformFile);
   TRY {
     SD_create_environment(platformFile);
   XBT_DEBUG("%s", platformFile);
   TRY {
     SD_create_environment(platformFile);
-  } CATCH(e) {
+  }
+  CATCH(e) {
     xbt_die("Error while loading %s: %s",platformFile,e.msg);
   }
 
     xbt_die("Error while loading %s: %s",platformFile,e.msg);
   }