X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftop.c;h=8d9ffb09fe9da5edaa24bca1024f2b3143522483;hb=3a316823b971396a428f020f401b9fe41252d98d;hp=fe6f384eb2698a016903e101f6c92b49d7864c8c;hpb=18646deca120f0ccc3bfad643dba83547ecc2f20;p=tinc diff --git a/src/top.c b/src/top.c index fe6f384e..8d9ffb09 100644 --- a/src/top.c +++ b/src/top.c @@ -89,7 +89,7 @@ static bool update(int fd) { for list_each(nodestats_t, ns, &node_list) ns->known = false; - while(recvline(fd, line, sizeof line)) { + while(recvline(fd, line, sizeof(line))) { int n = sscanf(line, "%d %d %4095s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, &code, &req, name, &in_packets, &in_bytes, &out_packets, &out_bytes); if(n == 2) @@ -108,7 +108,7 @@ static bool update(int fd) { found = ns; break; } else { - found = xzalloc(sizeof *found); + found = xzalloc(sizeof(*found)); found->name = xstrdup(name); list_insert_before(&node_list, node, found); changed = true; @@ -117,7 +117,7 @@ static bool update(int fd) { } if(!found) { - found = xzalloc(sizeof *found); + found = xzalloc(sizeof(*found)); found->name = xstrdup(name); list_insert_tail(&node_list, found); changed = true; @@ -166,33 +166,40 @@ static int sortfunc(const void *a, const void *b) { result = -cmpu64(na->in_packets, nb->in_packets); else result = -cmpfloat(na->in_packets_rate, nb->in_packets_rate); + break; case 2: if(cumulative) result = -cmpu64(na->in_bytes, nb->in_bytes); else result = -cmpfloat(na->in_bytes_rate, nb->in_bytes_rate); + break; case 3: if(cumulative) result = -cmpu64(na->out_packets, nb->out_packets); else result = -cmpfloat(na->out_packets_rate, nb->out_packets_rate); + break; case 4: if(cumulative) result = -cmpu64(na->out_bytes, nb->out_bytes); else result = -cmpfloat(na->out_bytes_rate, nb->out_bytes_rate); + break; case 5: if(cumulative) result = -cmpu64(na->in_packets + na->out_packets, nb->in_packets + nb->out_packets); else result = -cmpfloat(na->in_packets_rate + na->out_packets_rate, nb->in_packets_rate + nb->out_packets_rate); + break; case 6: if(cumulative) result = -cmpu64(na->in_bytes + na->out_bytes, nb->in_bytes + nb->out_bytes); else result = -cmpfloat(na->in_bytes_rate + na->out_bytes_rate, nb->in_bytes_rate + nb->out_bytes_rate); + break; default: result = strcmp(na->name, nb->name); + break; } if(result) @@ -213,7 +220,7 @@ static void redraw(void) { static int n = 0; if(changed) { n = 0; - sorted = xrealloc(sorted, node_list.count * sizeof *sorted); + sorted = xrealloc(sorted, node_list.count * sizeof(*sorted)); for list_each(nodestats_t, ns, &node_list) sorted[n++] = ns; changed = false; @@ -223,7 +230,7 @@ static void redraw(void) { sorted[i]->i = i; if(sorted) - qsort(sorted, n, sizeof *sorted, sortfunc); + qsort(sorted, n, sizeof(*sorted), sortfunc); for(int i = 0, row = 3; i < n; i++, row++) { nodestats_t *node = sorted[i];