summaryrefslogtreecommitdiff
path: root/ot_stats.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-04-03 01:40:39 +0200
committerDirk Engling <erdgeist@erdgeist.org>2026-04-03 01:40:39 +0200
commite4eb716d2688f5c2d4615d79ad5f4f1eb50a9343 (patch)
tree5612056173478fecaad0a030195b6ed2f399df4d /ot_stats.c
parentb20b0b89264e9d28ab873b8b1cc9ba73cdb58aeb (diff)
turn all int offsets into size_t
Diffstat (limited to 'ot_stats.c')
-rw-r--r--ot_stats.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/ot_stats.c b/ot_stats.c
index b2eaec9..3d64bce 100644
--- a/ot_stats.c
+++ b/ot_stats.c
@@ -38,7 +38,7 @@
38#endif 38#endif
39 39
40/* Forward declaration */ 40/* Forward declaration */
41static void stats_make(int *iovec_entries, struct iovec **iovector, ot_tasktype mode); 41static void stats_make(size_t *iovec_entries, struct iovec **iovector, ot_tasktype mode);
42#define OT_STATS_TMPSIZE 8192 42#define OT_STATS_TMPSIZE 8192
43 43
44/* Clumsy counters... to be rethought */ 44/* Clumsy counters... to be rethought */
@@ -113,7 +113,7 @@ static int stat_increase_network_count(stats_network_node **pnode, int depth, ui
113} 113}
114 114
115static int stats_shift_down_network_count(stats_network_node **node, int depth, int shift) { 115static int stats_shift_down_network_count(stats_network_node **node, int depth, int shift) {
116 int i, rest = 0; 116 size_t i, rest = 0;
117 117
118 if (!*node) 118 if (!*node)
119 return 0; 119 return 0;
@@ -134,8 +134,7 @@ static int stats_shift_down_network_count(stats_network_node **node, int depth,
134 134
135static size_t stats_get_highscore_networks(stats_network_node *node, int depth, ot_ip6 node_value, size_t *scores, ot_ip6 *networks, int network_count, 135static size_t stats_get_highscore_networks(stats_network_node *node, int depth, ot_ip6 node_value, size_t *scores, ot_ip6 *networks, int network_count,
136 int limit) { 136 int limit) {
137 size_t score = 0; 137 size_t i, score = 0;
138 int i;
139 138
140 if (!node) 139 if (!node)
141 return 0; 140 return 0;
@@ -195,7 +194,7 @@ static size_t stats_return_busy_networks(char *reply, stats_network_node *tree,
195 ot_ip6 networks[amount]; 194 ot_ip6 networks[amount];
196 ot_ip6 node_value; 195 ot_ip6 node_value;
197 size_t scores[amount]; 196 size_t scores[amount];
198 int i; 197 size_t i;
199 char *r = reply; 198 char *r = reply;
200 199
201 memset(scores, 0, sizeof(scores)); 200 memset(scores, 0, sizeof(scores));
@@ -225,8 +224,7 @@ static size_t stats_return_busy_networks(char *reply, stats_network_node *tree,
225static size_t stats_slash24s_txt(char *reply, size_t amount) { 224static size_t stats_slash24s_txt(char *reply, size_t amount) {
226 stats_network_node *slash24s_network_counters_root = NULL; 225 stats_network_node *slash24s_network_counters_root = NULL;
227 char *r = reply; 226 char *r = reply;
228 int bucket; 227 size_t i, bucket, peer_size = OT_PEER_SIZE4;
229 size_t i, peer_size = OT_PEER_SIZE4;
230 228
231 for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) { 229 for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) {
232 ot_vector *torrents_list = mutex_bucket_lock(bucket); 230 ot_vector *torrents_list = mutex_bucket_lock(bucket);
@@ -318,11 +316,10 @@ typedef struct {
318} ot_record; 316} ot_record;
319 317
320/* Fetches stats from tracker */ 318/* Fetches stats from tracker */
321size_t stats_top_txt(char *reply, int amount) { 319size_t stats_top_txt(char *reply, size_t amount) {
322 size_t j; 320 size_t j, idx, bucket;
323 ot_record top100s[100], top100c[100], top100l[100]; 321 ot_record top100s[100], top100c[100], top100l[100];
324 char *r = reply, hex_out[42]; 322 char *r = reply, hex_out[42];
325 int idx, bucket;
326 323
327 if (amount > 100) 324 if (amount > 100)
328 amount = 100; 325 amount = 100;
@@ -368,15 +365,15 @@ size_t stats_top_txt(char *reply, int amount) {
368 return 0; 365 return 0;
369 } 366 }
370 367
371 r += sprintf(r, "Top %d torrents by peers:\n", amount); 368 r += sprintf(r, "Top %zd torrents by peers:\n", amount);
372 for (idx = 0; idx < amount; ++idx) 369 for (idx = 0; idx < amount; ++idx)
373 if (top100c[idx].val) 370 if (top100c[idx].val)
374 r += sprintf(r, "\t%zd\t%s\n", top100c[idx].val, to_hex(hex_out, top100c[idx].hash)); 371 r += sprintf(r, "\t%zd\t%s\n", top100c[idx].val, to_hex(hex_out, top100c[idx].hash));
375 r += sprintf(r, "Top %d torrents by seeds:\n", amount); 372 r += sprintf(r, "Top %zd torrents by seeds:\n", amount);
376 for (idx = 0; idx < amount; ++idx) 373 for (idx = 0; idx < amount; ++idx)
377 if (top100s[idx].val) 374 if (top100s[idx].val)
378 r += sprintf(r, "\t%zd\t%s\n", top100s[idx].val, to_hex(hex_out, top100s[idx].hash)); 375 r += sprintf(r, "\t%zd\t%s\n", top100s[idx].val, to_hex(hex_out, top100s[idx].hash));
379 r += sprintf(r, "Top %d torrents by leechers:\n", amount); 376 r += sprintf(r, "Top %zd torrents by leechers:\n", amount);
380 for (idx = 0; idx < amount; ++idx) 377 for (idx = 0; idx < amount; ++idx)
381 if (top100l[idx].val) 378 if (top100l[idx].val)
382 r += sprintf(r, "\t%zd\t%s\n", top100l[idx].val, to_hex(hex_out, top100l[idx].hash)); 379 r += sprintf(r, "\t%zd\t%s\n", top100l[idx].val, to_hex(hex_out, top100l[idx].hash));
@@ -477,7 +474,7 @@ static size_t stats_return_numwants(char *reply) {
477#endif 474#endif
478 475
479#ifdef WANT_FULLLOG_NETWORKS 476#ifdef WANT_FULLLOG_NETWORKS
480static void stats_return_fulllog(int *iovec_entries, struct iovec **iovector, char *r) { 477static void stats_return_fulllog(size_t *iovec_entries, struct iovec **iovector, char *r) {
481 ot_log *loglist = g_logchain_first, *llnext; 478 ot_log *loglist = g_logchain_first, *llnext;
482 char *re = r + OT_STATS_TMPSIZE; 479 char *re = r + OT_STATS_TMPSIZE;
483 480
@@ -591,7 +588,7 @@ size_t return_stats_for_tracker(char *reply, int mode, int format) {
591 } 588 }
592} 589}
593 590
594static void stats_make(int *iovec_entries, struct iovec **iovector, ot_tasktype mode) { 591static void stats_make(size_t *iovec_entries, struct iovec **iovector, ot_tasktype mode) {
595 char *r; 592 char *r;
596 593
597 *iovec_entries = 0; 594 *iovec_entries = 0;
@@ -757,7 +754,7 @@ void stats_cleanup() {
757} 754}
758 755
759static void *stats_worker(void *args) { 756static void *stats_worker(void *args) {
760 int iovec_entries; 757 size_t iovec_entries;
761 struct iovec *iovector; 758 struct iovec *iovector;
762 759
763 (void)args; 760 (void)args;