[hackers] [slstatus] wifi_perc: Simplify || Aaron Marcher

From: <git_AT_suckless.org>
Date: Mon, 7 May 2018 12:25:50 +0200 (CEST)

commit 6c6c144be62d6b2da564f0875ba5f202dbaa3183
Author: Aaron Marcher <me_AT_drkhsh.at>
AuthorDate: Mon May 7 12:25:34 2018 +0200
Commit: Aaron Marcher <me_AT_drkhsh.at>
CommitDate: Mon May 7 12:25:34 2018 +0200

    wifi_perc: Simplify

diff --git a/components/wifi.c b/components/wifi.c
index 139ec8c..24dca36 100644
--- a/components/wifi.c
+++ b/components/wifi.c
_AT_@ -16,7 +16,6 @@
         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];
_AT_@ -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);
 
- perc = (float)cur / total * 100.0;
-
- return bprintf("%.0f", perc);
+ return bprintf("%d", (int)((float)cur / total * 100));
         }
 
         const char *
Received on Mon May 07 2018 - 12:25:50 CEST

This archive was generated by hypermail 2.3.0 : Mon May 07 2018 - 12:36:30 CEST