summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-23 22:16:25 +0200
committerDirk Engling <erdgeist@erdgeist.org>2026-10-23 22:16:25 +0200
commit4ece9d359fd6668bfbc9c4260463f5b5913ae8fc (patch)
tree96d9404ca1d46ea9b92db02765a579f0a74f5fd0
parent280344488f09ff29deb052dfa94ed74668c00b18 (diff)
Avoid returning the result of void functions
-rw-r--r--ot_fullscrape.c15
-rw-r--r--ot_vector.c12
-rw-r--r--trackerlogic.c17
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) {
179 179
180 if (mutex_workqueue_pushchunked(taskid, &iovector)) { 180 if (mutex_workqueue_pushchunked(taskid, &iovector)) {
181 free(iovector.iov_base); 181 free(iovector.iov_base);
182 return mutex_bucket_unlock(bucket, 0); 182 mutex_bucket_unlock(bucket, 0);
183 return;
183 } 184 }
184 /* Allocate a fresh output buffer */ 185 /* Allocate a fresh output buffer */
185 r = iovector.iov_base = malloc(OT_SCRAPE_CHUNK_SIZE); 186 r = iovector.iov_base = malloc(OT_SCRAPE_CHUNK_SIZE);
186 if (!r) 187 if (!r) {
187 return mutex_bucket_unlock(bucket, 0); 188 mutex_bucket_unlock(bucket, 0);
189 return;
190 }
188 191
189 /* re points to low watermark */ 192 /* re points to low watermark */
190 re = r + OT_SCRAPE_CHUNK_SIZE - OT_SCRAPE_MAXENTRYLEN; 193 re = r + OT_SCRAPE_CHUNK_SIZE - OT_SCRAPE_MAXENTRYLEN;
@@ -256,14 +259,16 @@ static void fullscrape_make_gzip(int taskid, ot_tasktype mode) {
256 259
257 if (mutex_workqueue_pushchunked(taskid, &iovector)) { 260 if (mutex_workqueue_pushchunked(taskid, &iovector)) {
258 free(iovector.iov_base); 261 free(iovector.iov_base);
259 return mutex_bucket_unlock(bucket, 0); 262 mutex_bucket_unlock(bucket, 0);
263 return;
260 } 264 }
261 /* Allocate a fresh output buffer */ 265 /* Allocate a fresh output buffer */
262 iovector.iov_base = malloc(OT_SCRAPE_CHUNK_SIZE); 266 iovector.iov_base = malloc(OT_SCRAPE_CHUNK_SIZE);
263 if (!iovector.iov_base) { 267 if (!iovector.iov_base) {
264 fprintf(stderr, "Out of memory trying to claim ouput buffer\n"); 268 fprintf(stderr, "Out of memory trying to claim ouput buffer\n");
265 deflateEnd(&strm); 269 deflateEnd(&strm);
266 return mutex_bucket_unlock(bucket, 0); 270 mutex_bucket_unlock(bucket, 0);
271 return;
267 } 272 }
268 strm.next_out = (uint8_t *)iovector.iov_base; 273 strm.next_out = (uint8_t *)iovector.iov_base;
269 strm.avail_out = OT_SCRAPE_CHUNK_SIZE; 274 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) {
218 for (bucket = 0; bucket < num_buckets_new; ++bucket) { 218 for (bucket = 0; bucket < num_buckets_new; ++bucket) {
219 bucket_list_new[bucket].space = bucket_size_new; 219 bucket_list_new[bucket].space = bucket_size_new;
220 bucket_list_new[bucket].data = malloc(bucket_size_new * peer_size); 220 bucket_list_new[bucket].data = malloc(bucket_size_new * peer_size);
221 if (!bucket_list_new[bucket].data) 221 if (!bucket_list_new[bucket].data) {
222 return vector_clean_list(bucket_list_new, num_buckets_new); 222 vector_clean_list(bucket_list_new, num_buckets_new);
223 return;
224 }
223 } 225 }
224 226
225 /* Now sort them into the correct bucket */ 227 /* Now sort them into the correct bucket */
@@ -232,8 +234,10 @@ void vector_redistribute_buckets(ot_peerlist *peer_list, size_t peer_size) {
232 bucket_dest += vector_hash_peer(peers_old, OT_PEER_COMPARE_SIZE_FROM_PEER_SIZE(peer_size), num_buckets_new); 234 bucket_dest += vector_hash_peer(peers_old, OT_PEER_COMPARE_SIZE_FROM_PEER_SIZE(peer_size), num_buckets_new);
233 if (bucket_dest->size + 1 > bucket_dest->space) { 235 if (bucket_dest->size + 1 > bucket_dest->space) {
234 void *tmp = realloc(bucket_dest->data, peer_size * OT_VECTOR_GROW_RATIO * bucket_dest->space); 236 void *tmp = realloc(bucket_dest->data, peer_size * OT_VECTOR_GROW_RATIO * bucket_dest->space);
235 if (!tmp) 237 if (!tmp) {
236 return vector_clean_list(bucket_list_new, num_buckets_new); 238 vector_clean_list(bucket_list_new, num_buckets_new);
239 return;
240 }
237 bucket_dest->data = tmp; 241 bucket_dest->data = tmp;
238 bucket_dest->space *= OT_VECTOR_GROW_RATIO; 242 bucket_dest->space *= OT_VECTOR_GROW_RATIO;
239 } 243 }
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_
48 ot_torrent *torrent; 48 ot_torrent *torrent;
49 ot_vector *torrents_list = mutex_bucket_lock_by_hash(hash); 49 ot_vector *torrents_list = mutex_bucket_lock_by_hash(hash);
50 50
51 if (!accesslist_hashisvalid(hash)) 51 if (!accesslist_hashisvalid(hash)) {
52 return mutex_bucket_unlock_by_hash(hash, 0); 52 mutex_bucket_unlock_by_hash(hash, 0);
53 return;
54 }
53 55
54 torrent = vector_find_or_insert(torrents_list, (void *)hash, sizeof(ot_torrent), OT_HASH_COMPARE_SIZE, &exactmatch); 56 torrent = vector_find_or_insert(torrents_list, (void *)hash, sizeof(ot_torrent), OT_HASH_COMPARE_SIZE, &exactmatch);
55 if (!torrent || exactmatch) 57 if (!torrent || exactmatch) {
56 return mutex_bucket_unlock_by_hash(hash, 0); 58 mutex_bucket_unlock_by_hash(hash, 0);
59 return;
60 }
57 61
58 /* Create a new torrent entry, then */ 62 /* Create a new torrent entry, then */
59 memset(torrent, 0, sizeof(ot_torrent)); 63 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_
61 65
62 if (!(torrent->peer_list6 = malloc(sizeof(ot_peerlist))) || !(torrent->peer_list4 = malloc(sizeof(ot_peerlist)))) { 66 if (!(torrent->peer_list6 = malloc(sizeof(ot_peerlist))) || !(torrent->peer_list4 = malloc(sizeof(ot_peerlist)))) {
63 vector_remove_torrent(torrents_list, torrent); 67 vector_remove_torrent(torrents_list, torrent);
64 return mutex_bucket_unlock_by_hash(hash, 0); 68 mutex_bucket_unlock_by_hash(hash, 0);
69 return;
65 } 70 }
66 71
67 memset(torrent->peer_list6, 0, sizeof(ot_peerlist)); 72 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_
71 torrent->peer_list6->down_count = down_count; 76 torrent->peer_list6->down_count = down_count;
72 torrent->peer_list4->down_count = down_count; 77 torrent->peer_list4->down_count = down_count;
73 78
74 return mutex_bucket_unlock_by_hash(hash, 1); 79 mutex_bucket_unlock_by_hash(hash, 1);
75} 80}
76 81
77size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstruct *ws, size_t amount) { 82size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstruct *ws, size_t amount) {