Xinqi Bao's Git
projects
/
slstatus.git
/ commitdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (from parent 1:
709549b
)
wifi: Various cleanups
author
Aaron Marcher <
[email protected]
>
Wed, 2 May 2018 06:49:06 +0000
(08:49 +0200)
committer
Aaron Marcher <
[email protected]
>
Wed, 2 May 2018 06:49:06 +0000
(08:49 +0200)
components/wifi.c
patch
|
blob
|
history
diff --git
a/components/wifi.c
b/components/wifi.c
index
33e09b7
..
13b630a
100644
(file)
--- a/
components/wifi.c
+++ b/
components/wifi.c
@@
-25,20
+25,17
@@
snprintf(path, sizeof(path), "%s%s%s", "/sys/class/net/", iface,
"/operstate");
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;
}
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;
}
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;
fprintf(stderr, "fopen '/proc/net/wireless': %s\n",
strerror(errno));
return NULL;
@@
-92,8
+89,8
@@
if (strcmp(id, "") == 0)
return NULL;
if (strcmp(id, "") == 0)
return NULL;
- else
-
return id;
+
+ return id;
}
#elif defined(__OpenBSD__)
/* unimplemented */
}
#elif defined(__OpenBSD__)
/* unimplemented */