[hackers] [slstatus] wifi: Various cleanups || Aaron Marcher
commit f7a6d6c8f7d621fe7b5a9c37a130f8bf3b9bd892
Author: Aaron Marcher <me_AT_drkhsh.at>
AuthorDate: Wed May 2 08:49:06 2018 +0200
Commit: Aaron Marcher <me_AT_drkhsh.at>
CommitDate: Wed May 2 08:49:06 2018 +0200
wifi: Various cleanups
diff --git a/components/wifi.c b/components/wifi.c
index 33e09b7..13b630a 100644
--- a/components/wifi.c
+++ b/components/wifi.c
_AT_@ -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;
_AT_@ -92,8 +89,8 @@
if (strcmp(id, "") == 0)
return NULL;
- else
- return id;
+
+ return id;
}
#elif defined(__OpenBSD__)
/* unimplemented */
Received on Wed May 02 2018 - 08:49:38 CEST
This archive was generated by hypermail 2.3.0
: Wed May 02 2018 - 09:01:04 CEST