summaryrefslogtreecommitdiff
path: root/sbin/iked/config.c
diff options
context:
space:
mode:
authortobhe <tobhe@cvs.openbsd.org>2020-03-09 11:50:44 +0000
committertobhe <tobhe@cvs.openbsd.org>2020-03-09 11:50:44 +0000
commit8809a3d0d3a00b23e7e68438809b3e4561b02dfd (patch)
treece17ad86a0e1f310936a88a94cf15dfab8a2a918 /sbin/iked/config.c
parentab2399ae576acee0248fd18f61232c9b75ec39d4 (diff)
Use TAILQ_FOREACH_SAFE instead of hand rolled loops.
From Wataru <wataash at wataash dot com> ok patrick@
Diffstat (limited to 'sbin/iked/config.c')
-rw-r--r--sbin/iked/config.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/sbin/iked/config.c b/sbin/iked/config.c
index 71f01cb5d54..13bf476f26f 100644
--- a/sbin/iked/config.c
+++ b/sbin/iked/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.53 2020/01/16 20:05:00 tobhe Exp $ */
+/* $OpenBSD: config.c,v 1.54 2020/03/09 11:50:43 tobhe Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
@@ -258,11 +258,9 @@ config_add_proposal(struct iked_proposals *head, unsigned int id,
void
config_free_proposals(struct iked_proposals *head, unsigned int proto)
{
- struct iked_proposal *prop, *next;
-
- for (prop = TAILQ_FIRST(head); prop != NULL; prop = next) {
- next = TAILQ_NEXT(prop, prop_entry);
+ struct iked_proposal *prop, *proptmp;
+ TAILQ_FOREACH_SAFE(prop, head, prop_entry, proptmp) {
/* Free any proposal or only selected SA proto */
if (proto != 0 && prop->prop_protoid != proto)
continue;
@@ -293,14 +291,12 @@ void
config_free_childsas(struct iked *env, struct iked_childsas *head,
struct iked_spi *peerspi, struct iked_spi *localspi)
{
- struct iked_childsa *csa, *nextcsa, *ipcomp;
+ struct iked_childsa *csa, *csatmp, *ipcomp;
if (localspi != NULL)
bzero(localspi, sizeof(*localspi));
- for (csa = TAILQ_FIRST(head); csa != NULL; csa = nextcsa) {
- nextcsa = TAILQ_NEXT(csa, csa_entry);
-
+ TAILQ_FOREACH_SAFE(csa, head, csa_entry, csatmp) {
if (peerspi != NULL) {
/* Only delete matching peer SPIs */
if (peerspi->spi != csa->csa_peerspi)
@@ -511,7 +507,7 @@ config_setreset(struct iked *env, unsigned int mode, enum privsep_procid id)
int
config_getreset(struct iked *env, struct imsg *imsg)
{
- struct iked_policy *pol, *nextpol;
+ struct iked_policy *pol, *poltmp;
struct iked_sa *sa, *nextsa;
struct iked_user *usr, *nextusr;
unsigned int mode;
@@ -521,9 +517,7 @@ config_getreset(struct iked *env, struct imsg *imsg)
if (mode == RESET_ALL || mode == RESET_POLICY) {
log_debug("%s: flushing policies", __func__);
- for (pol = TAILQ_FIRST(&env->sc_policies);
- pol != NULL; pol = nextpol) {
- nextpol = TAILQ_NEXT(pol, pol_entry);
+ TAILQ_FOREACH_SAFE(pol, &env->sc_policies, pol_entry, poltmp) {
config_free_policy(env, pol);
}
}