gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r12796 - gnunet/src/testing


From: gnunet
Subject: [GNUnet-SVN] r12796 - gnunet/src/testing
Date: Wed, 1 Sep 2010 15:21:03 +0200

Author: nevans
Date: 2010-09-01 15:21:03 +0200 (Wed, 01 Sep 2010)
New Revision: 12796

Modified:
   gnunet/src/testing/test_testing_group_remote.c
   gnunet/src/testing/test_testing_topology.c
   gnunet/src/testing/test_testing_topology_blacklist.c
   gnunet/src/testing/test_testing_topology_churn.c
   gnunet/src/testing/testing.c
   gnunet/src/testing/testing_group.c
Log:
klocwork fixes

Modified: gnunet/src/testing/test_testing_group_remote.c
===================================================================
--- gnunet/src/testing/test_testing_group_remote.c      2010-09-01 13:19:43 UTC 
(rev 12795)
+++ gnunet/src/testing/test_testing_group_remote.c      2010-09-01 13:21:03 UTC 
(rev 12796)
@@ -106,6 +106,7 @@
      const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct GNUNET_TESTING_Host *hosts;
+  struct GNUNET_TESTING_Host *hostpos;
   struct GNUNET_TESTING_Host *temphost;
   char *hostfile;
   struct stat frstat;
@@ -123,12 +124,14 @@
                                              &num_peers))
     num_peers = DEFAULT_NUM_PEERS;
 
+  GNUNET_assert(num_peers > 0 && num_peers < (unsigned long long)-1);
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile",
                                              &hostfile))
     hostfile = NULL;
 
   hosts = NULL;
+  data = NULL;
   if (hostfile != NULL)
     {
       if (GNUNET_OK != GNUNET_DISK_file_test (hostfile))
@@ -188,6 +191,14 @@
                                      NULL,
                                      NULL,
                                      hosts);
+  hostpos = hosts;
+  while (hostpos != NULL)
+    {
+      temphost = hostpos->next;
+      GNUNET_free(hostpos);
+      hostpos = temphost;
+    }
+  GNUNET_free_non_null(data);
   GNUNET_assert (pg != NULL);
 }
 

Modified: gnunet/src/testing/test_testing_topology.c
===================================================================
--- gnunet/src/testing/test_testing_topology.c  2010-09-01 13:19:43 UTC (rev 
12795)
+++ gnunet/src/testing/test_testing_topology.c  2010-09-01 13:21:03 UTC (rev 
12796)
@@ -200,8 +200,6 @@
               "Called finish testing, stopping daemons.\n");
 #endif
 
-  int count;
-  count = 0;
   pos = test_messages;
   while (pos != NULL)
     {
@@ -377,6 +375,7 @@
       GNUNET_SCHEDULER_cancel (sched, die_task);
       GNUNET_asprintf(&dotOutFileNameFinished, "%s.dot", "final_topology");
       dotOutFileFinished = fopen (dotOutFileNameFinished, "w");
+      GNUNET_free(dotOutFileNameFinished);
       if (dotOutFileFinished != NULL)
       {
         fprintf(dotOutFileFinished, "strict graph G {\n");
@@ -1001,6 +1000,7 @@
                                            
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START 
* num_peers),
                                            &end_badly, "didn't generate all 
hostkeys within a reasonable amount of time!!!");
 
+  GNUNET_assert(num_peers > 0 && num_peers < (unsigned int)-1);
   pg = GNUNET_TESTING_daemons_start (sched, cfg,
                                      peers_left, 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START 
* num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL,
                                      &topology_callback, NULL, NULL);
@@ -1046,6 +1046,7 @@
   char *our_binary_name;
 
   binary_start_pos = rindex(argv[0], '/');
+  GNUNET_assert(binary_start_pos != NULL);
   topology_string = strstr (binary_start_pos,
                            "_topology");
   GNUNET_assert (topology_string != NULL);

Modified: gnunet/src/testing/test_testing_topology_blacklist.c
===================================================================
--- gnunet/src/testing/test_testing_topology_blacklist.c        2010-09-01 
13:19:43 UTC (rev 12795)
+++ gnunet/src/testing/test_testing_topology_blacklist.c        2010-09-01 
13:21:03 UTC (rev 12796)
@@ -470,6 +470,7 @@
 
   main_cfg = cfg;
 
+  GNUNET_assert(num_peers > 0 && num_peers < (unsigned int)-1);
   peers_left = num_peers;
 
   /* For this specific test we only really want a CLIQUE topology as the

Modified: gnunet/src/testing/test_testing_topology_churn.c
===================================================================
--- gnunet/src/testing/test_testing_topology_churn.c    2010-09-01 13:19:43 UTC 
(rev 12795)
+++ gnunet/src/testing/test_testing_topology_churn.c    2010-09-01 13:21:03 UTC 
(rev 12796)
@@ -266,6 +266,7 @@
   main_cfg = cfg;
 
   peers_left = num_peers;
+  GNUNET_assert(num_peers > 0 && num_peers < (unsigned int)-1);
 
   /* For this specific test we only really want a CLIQUE topology as the
    * overlay allowed topology, and a RING topology as the underlying connection

Modified: gnunet/src/testing/testing.c
===================================================================
--- gnunet/src/testing/testing.c        2010-09-01 13:19:43 UTC (rev 12795)
+++ gnunet/src/testing/testing.c        2010-09-01 13:21:03 UTC (rev 12796)
@@ -1338,13 +1338,15 @@
 send_hello(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct ConnectContext *ctx = cls;
-
+  struct GNUNET_MessageHeader *hello;
   ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK;
   if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
     return;
-  if (ctx->d1->hello != NULL)
+  if ((ctx->d1->hello != NULL) && (NULL != 
GNUNET_HELLO_get_header(ctx->d1->hello)))
     {
-      GNUNET_TRANSPORT_offer_hello (ctx->d2th, 
GNUNET_HELLO_get_header(ctx->d1->hello));
+      hello = GNUNET_HELLO_get_header(ctx->d1->hello);
+      GNUNET_assert(hello != NULL);
+      GNUNET_TRANSPORT_offer_hello (ctx->d2th, hello);
       ctx->timeout_hello = GNUNET_TIME_relative_add(ctx->timeout_hello,
                                                    
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,
                                                                                
  500));

Modified: gnunet/src/testing/testing_group.c
===================================================================
--- gnunet/src/testing/testing_group.c  2010-09-01 13:19:43 UTC (rev 12795)
+++ gnunet/src/testing/testing_group.c  2010-09-01 13:21:03 UTC (rev 12796)
@@ -1306,6 +1306,7 @@
   unsigned int distance;
   double probability, random, percentage;
   unsigned int smallWorldConnections;
+  unsigned int small_world_it;
   char *p_string;
   int connect_attempts;
   square = floor (sqrt (pg->total));
@@ -1326,6 +1327,13 @@
                    "TESTING");
       GNUNET_free (p_string);
     }
+  if (percentage < 0.0)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  _("Invalid value `%s' for option `%s' in section `%s': got 
%f, needed value greater than 0\n"),
+                  "PERCENTAGE", "TESTING", percentage);
+      percentage = 0.5;
+    }
   probability = 0.5; /* FIXME: default percentage? */
   if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(pg->cfg,
                                                         "TESTING",
@@ -1392,7 +1400,9 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Total connections added thus far: 
%u!\n"), connect_attempts);
 #endif
   smallWorldConnections = 0;
-  for (i = 0; i < (int) (natLog * percentage); i++)
+  small_world_it = (unsigned int)(natLog * percentage);
+  GNUNET_assert(small_world_it > 0 && small_world_it < (unsigned int)-1);
+  for (i = 0; i < small_world_it; i++)
     {
       for (j = 0; j < pg->total; j++)
         {
@@ -2247,7 +2257,6 @@
   int unblacklisted_connections;
 
   GNUNET_assert (pg->notify_connection != NULL);
-  ret = GNUNET_OK;
 
   switch (topology)
     {
@@ -3797,22 +3806,26 @@
     }
   }
 
+  GNUNET_assert(running >= voff);
   for (i = 0; i < voff; i++)
   {
 #if DEBUG_CHURN
     GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Stopping peer %d!\n", 
running_permute[i]);
 #endif
+    GNUNET_assert(running_arr != NULL);
     GNUNET_TESTING_daemon_stop 
(pg->peers[running_arr[running_permute[i]]].daemon,
                                timeout, 
                                &churn_stop_callback, churn_ctx, 
                                GNUNET_NO, GNUNET_YES);
   }
 
+  GNUNET_assert(stopped >= von);
   for (i = 0; i < von; i++)
     {
 #if DEBUG_CHURN
       GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Starting up peer %d!\n", 
stopped_permute[i]);
 #endif
+      GNUNET_assert(stopped_arr != NULL);
       
GNUNET_TESTING_daemon_start_stopped(pg->peers[stopped_arr[stopped_permute[i]]].daemon,
 
                                          timeout, &churn_start_callback, 
churn_ctx);
   }
@@ -3964,9 +3977,10 @@
 schedule_shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * 
tc)
 {
   struct PeerShutdownContext *peer_shutdown_ctx = cls;
-  struct ShutdownContext *shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
+  struct ShutdownContext *shutdown_ctx;
 
   GNUNET_assert(peer_shutdown_ctx != NULL);
+  shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
   GNUNET_assert(shutdown_ctx != NULL);
 
   if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]