From b001bc189b7cb51aa8b41a2b9493530395e6a909 Mon Sep 17 00:00:00 2001 From: Julius Bünger Date: Sat, 27 Mar 2021 01:23:46 +0100 Subject: -fix coverity issues wrt rps --- src/rps/gnunet-rps-profiler.c | 7 ++++--- src/rps/gnunet-service-rps.c | 13 ++++++++++--- src/rps/gnunet-service-rps_custommap.c | 9 ++++++--- 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; -- cgit v1.2.3