wifi_essid: Fix coding style
authorAaron Marcher <me@drkhsh.at>
Thu, 17 May 2018 15:59:05 +0000 (17:59 +0200)
committerAaron Marcher <me@drkhsh.at>
Thu, 17 May 2018 15:59:05 +0000 (17:59 +0200)
Only initialize variables at the beginning of a block

components/wifi.c

index 7dfa4e2ab1f4f16c69c50ec49af1eba193ca1601..473c8a7fe041b8b938c7a278286f37af6b95a780 100644 (file)
        wifi_essid(const char *iface)
        {
                static char id[IW_ESSID_MAX_SIZE+1];
-               int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+               int sockfd;
                struct iwreq wreq;
 
                memset(&wreq, 0, sizeof(struct iwreq));
                wreq.u.essid.length = IW_ESSID_MAX_SIZE+1;
                snprintf(wreq.ifr_name, sizeof(wreq.ifr_name), "%s", iface);
 
-               if (sockfd < 0) {
+               if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
                        fprintf(stderr, "socket 'AF_INET': %s\n",
                                strerror(errno));
                        return NULL;