summaryrefslogtreecommitdiff
path: root/usr.sbin/switchd
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2017-01-05 12:42:20 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2017-01-05 12:42:20 +0000
commit385cc1a6a7d364a53040c00955c4b96a987c5356 (patch)
tree2fe790999ec37a3868ce7fc3070ff0599570a138 /usr.sbin/switchd
parent6bd1a9c1ac311b78e6bce077b29e0e0d21558db7 (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/switchd')
-rw-r--r--usr.sbin/switchd/parse.y12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/switchd/parse.y b/usr.sbin/switchd/parse.y
index 8f051d7a8bb..a365057c5d2 100644
--- a/usr.sbin/switchd/parse.y
+++ b/usr.sbin/switchd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.3 2016/10/12 19:07:42 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.4 2017/01/05 12:42:19 krw Exp $ */
/*
* Copyright (c) 2007-2016 Reyk Floeter <reyk@openbsd.org>
@@ -634,9 +634,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)
@@ -695,11 +696,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);
}