diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2017-03-03 17:50:22 -0300 | 
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2017-03-03 17:50:22 -0300 | 
| commit | b53f7b86efe5fdd6692fc9033e032881c4357139 (patch) | |
| tree | cf9bedf57537224f3015dc7ddc009245ebd8266b /ldpd/control.c | |
| parent | bc6cec21c458ff9a3e82f38bb3f5cf23143ba8c1 (diff) | |
ldpd: replace hand-rolled 'for' loop with specialized macro
No intentional functional change.
Original author: Kenneth R Westerback <krw@openbsd.org>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ldpd/control.c')
| -rw-r--r-- | ldpd/control.c | 14 | 
1 files 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);  }  | 
