diff options
author | Julius Bünger <buenger@mytum.de> | 2015-06-10 11:01:46 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2015-06-10 11:01:46 +0000 |
commit | 11ca82f4300e03a0fd82e1507b3f1fc9aefbbabd (patch) | |
tree | 1578b63dfc3c429208d686efd4e3ec8331255d71 /src/rps | |
parent | 83da6bcc7751ee11905e3f8f3adcfe33d2b926bc (diff) | |
download | gnunet-11ca82f4300e03a0fd82e1507b3f1fc9aefbbabd.tar.gz gnunet-11ca82f4300e03a0fd82e1507b3f1fc9aefbbabd.zip |
-fix coverity
Diffstat (limited to 'src/rps')
-rw-r--r-- | src/rps/gnunet-service-rps.c | 17 | ||||
-rw-r--r-- | src/rps/gnunet-service-rps_sampler.c | 5 | ||||
-rw-r--r-- | src/rps/rps-test_util.c | 14 |
3 files changed, 27 insertions, 9 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 83e06c2eb..7ad916840 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -1091,8 +1091,10 @@ add_peer_array_to_set (const struct GNUNET_PeerIdentity *peer_array, | |||
1091 | { | 1091 | { |
1092 | unsigned int i; | 1092 | unsigned int i; |
1093 | if (NULL == peer_map) | 1093 | if (NULL == peer_map) |
1094 | peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers + 1, | 1094 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1095 | GNUNET_NO); | 1095 | "Trying to add peers to an empty peermap.\n"); |
1096 | return; | ||
1097 | |||
1096 | for (i = 0 ; i < num_peers ; i++) | 1098 | for (i = 0 ; i < num_peers ; i++) |
1097 | { | 1099 | { |
1098 | GNUNET_CONTAINER_multipeermap_put (peer_map, | 1100 | GNUNET_CONTAINER_multipeermap_put (peer_map, |
@@ -1461,6 +1463,10 @@ handle_peer_push (void *cls, | |||
1461 | { /* We attack one single well-known peer - simply ignore */ | 1463 | { /* We attack one single well-known peer - simply ignore */ |
1462 | return GNUNET_OK; | 1464 | return GNUNET_OK; |
1463 | } | 1465 | } |
1466 | else | ||
1467 | { | ||
1468 | GNUNET_free (tmp_att_peer); | ||
1469 | } | ||
1464 | 1470 | ||
1465 | #endif /* ENABLE_MALICIOUS */ | 1471 | #endif /* ENABLE_MALICIOUS */ |
1466 | 1472 | ||
@@ -1951,6 +1957,7 @@ do_mal_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1951 | } | 1957 | } |
1952 | 1958 | ||
1953 | /* Send PULLs to some peers to learn about additional peers to attack */ | 1959 | /* Send PULLs to some peers to learn about additional peers to attack */ |
1960 | tmp_att_peer = att_peer_index; | ||
1954 | for (i = 0 ; i < num_pushes * alpha ; i++) | 1961 | for (i = 0 ; i < num_pushes * alpha ; i++) |
1955 | { | 1962 | { |
1956 | if (att_peers_tail == tmp_att_peer) | 1963 | if (att_peers_tail == tmp_att_peer) |
@@ -2597,7 +2604,11 @@ run (void *cls, | |||
2597 | gossip_list_size = 0; | 2604 | gossip_list_size = 0; |
2598 | 2605 | ||
2599 | /* file_name_view_log */ | 2606 | /* file_name_view_log */ |
2600 | GNUNET_DISK_directory_create ("/tmp/rps/"); | 2607 | if (GNUNET_OK != GNUNET_DISK_directory_create ("/tmp/rps/")) |
2608 | { | ||
2609 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
2610 | "Failed to create directory /tmp/rps/\n"); | ||
2611 | } | ||
2601 | 2612 | ||
2602 | size = (14 + strlen (GNUNET_i2s_full (&own_identity)) + 1) * sizeof (char); | 2613 | size = (14 + strlen (GNUNET_i2s_full (&own_identity)) + 1) * sizeof (char); |
2603 | file_name_view_log = GNUNET_malloc (size); | 2614 | file_name_view_log = GNUNET_malloc (size); |
diff --git a/src/rps/gnunet-service-rps_sampler.c b/src/rps/gnunet-service-rps_sampler.c index 88709d465..ed3677e8c 100644 --- a/src/rps/gnunet-service-rps_sampler.c +++ b/src/rps/gnunet-service-rps_sampler.c | |||
@@ -600,9 +600,6 @@ static void | |||
600 | sampler_empty (struct RPS_Sampler *sampler) | 600 | sampler_empty (struct RPS_Sampler *sampler) |
601 | { | 601 | { |
602 | sampler_resize (sampler, 0); | 602 | sampler_resize (sampler, 0); |
603 | GNUNET_array_grow (sampler->trash_can, | ||
604 | sampler->trash_can_size, | ||
605 | 0); | ||
606 | } | 603 | } |
607 | 604 | ||
608 | 605 | ||
@@ -923,6 +920,8 @@ RPS_sampler_get_n_rand_peers (struct RPS_Sampler *sampler, | |||
923 | void *cls, uint32_t num_peers) | 920 | void *cls, uint32_t num_peers) |
924 | { | 921 | { |
925 | GNUNET_assert (0 != sampler->sampler_size); | 922 | GNUNET_assert (0 != sampler->sampler_size); |
923 | if (0 == num_peers) | ||
924 | return; | ||
926 | 925 | ||
927 | // TODO check if we have too much (distinct) sampled peers | 926 | // TODO check if we have too much (distinct) sampled peers |
928 | uint32_t i; | 927 | uint32_t i; |
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c index a3354b0ac..5ba477bb7 100644 --- a/src/rps/rps-test_util.c +++ b/src/rps/rps-test_util.c | |||
@@ -82,6 +82,11 @@ to_file_ (char *file_name, char *line) | |||
82 | "Unable to write to file! (Size: %u, size2: %u)\n", | 82 | "Unable to write to file! (Size: %u, size2: %u)\n", |
83 | size, | 83 | size, |
84 | size2); | 84 | size2); |
85 | |||
86 | if (GNUNET_YES != GNUNET_DISK_file_close (f)) | ||
87 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
88 | "Unable to close file\n"); | ||
89 | |||
85 | return; | 90 | return; |
86 | } | 91 | } |
87 | 92 | ||
@@ -149,9 +154,12 @@ create_file (const char *name) | |||
149 | if (0 > size) | 154 | if (0 > size) |
150 | LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to create name_buf\n"); | 155 | LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to create name_buf\n"); |
151 | 156 | ||
152 | GNUNET_DISK_directory_create (prefix); | 157 | if (GNUNET_YES != GNUNET_DISK_directory_create (prefix)) |
153 | 158 | { | |
154 | file_name = GNUNET_malloc (strlen (name_buf) + 6); | 159 | LOG (GNUNET_ERROR_TYPE_WARNING, |
160 | "Could not create directory %s.\n", | ||
161 | prefix); | ||
162 | } | ||
155 | 163 | ||
156 | if (NULL == (file_name = GNUNET_DISK_mktemp (name_buf))) | 164 | if (NULL == (file_name = GNUNET_DISK_mktemp (name_buf))) |
157 | LOG (GNUNET_ERROR_TYPE_WARNING, "Could not create file\n"); | 165 | LOG (GNUNET_ERROR_TYPE_WARNING, "Could not create file\n"); |