diff options
author | drkhsh <me@drkhsh.at> | 2022-10-28 00:51:34 +0200 |
---|---|---|
committer | drkhsh <me@drkhsh.at> | 2022-10-28 01:03:38 +0200 |
commit | 3251e911878b78b0aad8fc09c782f8d81c878f75 (patch) | |
tree | dc9b6927e963a994286babd803357615c9b37a22 /components/wifi.c | |
parent | 2104dc362ca7336d98499a5945ea2a3d371f7568 (diff) | |
download | slstatus-3251e911878b78b0aad8fc09c782f8d81c878f75.tar.gz |
radical re-formatting 2/3: Fix blocks
Fixes coding style. Formatting commits suck, incoherent coding style
sucks more.
https://suckless.org/coding_style/
Diffstat (limited to 'components/wifi.c')
-rw-r--r-- | components/wifi.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/components/wifi.c b/components/wifi.c index a20e8d4..4543d32 100644 --- a/components/wifi.c +++ b/components/wifi.c @@ -38,27 +38,24 @@ } p = fgets(status, 5, fp); fclose(fp); - if (!p || strcmp(status, "up\n") != 0) { + if (!p || strcmp(status, "up\n") != 0) return NULL; - } if (!(fp = fopen("/proc/net/wireless", "r"))) { warn("fopen '/proc/net/wireless':"); return NULL; } - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) if (!(p = fgets(buf, sizeof(buf) - 1, fp))) break; - } + fclose(fp); - if (i < 2 || !p) { + if (i < 2 || !p) return NULL; - } - if (!(datastart = strstr(buf, interface))) { + if (!(datastart = strstr(buf, interface))) return NULL; - } datastart = (datastart+(strlen(interface)+1)); sscanf(datastart + 1, " %*d %d %*d %*d\t\t %*d\t " @@ -78,9 +75,8 @@ memset(&wreq, 0, sizeof(struct iwreq)); wreq.u.essid.length = IW_ESSID_MAX_SIZE+1; if (esnprintf(wreq.ifr_name, sizeof(wreq.ifr_name), "%s", - interface) < 0) { + interface) < 0) return NULL; - } if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { warn("socket 'AF_INET':"); @@ -95,9 +91,8 @@ close(sockfd); - if (!strcmp(id, "")) { + if (!strcmp(id, "")) return NULL; - } return id; } @@ -153,11 +148,11 @@ int q; if (load_ieee80211_nodereq(interface, &nr)) { - if (nr.nr_max_rssi) { + if (nr.nr_max_rssi) q = IEEE80211_NODEREQ_RSSI(&nr); - } else { + else q = RSSI_TO_PERC(nr.nr_rssi); - } + return bprintf("%d", q); } @@ -169,9 +164,8 @@ { struct ieee80211_nodereq nr; - if (load_ieee80211_nodereq(interface, &nr)) { + if (load_ieee80211_nodereq(interface, &nr)) return bprintf("%s", nr.nr_nwid); - } return NULL; } |