From 6738e0b6eda425183323ce7dfb75ec554648e605 Mon Sep 17 00:00:00 2001 From: Christian Weisgerber Date: Sat, 28 Nov 2020 22:06:26 +0000 Subject: improve legibility of the newly introduced unref_icmp6ev() before this code gets copied around; ok florian@ --- sbin/slaacd/frontend.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'sbin/slaacd') diff --git a/sbin/slaacd/frontend.c b/sbin/slaacd/frontend.c index 6cae8c9ca05..5d01cfb8960 100644 --- a/sbin/slaacd/frontend.c +++ b/sbin/slaacd/frontend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frontend.c,v 1.39 2020/11/28 07:59:26 florian Exp $ */ +/* $OpenBSD: frontend.c,v 1.40 2020/11/28 22:06:25 naddy Exp $ */ /* * Copyright (c) 2017 Florian Obser @@ -1137,14 +1137,16 @@ get_icmp6ev_by_rdomain(int rdomain) void unref_icmp6ev(struct iface *iface) { - if (iface->icmp6ev != NULL) { - iface->icmp6ev->refcnt--; - if (iface->icmp6ev->refcnt == 0) { - event_del(&iface->icmp6ev->ev); - close(EVENT_FD(&iface->icmp6ev->ev)); - free(iface->icmp6ev); + struct icmp6_ev *icmp6ev = iface->icmp6ev; + + if (icmp6ev != NULL) { + icmp6ev->refcnt--; + if (icmp6ev->refcnt == 0) { + event_del(&icmp6ev->ev); + close(EVENT_FD(&icmp6ev->ev)); + free(icmp6ev); } - iface->icmp6ev = NULL; + icmp6ev = NULL; } } -- cgit v1.2.3