From 3251e911878b78b0aad8fc09c782f8d81c878f75 Mon Sep 17 00:00:00 2001 From: drkhsh Date: Fri, 28 Oct 2022 00:51:34 +0200 Subject: radical re-formatting 2/3: Fix blocks Fixes coding style. Formatting commits suck, incoherent coding style sucks more. https://suckless.org/coding_style/ --- components/wifi.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'components/wifi.c') 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; } -- cgit v1.2.3