X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftop.c;h=910e7ef302693ddce9982cb3eeb9062f3a1c0fb5;hb=1022812ed4b5c70162f2f0a9d9a96c716c936408;hp=ab1461957a2c9667c3b76bd68bbd53f8620f09fc;hpb=1c475ecb575367a6b3f9328b0f643ad636155341;p=tinc diff --git a/src/top.c b/src/top.c index ab146195..910e7ef3 100644 --- a/src/top.c +++ b/src/top.c @@ -76,7 +76,7 @@ static bool update(int fd) { timersub(&cur, &prev, &diff); prev = cur; - float interval = diff.tv_sec + diff.tv_usec * 1e-6; + float interval = (float) diff.tv_sec + (float) diff.tv_usec * 1e-6f; char line[4096]; char name[4096]; @@ -131,10 +131,10 @@ static bool update(int fd) { } found->known = true; - found->in_packets_rate = (in_packets - found->in_packets) / interval; - found->in_bytes_rate = (in_bytes - found->in_bytes) / interval; - found->out_packets_rate = (out_packets - found->out_packets) / interval; - found->out_bytes_rate = (out_bytes - found->out_bytes) / interval; + found->in_packets_rate = (float)(in_packets - found->in_packets) / interval; + found->in_bytes_rate = (float)(in_bytes - found->in_bytes) / interval; + found->out_packets_rate = (float)(out_packets - found->out_packets) / interval; + found->out_bytes_rate = (float)(out_bytes - found->out_bytes) / interval; found->in_packets = in_packets; found->in_bytes = in_bytes; found->out_packets = out_packets; @@ -280,7 +280,8 @@ static void redraw(void) { if(cumulative) mvprintw(row, 0, "%-16s %10.0f %10.0f %10.0f %10.0f", - node->name, node->in_packets * pscale, node->in_bytes * bscale, node->out_packets * pscale, node->out_bytes * bscale); + node->name, (float) node->in_packets * pscale, (float) node->in_bytes * bscale, + (float) node->out_packets * pscale, (float) node->out_bytes * bscale); else mvprintw(row, 0, "%-16s %10.0f %10.0f %10.0f %10.0f", node->name, node->in_packets_rate * pscale, node->in_bytes_rate * bscale, node->out_packets_rate * pscale, node->out_bytes_rate * bscale); @@ -307,15 +308,15 @@ void top(int fd) { switch(getch()) { case 's': { timeout(-1); - float input = delay * 1e-3; + float input = (float)delay * 1e-3f; mvprintw(1, 0, "Change delay from %.1fs to: ", input); scanw("%f", &input); if(input < 0.1) { - input = 0.1; + input = 0.1f; } - delay = input * 1e3; + delay = (int)(input * 1e3f); timeout(delay); break; } @@ -361,23 +362,23 @@ void top(int fd) { case 'k': bunit = "kbyte"; - bscale = 1e-3; + bscale = 1e-3f; punit = "pkts"; pscale = 1; break; case 'M': bunit = "Mbyte"; - bscale = 1e-6; + bscale = 1e-6f; punit = "kpkt"; - pscale = 1e-3; + pscale = 1e-3f; break; case 'G': bunit = "Gbyte"; - bscale = 1e-9; + bscale = 1e-9f; punit = "Mpkt"; - pscale = 1e-6; + pscale = 1e-6f; break; case 'q':