From 4ece9d359fd6668bfbc9c4260463f5b5913ae8fc Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Fri, 23 Oct 2026 22:16:25 +0200 Subject: Avoid returning the result of void functions --- ot_fullscrape.c | 15 ++++++++++----- ot_vector.c | 12 ++++++++---- trackerlogic.c | 17 +++++++++++------ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/ot_fullscrape.c b/ot_fullscrape.c index 39f51ec..ec7f2df 100644 --- a/ot_fullscrape.c +++ b/ot_fullscrape.c @@ -179,12 +179,15 @@ static void fullscrape_make(int taskid, ot_tasktype mode) { if (mutex_workqueue_pushchunked(taskid, &iovector)) { free(iovector.iov_base); - return mutex_bucket_unlock(bucket, 0); + mutex_bucket_unlock(bucket, 0); + return; } /* Allocate a fresh output buffer */ r = iovector.iov_base = malloc(OT_SCRAPE_CHUNK_SIZE); - if (!r) - return mutex_bucket_unlock(bucket, 0); + if (!r) { + mutex_bucket_unlock(bucket, 0); + return; + } /* re points to low watermark */ re = r + OT_SCRAPE_CHUNK_SIZE - OT_SCRAPE_MAXENTRYLEN; @@ -256,14 +259,16 @@ static void fullscrape_make_gzip(int taskid, ot_tasktype mode) { if (mutex_workqueue_pushchunked(taskid, &iovector)) { free(iovector.iov_base); - return mutex_bucket_unlock(bucket, 0); + mutex_bucket_unlock(bucket, 0); + return; } /* Allocate a fresh output buffer */ iovector.iov_base = malloc(OT_SCRAPE_CHUNK_SIZE); if (!iovector.iov_base) { fprintf(stderr, "Out of memory trying to claim ouput buffer\n"); deflateEnd(&strm); - return mutex_bucket_unlock(bucket, 0); + mutex_bucket_unlock(bucket, 0); + return; } strm.next_out = (uint8_t *)iovector.iov_base; strm.avail_out = OT_SCRAPE_CHUNK_SIZE; diff --git a/ot_vector.c b/ot_vector.c index 7f661aa..e3c3d3f 100644 --- a/ot_vector.c +++ b/ot_vector.c @@ -218,8 +218,10 @@ void vector_redistribute_buckets(ot_peerlist *peer_list, size_t peer_size) { for (bucket = 0; bucket < num_buckets_new; ++bucket) { bucket_list_new[bucket].space = bucket_size_new; bucket_list_new[bucket].data = malloc(bucket_size_new * peer_size); - if (!bucket_list_new[bucket].data) - return vector_clean_list(bucket_list_new, num_buckets_new); + if (!bucket_list_new[bucket].data) { + vector_clean_list(bucket_list_new, num_buckets_new); + return; + } } /* Now sort them into the correct bucket */ @@ -232,8 +234,10 @@ void vector_redistribute_buckets(ot_peerlist *peer_list, size_t peer_size) { bucket_dest += vector_hash_peer(peers_old, OT_PEER_COMPARE_SIZE_FROM_PEER_SIZE(peer_size), num_buckets_new); if (bucket_dest->size + 1 > bucket_dest->space) { void *tmp = realloc(bucket_dest->data, peer_size * OT_VECTOR_GROW_RATIO * bucket_dest->space); - if (!tmp) - return vector_clean_list(bucket_list_new, num_buckets_new); + if (!tmp) { + vector_clean_list(bucket_list_new, num_buckets_new); + return; + } bucket_dest->data = tmp; bucket_dest->space *= OT_VECTOR_GROW_RATIO; } diff --git a/trackerlogic.c b/trackerlogic.c index 94ec71a..a76064e 100644 --- a/trackerlogic.c +++ b/trackerlogic.c @@ -48,12 +48,16 @@ void add_torrent_from_saved_state(ot_hash const hash, ot_time base, size_t down_ ot_torrent *torrent; ot_vector *torrents_list = mutex_bucket_lock_by_hash(hash); - if (!accesslist_hashisvalid(hash)) - return mutex_bucket_unlock_by_hash(hash, 0); + if (!accesslist_hashisvalid(hash)) { + mutex_bucket_unlock_by_hash(hash, 0); + return; + } torrent = vector_find_or_insert(torrents_list, (void *)hash, sizeof(ot_torrent), OT_HASH_COMPARE_SIZE, &exactmatch); - if (!torrent || exactmatch) - return mutex_bucket_unlock_by_hash(hash, 0); + if (!torrent || exactmatch) { + mutex_bucket_unlock_by_hash(hash, 0); + return; + } /* Create a new torrent entry, then */ memset(torrent, 0, sizeof(ot_torrent)); @@ -61,7 +65,8 @@ void add_torrent_from_saved_state(ot_hash const hash, ot_time base, size_t down_ if (!(torrent->peer_list6 = malloc(sizeof(ot_peerlist))) || !(torrent->peer_list4 = malloc(sizeof(ot_peerlist)))) { vector_remove_torrent(torrents_list, torrent); - return mutex_bucket_unlock_by_hash(hash, 0); + mutex_bucket_unlock_by_hash(hash, 0); + return; } memset(torrent->peer_list6, 0, sizeof(ot_peerlist)); @@ -71,7 +76,7 @@ void add_torrent_from_saved_state(ot_hash const hash, ot_time base, size_t down_ torrent->peer_list6->down_count = down_count; torrent->peer_list4->down_count = down_count; - return mutex_bucket_unlock_by_hash(hash, 1); + mutex_bucket_unlock_by_hash(hash, 1); } size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstruct *ws, size_t amount) { -- cgit v1.3