-check NULL, check RV
[oweals/gnunet.git] / src / namestore / test_namestore_api_zone_iteration.c
index cfeceabe063e1e3f2cbf06b3bce4eeed104dd7d1..933845206e59e473549375c11b8b527321e41cc9 100644 (file)
@@ -56,6 +56,8 @@ static char * s_name_3;
 
 static struct GNUNET_GNSRECORD_Data *s_rd_3;
 
+static char *directory;
+
 
 /**
  * Re-establish the connection to the service.
@@ -179,6 +181,7 @@ zone_proc (void *cls,
     GNUNET_SCHEDULER_add_now (&end, NULL);
     return;
   }
+  GNUNET_assert (NULL != zone);
   if (0 == memcmp (zone, privkey, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
   {
     if (0 == strcmp (label, s_name_1))
@@ -330,6 +333,7 @@ create_record (unsigned int count)
     rd[c].record_type = 1111;
     rd[c].data_size = 50;
     rd[c].data = GNUNET_malloc(50);
+    rd[c].flags = 0;
     memset ((char *) rd[c].data, 'a', 50);
   }
   return rd;
@@ -420,6 +424,13 @@ run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *cfg,
      struct GNUNET_TESTING_Peer *peer)
 {
+  directory = NULL;
+  GNUNET_assert (GNUNET_OK ==
+                 GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS",
+                                                       "GNUNET_TEST_HOME",
+                                                       &directory));
+  GNUNET_DISK_directory_remove (directory);
+
   endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT, &endbadly, NULL);
   nsh = GNUNET_NAMESTORE_connect (cfg);
   GNUNET_break (NULL != nsh);
@@ -445,7 +456,14 @@ main (int argc, char *argv[])
                                "test_namestore_api.conf",
                                &run,
                                NULL))
-    return 1;
+  {
+    res = 1;
+  }
+  if (NULL != directory)
+  {
+      GNUNET_DISK_directory_remove (directory);
+      GNUNET_free (directory);
+  }
   return res;
 }