No need to remember the fd anymore
authorRoy Marples <roy@marples.name>
Tue, 12 May 2015 22:18:21 +0000 (22:18 +0000)
committerRoy Marples <roy@marples.name>
Tue, 12 May 2015 22:18:21 +0000 (22:18 +0000)
src/dhcpcd-curses/dhcpcd-curses.c
src/dhcpcd-curses/dhcpcd-curses.h

index 65ea1d0c34f048218d15f6794c847e2112f3bea3..f47e74b9ac0557ba24bb15848154f886ce4d3f33 100644 (file)
@@ -200,12 +200,13 @@ try_open(void *arg)
 {
        struct ctx *ctx = arg;
        static int last_error;
+       int fd;
 
-       ctx->fd = dhcpcd_open(ctx->con, true);
-       if (ctx->fd == -1) {
+       fd = dhcpcd_open(ctx->con, true);
+       if (fd == -1) {
                if (errno == EACCES || errno == EPERM) {
-                       ctx->fd = dhcpcd_open(ctx->con, false);
-                       if (ctx->fd != -1)
+                       fd = dhcpcd_open(ctx->con, false);
+                       if (fd != -1)
                                goto unprived;
                }
                if (errno != last_error) {
@@ -223,7 +224,7 @@ unprived:
        /* Start listening to WPA events */
        dhcpcd_wpa_start(ctx->con);
 
-       eloop_event_add(ctx->eloop, ctx->fd, dispatch, ctx, NULL, NULL);
+       eloop_event_add(ctx->eloop, fd, dispatch, ctx, NULL, NULL);
 }
 
 static void
@@ -505,7 +506,6 @@ main(void)
        sigset_t sigmask;
 
        memset(&ctx, 0, sizeof(ctx));
-       ctx.fd = -1;
        TAILQ_INIT(&ctx.wi_scans);
 
        if ((ctx.eloop = eloop_new()) == NULL)
index 7bc8b149e64931933cac333064e5476ee54a330f..28dd507326b5aa112d81f2c36fbc5d93daa0b35d 100644 (file)
@@ -60,7 +60,6 @@ typedef TAILQ_HEAD(wi_scan_head, wi_scan) WI_SCANS;
 struct ctx {
        struct eloop *eloop;
        DHCPCD_CONNECTION *con;
-       int fd;
        bool online;
        bool carrier;
        unsigned int last_status;