From 040bd5bc86f53589d1a8a7f50b95566b0766c878 Mon Sep 17 00:00:00 2001 From: ozaki-r Date: Wed, 12 Jul 2017 03:59:32 +0000 Subject: [PATCH] Omit NULL checks for sav->lft_c sav->lft_c can be NULL only when initializing or destroying sav. --- sys/netipsec/key.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c index df47f9b24767..ea8d8faa45cf 100644 --- a/sys/netipsec/key.c +++ b/sys/netipsec/key.c @@ -1,4 +1,4 @@ -/* $NetBSD: key.c,v 1.177 2017/07/12 03:53:55 ozaki-r Exp $ */ +/* $NetBSD: key.c,v 1.178 2017/07/12 03:59:32 ozaki-r Exp $ */ /* $FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $ */ /* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */ @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.177 2017/07/12 03:53:55 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.178 2017/07/12 03:59:32 ozaki-r Exp $"); /* * This code is referd to RFC 2367 @@ -3461,8 +3461,7 @@ key_setdumpsa(struct secasvar *sav, u_int8_t type, u_int8_t satype, break; case SADB_EXT_LIFETIME_CURRENT: - if (!sav->lft_c) - continue; + KASSERT(sav->lft_c != NULL); l = PFKEY_UNUNIT64(((struct sadb_ext *)sav->lft_c)->sadb_ext_len); memcpy(<, sav->lft_c, sizeof(struct sadb_lifetime)); lt.sadb_lifetime_addtime = @@ -4478,11 +4477,7 @@ key_timehandler_sad(time_t now) continue; /* sanity check */ - if (sav->lft_c == NULL) { - IPSECLOG(LOG_DEBUG, - "There is no CURRENT time, why?\n"); - continue; - } + KASSERT(sav->lft_c != NULL); /* check SOFT lifetime */ if (sav->lft_s->sadb_lifetime_addtime != 0 && @@ -4532,11 +4527,7 @@ key_timehandler_sad(time_t now) continue; /* sanity check */ - if (sav->lft_c == NULL) { - IPSECLOG(LOG_DEBUG, - "There is no CURRENT time, why?\n"); - continue; - } + KASSERT(sav->lft_c != NULL); if (sav->lft_h->sadb_lifetime_addtime != 0 && now - sav->created > sav->lft_h->sadb_lifetime_addtime) { @@ -7780,9 +7771,8 @@ key_sa_recordxfer(struct secasvar *sav, struct mbuf *m) { KASSERT(sav != NULL); + KASSERT(sav->lft_c != NULL); KASSERT(m != NULL); - if (!sav->lft_c) - return; /* * XXX Currently, there is a difference of bytes size