slstatus

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.beauhilton.com/slstatus.git
Log | Files | Refs | README | LICENSE

commit f7a6d6c8f7d621fe7b5a9c37a130f8bf3b9bd892
parent 709549b4bd9fee0e0054c0dfa75fff9ac18f2862
Author: Aaron Marcher <me@drkhsh.at>
Date:   Wed,  2 May 2018 08:49:06 +0200

wifi: Various cleanups

Diffstat:
Mcomponents/wifi.c | 15++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/components/wifi.c b/components/wifi.c @@ -25,20 +25,17 @@ snprintf(path, sizeof(path), "%s%s%s", "/sys/class/net/", iface, "/operstate"); - fp = fopen(path, "r"); - if (fp == NULL) { + if (!(fp = fopen(path, "r"))) { fprintf(stderr, "fopen '%s': %s\n", path, strerror(errno)); return NULL; } - p = fgets(status, 5, fp); - fclose(fp); - if(!p || strcmp(status, "up\n") != 0) { + if(!(p = fgets(status, 5, fp)) || strcmp(status, "up\n") != 0) { return NULL; } + fclose(fp); - fp = fopen("/proc/net/wireless", "r"); - if (fp == NULL) { + if (!(fp = fopen("/proc/net/wireless", "r"))) { fprintf(stderr, "fopen '/proc/net/wireless': %s\n", strerror(errno)); return NULL; @@ -92,8 +89,8 @@ if (strcmp(id, "") == 0) return NULL; - else - return id; + + return id; } #elif defined(__OpenBSD__) /* unimplemented */