Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netipsec Omit NULL checks for sav->lft_c



details:   https://anonhg.NetBSD.org/src/rev/67349306eda3
branches:  trunk
changeset: 825369:67349306eda3
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Wed Jul 12 03:59:32 2017 +0000

description:
Omit NULL checks for sav->lft_c

sav->lft_c can be NULL only when initializing or destroying sav.

diffstat:

 sys/netipsec/key.c |  22 ++++++----------------
 1 files changed, 6 insertions(+), 16 deletions(-)

diffs (65 lines):

diff -r 8478622680a6 -r 67349306eda3 sys/netipsec/key.c
--- a/sys/netipsec/key.c        Wed Jul 12 03:53:55 2017 +0000
+++ b/sys/netipsec/key.c        Wed Jul 12 03:59:32 2017 +0000
@@ -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 <sys/cdefs.h>
-__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 @@
                        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(&lt, sav->lft_c, sizeof(struct sadb_lifetime));
                        lt.sadb_lifetime_addtime =
@@ -4478,11 +4477,7 @@
                                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 @@
                                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 @@
 {
 
        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



Home | Main Index | Thread Index | Old Index