summaryrefslogtreecommitdiff
path: root/sbin
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 /sbin
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 'sbin')
-rw-r--r--sbin/iked/parse.y12
-rw-r--r--sbin/ipsecctl/parse.y12
-rw-r--r--sbin/pfctl/parse.y12
3 files changed, 21 insertions, 15 deletions
diff --git a/sbin/iked/parse.y b/sbin/iked/parse.y
index 99880c3f58b..b4168e443a2 100644
--- a/sbin/iked/parse.y
+++ b/sbin/iked/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.59 2017/01/04 12:31:01 mikeb Exp $ */
+/* $OpenBSD: parse.y,v 1.60 2017/01/05 12:42:18 krw Exp $ */
/*
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
@@ -1513,9 +1513,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)
@@ -1574,11 +1575,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);
}
diff --git a/sbin/ipsecctl/parse.y b/sbin/ipsecctl/parse.y
index 4bfc1deb51b..0eace41f56b 100644
--- a/sbin/ipsecctl/parse.y
+++ b/sbin/ipsecctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.165 2016/06/21 21:35:24 benno Exp $ */
+/* $OpenBSD: parse.y,v 1.166 2017/01/05 12:42:18 krw Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1359,9 +1359,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)
@@ -1420,11 +1421,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);
}
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index b853a42549c..18e5524bb0f 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.656 2016/11/23 12:13:23 bluhm Exp $ */
+/* $OpenBSD: parse.y,v 1.657 2017/01/05 12:42:18 krw Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -5476,9 +5476,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)
@@ -5535,11 +5536,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);
}