X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0ca1291c2f63ca6235f4b4885c48413a900aade4..406f54970c00ca178fa918763d943027bd09e3ba:/src/xbt/set.c diff --git a/src/xbt/set.c b/src/xbt/set.c index f0d6b9082d..eb09a357fb 100644 --- a/src/xbt/set.c +++ b/src/xbt/set.c @@ -57,7 +57,7 @@ void xbt_set_free(xbt_set_t * set) static int _xbt_set_get_id(xbt_set_t set) { int id; - if (xbt_dynar_length(set->available_ids) > 0) { + if (!xbt_dynar_is_empty(set->available_ids)) { /* if there are some available ids */ xbt_dynar_pop(set->available_ids, &id); } else { @@ -71,7 +71,7 @@ static int _xbt_set_get_id(xbt_set_t set) * * \param set set to populate * \param elm element to add. - * \param free_func How to add the data + * \param free_func how to free the data * * elm->name must be set; * if elm->name_len <= 0, it is recomputed. If >0, it's used as is; @@ -101,19 +101,19 @@ void xbt_set_add(xbt_set_t set, xbt_set_elm_t elm, elm->ID = _xbt_set_get_id(set); xbt_dict_set_ext(set->dict, elm->name, elm->name_len, elm, free_func); xbt_dynar_set(set->dynar, elm->ID, &elm); - XBT_DEBUG("Insertion of key '%s' (id %d)", elm->name, elm->ID); + XBT_DEBUG("Insertion of key '%s' (id %u)", elm->name, elm->ID); xbt_ex_free(e); } if (found) { if (elm == found_in_dict) { XBT_DEBUG - ("Ignoring request to insert the same element twice (key %s ; id %d)", + ("Ignoring request to insert the same element twice (key %s ; id %u)", elm->name, elm->ID); return; } else { elm->ID = found_in_dict->ID; - XBT_DEBUG("Reinsertion of key %s (id %d)", elm->name, elm->ID); + XBT_DEBUG("Reinsertion of key %s (id %u)", elm->name, elm->ID); xbt_dict_set_ext(set->dict, elm->name, elm->name_len, elm, free_func); xbt_dynar_set(set->dynar, elm->ID, &elm); @@ -380,7 +380,7 @@ static void search_name(xbt_set_t head, const char *key) xbt_test_add("Search by name %s", key); elm = (my_elem_t) xbt_set_get_by_name(head, key); - xbt_test_log(" Found %s (under ID %d)\n", + xbt_test_log(" Found %s (under ID %u)\n", elm ? elm->data : "(null)", elm ? elm->ID : -1); if (strcmp(key, elm->name)) THROWF(mismatch_error, 0, "The key (%s) is not the one expected (%s)", @@ -401,7 +401,7 @@ static void search_id(xbt_set_t head, int id, const char *key) elm ? elm->name : "(null)", elm ? elm->data : "(null)"); if (id != elm->ID) THROWF(mismatch_error, 0, - "The found ID (%d) is not the one expected (%d)", elm->ID, id); + "The found ID (%u) is not the one expected (%d)", elm->ID, id); if (strcmp(key, elm->name)) THROWF(mismatch_error, 0, "The key (%s) is not the one expected (%s)", elm->name, key); @@ -418,7 +418,7 @@ static void traverse(xbt_set_t set) xbt_set_foreach(set, cursor, elm) { xbt_test_assert(elm, "Dude ! Got a null elm during traversal!"); - xbt_test_log("Id(%d): %s->%s\n", elm->ID, elm->name, elm->data); + xbt_test_log("Id(%u): %s->%s\n", elm->ID, elm->name, elm->data); xbt_test_assert(!strcmp(elm->name, elm->data), "Key(%s) != value(%s). Abording", elm->name, elm->data); @@ -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); @@ -548,7 +549,7 @@ XBT_TEST_UNIT("remove", test_set_remove, "Removing some values") debuged_add(set, "12anew", "12anew"); elm = (my_elem_t) xbt_set_get_by_id(set, 1); - xbt_test_assert(elm->ID == 1, "elm->ID is %d but should be 1", elm->ID); + xbt_test_assert(elm->ID == 1, "elm->ID is %u but should be 1", elm->ID); xbt_set_free(&set); }