]> git.proxmox.com Git - mirror_frr.git/commitdiff
ldpd: replace hand-rolled 'for' loop with specialized macro
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 3 Mar 2017 20:50:22 +0000 (17:50 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Fri, 3 Mar 2017 20:50:22 +0000 (17:50 -0300)
No intentional functional change.

Original author: Kenneth R Westerback <krw@openbsd.org>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ldpd/control.c

index 8a2280be07bf54ae36e0d1bb91655a635415bb53..0bfe0abc9de56bba7c67adeb2e879e40d63e03d6 100644 (file)
@@ -148,9 +148,10 @@ control_connbyfd(int fd)
 {
        struct ctl_conn *c;
 
-       for (c = TAILQ_FIRST(&ctl_conns); c != NULL && c->iev.ibuf.fd != fd;
-           c = TAILQ_NEXT(c, entry))
-               ;       /* nothing */
+       TAILQ_FOREACH(c, &ctl_conns, entry) {
+               if (c->iev.ibuf.fd == fd)
+                       break;
+       }
 
        return (c);
 }
@@ -160,9 +161,10 @@ control_connbypid(pid_t pid)
 {
        struct ctl_conn *c;
 
-       for (c = TAILQ_FIRST(&ctl_conns); c != NULL && c->iev.ibuf.pid != pid;
-           c = TAILQ_NEXT(c, entry))
-               ;       /* nothing */
+       TAILQ_FOREACH(c, &ctl_conns, entry) {
+               if (c->iev.ibuf.pid == pid)
+                       break;
+       }
 
        return (c);
 }