Xinqi Bao's Git
projects
/
slstatus.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
wifi_perc: Simplify
[slstatus.git]
/
components
/
wifi.c
diff --git
a/components/wifi.c
b/components/wifi.c
index
139ec8c
..
24dca36
100644
(file)
--- a/
components/wifi.c
+++ b/
components/wifi.c
@@
-16,7
+16,6
@@
wifi_perc(const char *iface)
{
int i, cur;
wifi_perc(const char *iface)
{
int i, cur;
- float perc;
int total = 70; /* the max of /proc/net/wireless */
char *p, *datastart;
char path[PATH_MAX];
int total = 70; /* the max of /proc/net/wireless */
char *p, *datastart;
char path[PATH_MAX];
@@
-59,9
+58,7
@@
sscanf(datastart + 1, " %*d %d %*d %*d\t\t %*d\t "
"%*d\t\t%*d\t\t %*d\t %*d\t\t %*d", &cur);
sscanf(datastart + 1, " %*d %d %*d %*d\t\t %*d\t "
"%*d\t\t%*d\t\t %*d\t %*d\t\t %*d", &cur);
- perc = (float)cur / total * 100.0;
-
- return bprintf("%.0f", perc);
+ return bprintf("%d", (int)((float)cur / total * 100));
}
const char *
}
const char *