fixes
authorChristian Grothoff <christian@grothoff.org>
Sun, 22 Nov 2009 19:06:54 +0000 (19:06 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 22 Nov 2009 19:06:54 +0000 (19:06 +0000)
src/util/test_configuration.c
src/util/test_resolver_api.c

index 609f797bdb734d297e7f72327f1a67f3ca6401d4..7d87d03a882252df13c3f9c9d141c7281d95f48e 100644 (file)
@@ -117,6 +117,8 @@ diffsCallBack (void *cls,
       {
        int ret;
        char *diffValue;
+
+       diffValue = NULL;
        ret =
          GNUNET_CONFIGURATION_get_value_string (cbData->cfgDiffs, section,
                                                 option, &diffValue);
@@ -127,6 +129,7 @@ diffsCallBack (void *cls,
          }
        else
          cbData->status = 1;
+       GNUNET_free_non_null (diffValue);
        break;
       }
 #if DEBUG
@@ -180,6 +183,7 @@ editConfiguration (struct GNUNET_CONFIGURATION_Handle *cfg, int option)
            GNUNET_CONFIGURATION_set_value_string (diffsCB.cfgDiffs,
                                                   "new-section", key,
                                                   "new-value");
+           GNUNET_free (key);
          }
        break;
       }
@@ -209,12 +213,15 @@ checkDiffs (struct GNUNET_CONFIGURATION_Handle *cfgDefault, int option)
   initDiffsCBData (&cbData);
 
   cfg = GNUNET_CONFIGURATION_create ();
-  GNUNET_CONFIGURATION_load (cfg, NULL);
+  /* load defaults */
+  GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, NULL));
 
   /* Modify configuration and save it */
   cfgDiffs = editConfiguration (cfg, option);
   diffsFileName =
     GNUNET_DISK_mktemp ("gnunet-test-configurations-diffs.conf");
+  if (diffsFileName == NULL)
+    return 1;
   GNUNET_CONFIGURATION_write_diffs (cfgDefault, cfg, diffsFileName);
   GNUNET_CONFIGURATION_destroy (cfg);
 
@@ -225,7 +232,7 @@ checkDiffs (struct GNUNET_CONFIGURATION_Handle *cfgDefault, int option)
   cbData.callBackOption = COMPARE;
   cbData.cfgDiffs = cfgDiffs;
   GNUNET_CONFIGURATION_iterate (cfg, diffsCallBack, &cbData);
-  if ((ret = cbData.status) == 1)
+  if (1 == (ret = cbData.status))
     {
       fprintf (stderr,
               "Incorrect Configuration Diffs: Diffs may contain data not actually edited\n");
@@ -249,6 +256,7 @@ housekeeping:
 #endif
   GNUNET_CONFIGURATION_destroy (cfg);
   GNUNET_CONFIGURATION_destroy (cfgDiffs);
+  GNUNET_free (diffsFileName);
   return ret;
 }
 
index f49d7a79af4eefcc0e5a83cc428809427dd4d071..7cef33e60c0b711d5656e5feebf3ca4cf59f50bd 100644 (file)
@@ -159,6 +159,7 @@ check ()
 {
   int ok = 1 + 2 + 4 + 8;
   char *fn;
+  char *pfx;
   pid_t pid;
   char *const argv[] = { "test-resolver-api",
     "-c",
@@ -171,9 +172,11 @@ check ()
   struct GNUNET_GETOPT_CommandLineOption options[] = {
     GNUNET_GETOPT_OPTION_END
   };
+  pfx = GNUNET_OS_installation_get_path(GNUNET_OS_IPK_BINDIR);
   GNUNET_asprintf(&fn, "%s%cgnunet-service-resolver",
-                  GNUNET_OS_installation_get_path(GNUNET_OS_IPK_BINDIR),
+                  pfx,
                   DIR_SEPARATOR);
+  GNUNET_free (pfx);
   pid = GNUNET_OS_start_process (fn,
                                  "gnunet-service-resolver",
 #if VERBOSE