gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r35905 - gnunet/src/rps


From: gnunet
Subject: [GNUnet-SVN] r35905 - gnunet/src/rps
Date: Wed, 10 Jun 2015 13:01:47 +0200

Author: ch3
Date: 2015-06-10 13:01:46 +0200 (Wed, 10 Jun 2015)
New Revision: 35905

Modified:
   gnunet/src/rps/gnunet-service-rps.c
   gnunet/src/rps/gnunet-service-rps_sampler.c
   gnunet/src/rps/rps-test_util.c
Log:
-fix coverity

Modified: gnunet/src/rps/gnunet-service-rps.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps.c 2015-06-09 19:34:53 UTC (rev 35904)
+++ gnunet/src/rps/gnunet-service-rps.c 2015-06-10 11:01:46 UTC (rev 35905)
@@ -1091,8 +1091,10 @@
 {
   unsigned int i;
   if (NULL == peer_map)
-    peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers + 1,
-                                                     GNUNET_NO);
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         "Trying to add peers to an empty peermap.\n");
+    return;
+
   for (i = 0 ; i < num_peers ; i++)
   {
     GNUNET_CONTAINER_multipeermap_put (peer_map,
@@ -1461,6 +1463,10 @@
   { /* We attack one single well-known peer - simply ignore */
     return GNUNET_OK;
   }
+  else
+  {
+    GNUNET_free (tmp_att_peer);
+  }
 
   #endif /* ENABLE_MALICIOUS */
 
@@ -1951,6 +1957,7 @@
     }
 
     /* Send PULLs to some peers to learn about additional peers to attack */
+    tmp_att_peer = att_peer_index;
     for (i = 0 ; i < num_pushes * alpha ; i++)
     {
       if (att_peers_tail == tmp_att_peer)
@@ -2597,7 +2604,11 @@
   gossip_list_size = 0;
 
   /* file_name_view_log */
-  GNUNET_DISK_directory_create ("/tmp/rps/");
+  if (GNUNET_OK != GNUNET_DISK_directory_create ("/tmp/rps/"))
+  {
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         "Failed to create directory /tmp/rps/\n");
+  }
 
   size = (14 + strlen (GNUNET_i2s_full (&own_identity)) + 1) * sizeof (char);
   file_name_view_log = GNUNET_malloc (size);

Modified: gnunet/src/rps/gnunet-service-rps_sampler.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps_sampler.c 2015-06-09 19:34:53 UTC (rev 
35904)
+++ gnunet/src/rps/gnunet-service-rps_sampler.c 2015-06-10 11:01:46 UTC (rev 
35905)
@@ -600,9 +600,6 @@
 sampler_empty (struct RPS_Sampler *sampler)
 {
   sampler_resize (sampler, 0);
-  GNUNET_array_grow (sampler->trash_can,
-                     sampler->trash_can_size,
-                     0);
 }
 
 
@@ -923,6 +920,8 @@
                               void *cls, uint32_t num_peers)
 {
   GNUNET_assert (0 != sampler->sampler_size);
+  if (0 == num_peers)
+    return;
 
   // TODO check if we have too much (distinct) sampled peers
   uint32_t i;

Modified: gnunet/src/rps/rps-test_util.c
===================================================================
--- gnunet/src/rps/rps-test_util.c      2015-06-09 19:34:53 UTC (rev 35904)
+++ gnunet/src/rps/rps-test_util.c      2015-06-10 11:01:46 UTC (rev 35905)
@@ -82,6 +82,11 @@
          "Unable to write to file! (Size: %u, size2: %u)\n",
          size,
          size2);
+
+    if (GNUNET_YES != GNUNET_DISK_file_close (f))
+      LOG (GNUNET_ERROR_TYPE_WARNING,
+           "Unable to close file\n");
+
     return;
   }
 
@@ -149,10 +154,13 @@
   if (0 > size)
     LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to create name_buf\n");
 
-  GNUNET_DISK_directory_create (prefix);
+  if (GNUNET_YES != GNUNET_DISK_directory_create (prefix))
+  {
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         "Could not create directory %s.\n",
+         prefix);
+  }
 
-  file_name = GNUNET_malloc (strlen (name_buf) + 6);
-
   if (NULL == (file_name = GNUNET_DISK_mktemp (name_buf)))
         LOG (GNUNET_ERROR_TYPE_WARNING, "Could not create file\n");
 




reply via email to

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