]> AND Public Git Repository - simgrid.git/blobdiff - src/xbt/dict.c
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill "if" before free, and useless cast of free argument.
[simgrid.git] / src / xbt / dict.c
index 7f1c91a3c39e18bef9bfafb8db066d2a7dcd17ff..d591e01b9f87c28c867ac5ffba5357dd0699503c 100644 (file)
@@ -323,7 +323,7 @@ XBT_INLINE void *xbt_dict_get_ext(xbt_dict_t dict, const char *key,
   }
 
   if (current == NULL)
-    THROW2(not_found_error, 0, "key %.*s not found", key_len, key);
+    THROWF(not_found_error, 0, "key %.*s not found", key_len, key);
 
   return current->content;
 }
@@ -401,7 +401,7 @@ XBT_INLINE void *xbt_dict_get(xbt_dict_t dict, const char *key)
     current = current->next;
 
   if (current == NULL)
-    THROW1(not_found_error, 0, "key %s not found", key);
+    THROWF(not_found_error, 0, "key %s not found", key);
 
   return current->content;
 }
@@ -457,7 +457,7 @@ XBT_INLINE void xbt_dict_remove_ext(xbt_dict_t dict, const char *key,
   }
 
   if (current == NULL)
-    THROW2(not_found_error, 0, "key %.*s not found", key_len, key);
+    THROWF(not_found_error, 0, "key %.*s not found", key_len, key);
 
   if (previous != NULL) {
     previous->next = current->next;
@@ -591,7 +591,7 @@ XBT_INLINE void xbt_dicti_remove(xbt_dict_t dict, uintptr_t key)
   }
 
   if (current == NULL)
-    THROW1(not_found_error, 0, "key %zu not found", key);
+    THROWF(not_found_error, 0, "key %zu not found", key);
 
   if (previous != NULL) {
     previous->next = current->next;
@@ -939,9 +939,10 @@ static void search_not_found(xbt_dict_t head, const char *data)
 
   TRY {
     data = xbt_dict_get(head, data);
-    THROW1(unknown_error, 0,
+    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);
@@ -974,7 +975,8 @@ static void count(xbt_dict_t dict, int length)
 static void count_check_get_key(xbt_dict_t dict, int length)
 {
   xbt_dict_cursor_t cursor;
-  char *key, *key2;
+  char *key;
+  _XBT_GNUC_UNUSED char *key2;
   void *data;
   int effective = 0;
 
@@ -989,7 +991,7 @@ static void count_check_get_key(xbt_dict_t dict, int length)
   xbt_dict_foreach(dict, cursor, key, data) {
     effective++;
     key2 = xbt_dict_get_key(dict, data);
-    xbt_assert2(!strcmp(key, key2),
+    xbt_assert(!strcmp(key, key2),
                 "The data was registered under %s instead of %s as expected",
                 key2, key);
   }
@@ -1014,7 +1016,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);
@@ -1248,7 +1251,7 @@ static int countelems(xbt_dict_t head)
 XBT_TEST_UNIT("crash", test_dict_crash, "Crash test")
 {
   xbt_dict_t head = NULL;
-  int i, j, k, nb;
+  int i, j, k;
   char *key;
   void *data;
 
@@ -1263,7 +1266,6 @@ XBT_TEST_UNIT("crash", test_dict_crash, "Crash test")
          SIZEOFKEY);
     head = xbt_dict_new();
     /* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
-    nb = 0;
     for (j = 0; j < 1000; j++) {
       char *data = NULL;
       key = xbt_malloc(SIZEOFKEY);