Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Replace DIAGNOSTIC + panic with KASSERT
details: https://anonhg.NetBSD.org/src/rev/a0fc703325c7
branches: trunk
changeset: 352068:a0fc703325c7
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Tue Mar 14 04:25:10 2017 +0000
description:
Replace DIAGNOSTIC + panic with KASSERT
diffstat:
sys/net/if.c | 10 +++-------
sys/net/rtsock.c | 9 +++------
sys/netinet6/ip6_input.c | 9 +++------
sys/netinet6/nd6_nbr.c | 26 ++++++++------------------
4 files changed, 17 insertions(+), 37 deletions(-)
diffs (145 lines):
diff -r 2abb0751aa18 -r a0fc703325c7 sys/net/if.c
--- a/sys/net/if.c Tue Mar 14 04:24:04 2017 +0000
+++ b/sys/net/if.c Tue Mar 14 04:25:10 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.383 2017/03/09 09:57:36 knakahara Exp $ */
+/* $NetBSD: if.c,v 1.384 2017/03/14 04:25:10 ozaki-r Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.383 2017/03/09 09:57:36 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.384 2017/03/14 04:25:10 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -1371,11 +1371,7 @@
if (family == AF_LINK)
continue;
dp = pffinddomain(family);
-#ifdef DIAGNOSTIC
- if (dp == NULL)
- panic("if_detach: no domain for AF %d",
- family);
-#endif
+ KASSERTMSG(dp != NULL, "no domain for AF %d", family);
/*
* XXX These PURGEIF calls are redundant with the
* purge-all-families calls below, but are left in for
diff -r 2abb0751aa18 -r a0fc703325c7 sys/net/rtsock.c
--- a/sys/net/rtsock.c Tue Mar 14 04:24:04 2017 +0000
+++ b/sys/net/rtsock.c Tue Mar 14 04:25:10 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock.c,v 1.203 2017/03/14 04:23:15 ozaki-r Exp $ */
+/* $NetBSD: rtsock.c,v 1.204 2017/03/14 04:25:10 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.203 2017/03/14 04:23:15 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.204 2017/03/14 04:25:10 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1449,10 +1449,7 @@
default:
continue;
}
-#ifdef DIAGNOSTIC
- if (m == NULL)
- panic("%s: called with wrong command", __func__);
-#endif
+ KASSERTMSG(m != NULL, "called with wrong command");
COMPATNAME(route_enqueue)(m, sa ? sa->sa_family : 0);
}
#undef cmdpass
diff -r 2abb0751aa18 -r a0fc703325c7 sys/netinet6/ip6_input.c
--- a/sys/netinet6/ip6_input.c Tue Mar 14 04:24:04 2017 +0000
+++ b/sys/netinet6/ip6_input.c Tue Mar 14 04:25:10 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_input.c,v 1.176 2017/03/01 08:54:12 ozaki-r Exp $ */
+/* $NetBSD: ip6_input.c,v 1.177 2017/03/14 04:25:10 ozaki-r Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.176 2017/03/01 08:54:12 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.177 2017/03/14 04:25:10 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_gateway.h"
@@ -1322,10 +1322,7 @@
if (mtu == NULL)
return;
-#ifdef DIAGNOSTIC
- if (so == NULL) /* I believe this is impossible */
- panic("ip6_notify_pmtu: socket is NULL");
-#endif
+ KASSERT(so != NULL);
memset(&mtuctl, 0, sizeof(mtuctl)); /* zero-clear for safety */
mtuctl.ip6m_mtu = *mtu;
diff -r 2abb0751aa18 -r a0fc703325c7 sys/netinet6/nd6_nbr.c
--- a/sys/netinet6/nd6_nbr.c Tue Mar 14 04:24:04 2017 +0000
+++ b/sys/netinet6/nd6_nbr.c Tue Mar 14 04:25:10 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6_nbr.c,v 1.137 2017/02/21 03:58:24 ozaki-r Exp $ */
+/* $NetBSD: nd6_nbr.c,v 1.138 2017/03/14 04:25:10 ozaki-r Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.137 2017/02/21 03:58:24 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.138 2017/03/14 04:25:10 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -394,14 +394,9 @@
/* estimate the size of message */
maxlen = sizeof(*ip6) + sizeof(*nd_ns);
maxlen += (sizeof(struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7;
-#ifdef DIAGNOSTIC
- if (max_linkhdr + maxlen >= MCLBYTES) {
- printf("nd6_ns_output: max_linkhdr + maxlen >= MCLBYTES "
- "(%d + %d > %d)\n", max_linkhdr, maxlen, MCLBYTES);
- panic("nd6_ns_output: insufficient MCLBYTES");
- /* NOTREACHED */
- }
-#endif
+ KASSERTMSG(max_linkhdr + maxlen < MCLBYTES,
+ "max_linkhdr + maxlen >= MCLBYTES (%d + %d >= %d)",
+ max_linkhdr, maxlen, MCLBYTES);
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m && max_linkhdr + maxlen >= MHLEN) {
@@ -910,14 +905,9 @@
/* estimate the size of message */
maxlen = sizeof(*ip6) + sizeof(*nd_na);
maxlen += (sizeof(struct nd_opt_hdr) + ifp->if_addrlen + 7) & ~7;
-#ifdef DIAGNOSTIC
- if (max_linkhdr + maxlen >= MCLBYTES) {
- printf("nd6_na_output: max_linkhdr + maxlen >= MCLBYTES "
- "(%d + %d > %d)\n", max_linkhdr, maxlen, MCLBYTES);
- panic("nd6_na_output: insufficient MCLBYTES");
- /* NOTREACHED */
- }
-#endif
+ KASSERTMSG(max_linkhdr + maxlen < MCLBYTES,
+ "max_linkhdr + maxlen >= MCLBYTES (%d + %d >= %d)",
+ max_linkhdr, maxlen, MCLBYTES);
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m && max_linkhdr + maxlen >= MHLEN) {
Home |
Main Index |
Thread Index |
Old Index