diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-01-05 12:42:20 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-01-05 12:42:20 +0000 |
commit | 385cc1a6a7d364a53040c00955c4b96a987c5356 (patch) | |
tree | 2fe790999ec37a3868ce7fc3070ff0599570a138 /usr.sbin/ldpd | |
parent | 6bd1a9c1ac311b78e6bce077b29e0e0d21558db7 (diff) |
Replace symset()'s hand-rolled for(;;) traversal of 'symhead' TAILQ
with more modern TAILQ_FOREACH(). This what symget() was already
doing.
Add paranoia '{}' around body of symget()'s TAILQ_FOREACH().
No intentional functional change.
ok bluhm@ otto@
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r-- | usr.sbin/ldpd/parse.y | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y index 98f0e1e3b7f..36f60734200 100644 --- a/usr.sbin/ldpd/parse.y +++ b/usr.sbin/ldpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.57 2016/07/01 23:14:31 renato Exp $ */ +/* $OpenBSD: parse.y,v 1.58 2017/01/05 12:42:18 krw Exp $ */ /* * Copyright (c) 2013, 2015, 2016 Renato Westphal <renato@openbsd.org> @@ -1231,9 +1231,10 @@ symset(const char *nam, const char *val, int persist) { struct sym *sym; - for (sym = TAILQ_FIRST(&symhead); sym && strcmp(nam, sym->nam); - sym = TAILQ_NEXT(sym, entry)) - ; /* nothing */ + TAILQ_FOREACH(sym, &symhead, entry) { + if (strcmp(nam, sym->nam) == 0) + break; + } if (sym != NULL) { if (sym->persist == 1) @@ -1292,11 +1293,12 @@ symget(const char *nam) { struct sym *sym; - TAILQ_FOREACH(sym, &symhead, entry) + TAILQ_FOREACH(sym, &symhead, entry) { if (strcmp(nam, sym->nam) == 0) { sym->used = 1; return (sym->val); } + } return (NULL); } |