From b53f7b86efe5fdd6692fc9033e032881c4357139 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 3 Mar 2017 17:50:22 -0300 Subject: [PATCH] ldpd: replace hand-rolled 'for' loop with specialized macro No intentional functional change. Original author: Kenneth R Westerback Signed-off-by: Renato Westphal --- ldpd/control.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ldpd/control.c b/ldpd/control.c index 8a2280be07..0bfe0abc9d 100644 --- a/ldpd/control.c +++ b/ldpd/control.c @@ -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); } -- 2.39.5