diff options
author | arr <arr@FreeBSD.org> | 2002-05-21 18:52:24 +0000 |
---|---|---|
committer | arr <arr@FreeBSD.org> | 2002-05-21 18:52:24 +0000 |
commit | 37981f345cceca42470a26bc5c4164cbdbd630cb (patch) | |
tree | 3a864b73f84ee96f800b6e857658551c76ef181c /sys/netinet/ip_output.c | |
parent | a491c6f95a0bde0a1667d8dc7d0e50801a057133 (diff) | |
download | FreeBSD-src-37981f345cceca42470a26bc5c4164cbdbd630cb.zip FreeBSD-src-37981f345cceca42470a26bc5c4164cbdbd630cb.tar.gz |
- Change the newly turned INVARIANTS #ifdef blocks (they were changed from
DIAGNOSTIC yesterday) into KASSERT()'s as these help to increase code
readability.
Diffstat (limited to 'sys/netinet/ip_output.c')
-rw-r--r-- | sys/netinet/ip_output.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 818bd94..f553872 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -186,13 +186,11 @@ ip_output(m0, opt, ro, flags, imo) (void)ipsec_setsocket(m, NULL); #endif -#ifdef INVARIANTS - if ((m->m_flags & M_PKTHDR) == 0) - panic("ip_output no HDR"); - if (!ro) - panic("ip_output no route, proto = %d", - mtod(m, struct ip *)->ip_p); -#endif + KASSERT((m->m_flags & M_PKTHDR) != 0, ("ip_output: no HDR")); + + KASSERT(ro != NULL, ("ip_output: no route, proto %d", + mtod(m, struct ip *)->ip_p)); + if (opt) { m = ip_insertoptions(m, opt, &len); hlen = len; @@ -1111,15 +1109,13 @@ ip_optcopy(ip, jp) optlen = 1; continue; } -#ifdef INVARIANTS - if (cnt < IPOPT_OLEN + sizeof(*cp)) - panic("malformed IPv4 option passed to ip_optcopy"); -#endif + + KASSERT(cnt >= IPOPT_OLEN + sizeof(*cp), + ("ip_optcopy: malformed ipv4 option")); optlen = cp[IPOPT_OLEN]; -#ifdef INVARIANTS - if (optlen < IPOPT_OLEN + sizeof(*cp) || optlen > cnt) - panic("malformed IPv4 option passed to ip_optcopy"); -#endif + KASSERT(optlen >= IPOPT_OLEN + sizeof(*cp) && optlen <= cnt, + ("ip_optcopy: malformed ipv4 option")); + /* bogus lengths should have been caught by ip_dooptions */ if (optlen > cnt) optlen = cnt; |