chiark / gitweb /
src/event.c: Use `continue' in adns_processreadable (style)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 12 Oct 2014 19:02:27 +0000 (20:02 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Oct 2014 20:14:57 +0000 (21:14 +0100)
This is IMO clearer than another nested indent of the bulk of the loop
body.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/event.c

index 1652268..6cfc4ba 100644 (file)
@@ -398,31 +398,30 @@ int adns_processreadable(adns_state ads, int fd, const struct timeval *now) {
   }
   for (i=0; i<ads->nudpsockets; i++) {
     udp= &ads->udpsockets[i];
-    if (fd == udp->fd) {
-      for (;;) {
-       udpaddrlen= sizeof(udpaddr);
-       r= recvfrom(fd,udpbuf,sizeof(udpbuf),0, &udpaddr.sa,&udpaddrlen);
-       if (r<0) {
-         if (errno == EAGAIN || errno == EWOULDBLOCK) { r= 0; goto xit; }
-         if (errno == EINTR) continue;
-         if (errno_resources(errno)) { r= errno; goto xit; }
-         adns__warn(ads,-1,0,"datagram receive error: %s",strerror(errno));
-         r= 0; goto xit;
-       }
-       for (serv= 0;
-            serv < ads->nservers &&
-              !adns__sockaddrs_equal(&udpaddr.sa,
-                                     &ads->servers[serv].addr.sa);
-            serv++);
-       if (serv >= ads->nservers) {
-         adns__warn(ads,-1,0,"datagram received from unknown nameserver %s",
-                    adns__sockaddr_ntoa(&udpaddr.sa, addrbuf));
-         continue;
-       }
-       adns__procdgram(ads,udpbuf,r,serv,0,*now);
+    if (fd != udp->fd) continue;
+    for (;;) {
+      udpaddrlen= sizeof(udpaddr);
+      r= recvfrom(fd,udpbuf,sizeof(udpbuf),0, &udpaddr.sa,&udpaddrlen);
+      if (r<0) {
+       if (errno == EAGAIN || errno == EWOULDBLOCK) { r= 0; goto xit; }
+       if (errno == EINTR) continue;
+       if (errno_resources(errno)) { r= errno; goto xit; }
+       adns__warn(ads,-1,0,"datagram receive error: %s",strerror(errno));
+       r= 0; goto xit;
       }
-      break;
+      for (serv= 0;
+          serv < ads->nservers &&
+            !adns__sockaddrs_equal(&udpaddr.sa,
+                                   &ads->servers[serv].addr.sa);
+          serv++);
+      if (serv >= ads->nservers) {
+       adns__warn(ads,-1,0,"datagram received from unknown nameserver %s",
+                  adns__sockaddr_ntoa(&udpaddr.sa, addrbuf));
+       continue;
+      }
+      adns__procdgram(ads,udpbuf,r,serv,0,*now);
     }
+    break;
   }
   r= 0;
 xit: