summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2021-03-27 01:23:46 +0100
committerJulius Bünger <buenger@mytum.de>2021-03-27 01:23:46 +0100
commitb001bc189b7cb51aa8b41a2b9493530395e6a909 (patch)
treeb51a9477077ad04c6ecef0655c4b61b51d064339
parent33054bb2a8d6272e2f137e8be1833ff9e469c177 (diff)
-fix coverity issues wrt rps
-rw-r--r--src/rps/gnunet-rps-profiler.c7
-rw-r--r--src/rps/gnunet-service-rps.c13
-rw-r--r--src/rps/gnunet-service-rps_custommap.c9
3 files changed, 20 insertions, 9 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 82aeffb79..908dcca17 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -3067,9 +3067,10 @@ run (void *cls,
}
else
{
- duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
- (timeout.rel_value_us / 1000000)
- * 0.75);
+ duration = GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_SECONDS,
+ ( (double) timeout.rel_value_us / (double) 1000000)
+ * 0.75);
}
}
else
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index dc4c5dab7..cccd1a4b3 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -2637,7 +2637,7 @@ insert_in_sampler (void *cls,
}
#ifdef TO_FILE
sub->num_observed_peers++;
- GNUNET_CONTAINER_multipeermap_put
+ (void) GNUNET_CONTAINER_multipeermap_put
(sub->observed_unique_peers,
peer,
NULL,
@@ -2836,13 +2836,20 @@ cleanup_destroyed_channel (void *cls,
(void) channel;
channel_ctx->channel = NULL;
- remove_channel_ctx (channel_ctx);
if ((NULL != peer_ctx) &&
(peer_ctx->send_channel_ctx == channel_ctx) &&
- (GNUNET_YES == check_sending_channel_needed (channel_ctx->peer_ctx)) )
+ (GNUNET_YES == check_sending_channel_needed (peer_ctx)) )
{
+ remove_channel_ctx (channel_ctx);
remove_peer (peer_ctx->sub, &peer_ctx->peer_id);
}
+ else
+ {
+ /* We need this if-else construct because we need to make sure the channel
+ * (context) is cleaned up before removing the peer, but still neet to
+ * compare it while checking the condition */
+ remove_channel_ctx (channel_ctx);
+ }
}
diff --git a/src/rps/gnunet-service-rps_custommap.c b/src/rps/gnunet-service-rps_custommap.c
index 54e361d32..392c29397 100644
--- a/src/rps/gnunet-service-rps_custommap.c
+++ b/src/rps/gnunet-service-rps_custommap.c
@@ -206,6 +206,7 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map,
struct GNUNET_PeerIdentity *p;
uint32_t *last_index;
struct GNUNET_PeerIdentity *last_p;
+ int ret;
if (GNUNET_NO == CustomPeerMap_contains_peer (c_peer_map,
peer))
@@ -234,9 +235,11 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map,
last_p);
GNUNET_assert (NULL != last_index);
GNUNET_assert (CustomPeerMap_size (c_peer_map) == *last_index);
- GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map,
- *index, last_p,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+ ret = GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map,
+ *index,
+ last_p,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+ GNUNET_assert (GNUNET_OK == ret);
GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map,
*last_index);
*last_index = *index;