summaryrefslogtreecommitdiff
path: root/components/wifi.c
diff options
context:
space:
mode:
authorAaron Marcher <me@drkhsh.at>2018-05-06 22:28:56 +0200
committerAaron Marcher <me@drkhsh.at>2018-05-06 22:28:56 +0200
commitee5ec756218c852385c5ba5ef0f75b47ba59ec39 (patch)
tree2cc3cd4e654671d509dceb572c7c72d3bfde5e9d /components/wifi.c
parent66a7fb16fc903ac7ef6ce1acdbb353f1072cd0ec (diff)
Fix coding style
- Use block for single statement ifs - Keep lines to reasonable length (current debate as to reasonable) - When functions return -1 for error test against 0 not -1 - Do not indent cases another level - Do not test against NULL and 0 explicitly - Use tabs for indentation, use spaces for alignment
Diffstat (limited to 'components/wifi.c')
-rw-r--r--components/wifi.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/components/wifi.c b/components/wifi.c
index 7cd2702..c209598 100644
--- a/components/wifi.c
+++ b/components/wifi.c
@@ -47,11 +47,13 @@
break;
}
fclose(fp);
- if (i < 2 || !p)
+ if (i < 2 || !p) {
return NULL;
+ }
- if ((datastart = strstr(buf, iface)) == NULL)
+ if (!(datastart = strstr(buf, iface))) {
return NULL;
+ }
datastart = (datastart+(strlen(iface)+1));
sscanf(datastart + 1, " %*d %d %*d %*d\t\t %*d\t "
@@ -73,23 +75,23 @@
wreq.u.essid.length = IW_ESSID_MAX_SIZE+1;
snprintf(wreq.ifr_name, sizeof(wreq.ifr_name), "%s", iface);
- if (sockfd == -1) {
+ if (sockfd < 0) {
fprintf(stderr, "socket 'AF_INET': %s\n",
strerror(errno));
return NULL;
}
wreq.u.essid.pointer = id;
- if (ioctl(sockfd,SIOCGIWESSID, &wreq) == -1) {
- fprintf(stderr, "ioctl 'SIOCGIWESSID': %s\n",
- strerror(errno));
+ if (ioctl(sockfd,SIOCGIWESSID, &wreq) < 0) {
+ fprintf(stderr, "ioctl 'SIOCGIWESSID': %s\n", strerror(errno));
close(sockfd);
return NULL;
}
close(sockfd);
- if (strcmp(id, "") == 0)
+ if (!strcmp(id, "")) {
return NULL;
+ }
return id;
}