1
0
Fork 0

wifi_perc: Simplify

This commit is contained in:
Aaron Marcher 2018-05-07 12:25:34 +02:00
parent 0a287616b2
commit 6c6c144be6

View file

@ -16,7 +16,6 @@
wifi_perc(const char *iface) wifi_perc(const char *iface)
{ {
int i, cur; int i, cur;
float perc;
int total = 70; /* the max of /proc/net/wireless */ int total = 70; /* the max of /proc/net/wireless */
char *p, *datastart; char *p, *datastart;
char path[PATH_MAX]; char path[PATH_MAX];
@ -59,9 +58,7 @@
sscanf(datastart + 1, " %*d %d %*d %*d\t\t %*d\t " sscanf(datastart + 1, " %*d %d %*d %*d\t\t %*d\t "
"%*d\t\t%*d\t\t %*d\t %*d\t\t %*d", &cur); "%*d\t\t%*d\t\t %*d\t %*d\t\t %*d", &cur);
perc = (float)cur / total * 100.0; return bprintf("%d", (int)((float)cur / total * 100));
return bprintf("%.0f", perc);
} }
const char * const char *