From: Lucas Schnorr Date: Mon, 23 Jan 2012 12:11:48 +0000 (+0100) Subject: [trace] sanity checks X-Git-Tag: exp_20120216~119^2~33 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/17e2ecb241a23400dab096057ed1fe5cc08cffb1?ds=sidebyside [trace] sanity checks --- diff --git a/src/instr/instr_paje.c b/src/instr/instr_paje.c index 0ea9147eae..dee02034c3 100644 --- a/src/instr/instr_paje.c +++ b/src/instr/instr_paje.c @@ -42,6 +42,10 @@ void PJ_container_set_root (container_t root) container_t PJ_container_new (const char *name, e_container_types kind, container_t father) { + if (name == NULL){ + THROWF (tracing_error, 0, "can't create a container with a NULL name"); + } + static long long int container_id = 0; char id_str[INSTR_DEFAULT_STR_SIZE]; snprintf (id_str, INSTR_DEFAULT_STR_SIZE, "%lld", container_id++); @@ -81,7 +85,7 @@ container_t PJ_container_new (const char *name, e_container_types kind, containe case INSTR_SMPI: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MPI"); break; case INSTR_MSG_PROCESS: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_PROCESS"); break; case INSTR_MSG_TASK: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_TASK"); break; - default: xbt_die ("Congratulations, you have found a bug on newContainer function of instr_routing.c"); break; + default: THROWF (tracing_error, 0, "new container kind is unknown."); break; } type_t type = PJ_type_get (typename, new->father->type); if (type == NULL){ @@ -135,6 +139,10 @@ container_t PJ_container_get_root () void PJ_container_remove_from_parent (container_t child) { + if (child == NULL){ + THROWF (tracing_error, 0, "can't remove from parent with a NULL child"); + } + container_t parent = child->father; if (parent){ XBT_DEBUG("removeChildContainer (%s) FromContainer (%s) ", @@ -146,6 +154,9 @@ void PJ_container_remove_from_parent (container_t child) void PJ_container_free (container_t container) { + if (container == NULL){ + THROWF (tracing_error, 0, "trying to free a NULL container"); + } XBT_DEBUG("destroy container %s", container->name); //obligation to dump previous events because they might @@ -172,6 +183,9 @@ void PJ_container_free (container_t container) static void recursiveDestroyContainer (container_t container) { + if (container == NULL){ + THROWF (tracing_error, 0, "trying to recursively destroy a NULL container"); + } XBT_DEBUG("recursiveDestroyContainer %s", container->name); xbt_dict_cursor_t cursor = NULL; container_t child; @@ -184,7 +198,11 @@ static void recursiveDestroyContainer (container_t container) void PJ_container_free_all () { - if (PJ_container_get_root()) recursiveDestroyContainer (PJ_container_get_root()); + container_t root = PJ_container_get_root(); + if (root == NULL){ + THROWF (tracing_error, 0, "trying to free all containers, but root is NULL"); + } + recursiveDestroyContainer (root); rootContainer = NULL; //checks diff --git a/src/instr/instr_paje_types.c b/src/instr/instr_paje_types.c index 5bf0a6c366..c8f0ee2e3f 100644 --- a/src/instr/instr_paje_types.c +++ b/src/instr/instr_paje_types.c @@ -31,6 +31,10 @@ type_t PJ_type_get_root () static type_t newType (const char *typename, const char *key, const char *color, e_entity_types kind, type_t father) { + if (typename == NULL || key == NULL){ + THROWF(tracing_error, 0, "can't create a new type with name or key equal NULL"); + } + type_t ret = xbt_new0(s_type_t, 1); ret->name = xbt_strdup (typename); ret->father = father; @@ -96,6 +100,10 @@ void PJ_type_free_all (void) static type_t recursiveGetType (const char *name, type_t root) { + if (name == NULL || root == NULL){ + THROWF (tracing_error, 0, "can't get type with a NULL name (or a NULL father given)"); + } + if (strcmp (root->name, name) == 0) return root; xbt_dict_cursor_t cursor = NULL; @@ -122,6 +130,10 @@ type_t PJ_type_get (const char *name, type_t father) type_t PJ_type_container_new (const char *name, type_t father) { + if (name == NULL){ + THROWF (tracing_error, 0, "can't create a container type with a NULL name"); + } + type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name); if (ret){ THROWF(tracing_error, 1, "container type with name %s already exists", name); @@ -141,6 +153,10 @@ type_t PJ_type_container_new (const char *name, type_t father) type_t PJ_type_event_new (const char *name, const char *color, type_t father) { + if (name == NULL){ + THROWF (tracing_error, 0, "can't create an event type with a NULL name"); + } + type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name); if (ret){ THROWF(tracing_error, 1, "event type with name %s already exists", name); @@ -159,6 +175,10 @@ type_t PJ_type_event_new (const char *name, const char *color, type_t father) type_t PJ_type_variable_new (const char *name, const char *color, type_t father) { + if (name == NULL){ + THROWF (tracing_error, 0, "can't create a variable type with a NULL name"); + } + type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name); if (ret){ THROWF(tracing_error, 1, "variable type with name %s already exists", name); @@ -177,6 +197,10 @@ type_t PJ_type_variable_new (const char *name, const char *color, type_t father) type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t dest) { + if (name == NULL){ + THROWF (tracing_error, 0, "can't create a link type with a NULL name"); + } + type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name); if (ret){ THROWF(tracing_error, 1, "link type with name %s already exists", name); @@ -192,6 +216,10 @@ type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t type_t PJ_type_state_new (const char *name, type_t father) { + if (name == NULL){ + THROWF (tracing_error, 0, "can't create a state type with a NULL name"); + } + type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name); if (ret){ THROWF(tracing_error, 1, "state type with name %s already exists", name); diff --git a/src/instr/instr_paje_values.c b/src/instr/instr_paje_values.c index da52f143c6..70580430e3 100644 --- a/src/instr/instr_paje_values.c +++ b/src/instr/instr_paje_values.c @@ -11,6 +11,10 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_values, instr, "Paje tracing event s val_t PJ_value_new (const char *name, const char *color, type_t father) { + if (name == NULL || father == NULL){ + THROWF (tracing_error, 0, "can't create a value with a NULL name (or a NULL father)"); + } + val_t ret = xbt_new0(s_val_t, 1); ret->name = xbt_strdup (name); ret->father = father; @@ -28,6 +32,10 @@ val_t PJ_value_new (const char *name, const char *color, type_t father) val_t PJ_value_get (const char *name, type_t father) { + if (name == NULL || father == NULL){ + THROWF (tracing_error, 0, "can't get a value with a NULL name (or a NULL father)"); + } + if (father->kind == TYPE_VARIABLE) return NULL; //Variables can't have different values val_t ret = (val_t)xbt_dict_get_or_null (father->values, name); if (ret == NULL){