diff options
author | tobhe <tobhe@cvs.openbsd.org> | 2020-09-25 10:38:06 +0000 |
---|---|---|
committer | tobhe <tobhe@cvs.openbsd.org> | 2020-09-25 10:38:06 +0000 |
commit | b2d328d9e04c10f2e56a2f828c3b177c111bd2d4 (patch) | |
tree | af7dc26b1d9ca23080a81946177ce7583324d50c /sbin/iked | |
parent | 6a49550be3ad5ecbe6180060709d1e6dab4d1bf9 (diff) |
Simplify RB_TREE cleanup loops.
ok markus@
Diffstat (limited to 'sbin/iked')
-rw-r--r-- | sbin/iked/config.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/sbin/iked/config.c b/sbin/iked/config.c index 4a888b55b86..967d90d3eae 100644 --- a/sbin/iked/config.c +++ b/sbin/iked/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.66 2020/09/23 14:25:55 tobhe Exp $ */ +/* $OpenBSD: config.c,v 1.67 2020/09/25 10:38:05 tobhe Exp $ */ /* * Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de> @@ -278,10 +278,9 @@ config_free_proposals(struct iked_proposals *head, unsigned int proto) void config_free_flows(struct iked *env, struct iked_flows *head) { - struct iked_flow *flow, *next; + struct iked_flow *flow; - for (flow = RB_MIN(iked_flows, head); flow != NULL; flow = next) { - next = RB_NEXT(iked_flows, head, flow); + while ((flow = RB_MIN(iked_flows, head))) { log_debug("%s: free %p", __func__, flow); RB_REMOVE(iked_flows, head, flow); flow_free(flow); @@ -509,8 +508,8 @@ int config_getreset(struct iked *env, struct imsg *imsg) { struct iked_policy *pol, *poltmp; - struct iked_sa *sa, *nextsa; - struct iked_user *usr, *nextusr; + struct iked_sa *sa; + struct iked_user *usr; unsigned int mode; IMSG_SIZE_CHECK(imsg, &mode); @@ -525,9 +524,7 @@ config_getreset(struct iked *env, struct imsg *imsg) if (mode == RESET_ALL || mode == RESET_SA) { log_debug("%s: flushing SAs", __func__); - for (sa = RB_MIN(iked_sas, &env->sc_sas); - sa != NULL; sa = nextsa) { - nextsa = RB_NEXT(iked_sas, &env->sc_sas, sa); + while ((sa = RB_MIN(iked_sas, &env->sc_sas))) { /* for RESET_SA we try send a DELETE */ if (mode == RESET_ALL || ikev2_ike_sa_delete(env, sa) != 0) { @@ -539,9 +536,7 @@ config_getreset(struct iked *env, struct imsg *imsg) if (mode == RESET_ALL || mode == RESET_USER) { log_debug("%s: flushing users", __func__); - for (usr = RB_MIN(iked_users, &env->sc_users); - usr != NULL; usr = nextusr) { - nextusr = RB_NEXT(iked_users, &env->sc_users, usr); + while ((usr = RB_MIN(iked_users, &env->sc_users))) { RB_REMOVE(iked_users, &env->sc_users, usr); free(usr); } |