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

From: <git_AT_suckless.org>
Date: Sat, 7 Jul 2018 14:06:21 +0200 (CEST)

commit c93971748cb4771aec25aee6e8ff5b7bbb1aacf3
Author: Aaron Marcher <me_AT_drkhsh.at>
AuthorDate: Sat Jul 7 14:05:53 2018 +0200
Commit: Aaron Marcher <me_AT_drkhsh.at>
CommitDate: Sat Jul 7 14:05:53 2018 +0200

    wifi_perc: Simplify on Linux
    
    Remove unnecessary variable

diff --git a/components/wifi.c b/components/wifi.c
index 9de543b..da00cb3 100644
--- a/components/wifi.c
+++ b/components/wifi.c
_AT_@ -15,8 +15,8 @@
         const char *
         wifi_perc(const char *interface)
         {
- int i, cur;
- int total = 70; /* the max of /proc/net/wireless */
+ int cur;
+ size_t i;
                 char *p, *datastart;
                 char path[PATH_MAX];
                 char status[5];
_AT_@ -59,7 +59,8 @@
                 sscanf(datastart + 1, " %*d %d %*d %*d\t\t %*d\t "
                        "%*d\t\t%*d\t\t %*d\t %*d\t\t %*d", &cur);
 
- return bprintf("%d", (int)((float)cur / total * 100));
+ /* 70 is the max of /proc/net/wireless */
+ return bprintf("%d", (int)((float)cur / 70 * 100));
         }
 
         const char *
Received on Sat Jul 07 2018 - 14:06:21 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 07 2018 - 14:12:25 CEST