summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2006-03-26 01:33:41 +0000
committerrwatson <rwatson@FreeBSD.org>2006-03-26 01:33:41 +0000
commit46492ab6604a4e31629809cf807aab827d7be8e5 (patch)
treea4c7639265c289cb5190edeaa1dedbf4f837f5b9
parent2f146bc4fd3bffebc6a8e11d8b6705fbfb27e64f (diff)
downloadFreeBSD-src-46492ab6604a4e31629809cf807aab827d7be8e5.zip
FreeBSD-src-46492ab6604a4e31629809cf807aab827d7be8e5.tar.gz
Explicitly assert socket pointer is non-NULL in tcp_input() so as to
provide better debugging information. Prefer explicit comparison to NULL for tcpcb pointers rather than treating them as booleans. MFC after: 1 month
-rw-r--r--sys/netinet/tcp_input.c7
-rw-r--r--sys/netinet/tcp_reass.c7
-rw-r--r--sys/netinet/tcp_timer.c16
3 files changed, 16 insertions, 14 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 836181d..18ccc34 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -784,6 +784,7 @@ findpcb:
goto drop;
#endif
so = inp->inp_socket;
+ KASSERT(so != NULL, ("tcp_input: so == NULL"));
#ifdef TCPDEBUG
if (so->so_options & SO_DEBUG) {
ostate = tp->t_state;
@@ -2552,7 +2553,7 @@ dropwithreset:
(tcp_seq)0, TH_RST|TH_ACK);
}
- if (tp)
+ if (tp != NULL)
INP_UNLOCK(inp);
if (headlocked)
INP_INFO_WUNLOCK(&tcbinfo);
@@ -2563,11 +2564,11 @@ drop:
* Drop space held by incoming segment and return.
*/
#ifdef TCPDEBUG
- if (tp == 0 || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
+ if (tp == NULL || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- if (tp)
+ if (tp != NULL)
INP_UNLOCK(inp);
if (headlocked)
INP_INFO_WUNLOCK(&tcbinfo);
diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c
index 836181d..18ccc34 100644
--- a/sys/netinet/tcp_reass.c
+++ b/sys/netinet/tcp_reass.c
@@ -784,6 +784,7 @@ findpcb:
goto drop;
#endif
so = inp->inp_socket;
+ KASSERT(so != NULL, ("tcp_input: so == NULL"));
#ifdef TCPDEBUG
if (so->so_options & SO_DEBUG) {
ostate = tp->t_state;
@@ -2552,7 +2553,7 @@ dropwithreset:
(tcp_seq)0, TH_RST|TH_ACK);
}
- if (tp)
+ if (tp != NULL)
INP_UNLOCK(inp);
if (headlocked)
INP_INFO_WUNLOCK(&tcbinfo);
@@ -2563,11 +2564,11 @@ drop:
* Drop space held by incoming segment and return.
*/
#ifdef TCPDEBUG
- if (tp == 0 || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
+ if (tp == NULL || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
&tcp_savetcp, 0);
#endif
- if (tp)
+ if (tp != NULL)
INP_UNLOCK(inp);
if (headlocked)
INP_INFO_WUNLOCK(&tcbinfo);
diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c
index b9d24a8..45808af 100644
--- a/sys/netinet/tcp_timer.c
+++ b/sys/netinet/tcp_timer.c
@@ -195,11 +195,11 @@ tcp_timer_2msl(xtp)
tp = tcp_close(tp);
#ifdef TCPDEBUG
- if (tp && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
+ if (tp != NULL && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
PRU_SLOWTIMO);
#endif
- if (tp)
+ if (tp != NULL)
INP_UNLOCK(inp);
INP_INFO_WUNLOCK(&tcbinfo);
}
@@ -353,11 +353,11 @@ dropit:
tp = tcp_drop(tp, ETIMEDOUT);
#ifdef TCPDEBUG
- if (tp && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
+ if (tp != NULL && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
PRU_SLOWTIMO);
#endif
- if (tp)
+ if (tp != NULL)
INP_UNLOCK(tp->t_inpcb);
INP_INFO_WUNLOCK(&tcbinfo);
}
@@ -412,11 +412,11 @@ tcp_timer_persist(xtp)
out:
#ifdef TCPDEBUG
- if (tp && tp->t_inpcb->inp_socket->so_options & SO_DEBUG)
+ if (tp != NULL && tp->t_inpcb->inp_socket->so_options & SO_DEBUG)
tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
PRU_SLOWTIMO);
#endif
- if (tp)
+ if (tp != NULL)
INP_UNLOCK(inp);
INP_INFO_WUNLOCK(&tcbinfo);
}
@@ -560,11 +560,11 @@ tcp_timer_rexmt(xtp)
out:
#ifdef TCPDEBUG
- if (tp && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
+ if (tp != NULL && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0,
PRU_SLOWTIMO);
#endif
- if (tp)
+ if (tp != NULL)
INP_UNLOCK(inp);
if (headlocked)
INP_INFO_WUNLOCK(&tcbinfo);
OpenPOWER on IntegriCloud