From be7f2d54bc1ca21b6bfe9d7415ce780b4db2dbef Mon Sep 17 00:00:00 2001 From: Adrian S Tam Date: Sun, 11 Dec 2011 23:57:15 -0500 Subject: [PATCH] Improve code readability in TCP module. --- src/internet/model/tcp-rx-buffer.cc | 2 +- src/internet/model/tcp-socket-base.cc | 25 +++++-------------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/internet/model/tcp-rx-buffer.cc b/src/internet/model/tcp-rx-buffer.cc index fae478220..703d0b811 100644 --- a/src/internet/model/tcp-rx-buffer.cc +++ b/src/internet/model/tcp-rx-buffer.cc @@ -102,7 +102,7 @@ TcpRxBuffer::IncNextRxSequence () m_nextRxSeq++; } -// Return the highest sequence number that this TcpRxBuffer can accept +// Return the lowest sequence number that this TcpRxBuffer cannot accept SequenceNumber32 TcpRxBuffer::MaxRxSequence (void) const { diff --git a/src/internet/model/tcp-socket-base.cc b/src/internet/model/tcp-socket-base.cc index c01a17ab7..28b6a5714 100644 --- a/src/internet/model/tcp-socket-base.cc +++ b/src/internet/model/tcp-socket-base.cc @@ -258,38 +258,23 @@ TcpSocketBase::Bind (const Address &address) if (ipv4 == Ipv4Address::GetAny () && port == 0) { m_endPoint = m_tcp->Allocate (); - if (0 == m_endPoint) - { - m_errno = ERROR_ADDRNOTAVAIL; - return -1; - } } else if (ipv4 == Ipv4Address::GetAny () && port != 0) { m_endPoint = m_tcp->Allocate (port); - if (0 == m_endPoint) - { - m_errno = ERROR_ADDRINUSE; - return -1; - } } else if (ipv4 != Ipv4Address::GetAny () && port == 0) { m_endPoint = m_tcp->Allocate (ipv4); - if (0 == m_endPoint) - { - m_errno = ERROR_ADDRNOTAVAIL; - return -1; - } } else if (ipv4 != Ipv4Address::GetAny () && port != 0) { m_endPoint = m_tcp->Allocate (ipv4, port); - if (0 == m_endPoint) - { - m_errno = ERROR_ADDRINUSE; - return -1; - } + } + if (0 == m_endPoint) + { + m_errno = port ? ERROR_ADDRINUSE : ERROR_ADDRNOTAVAIL; + return -1; } m_tcp->m_sockets.push_back (this); NS_LOG_LOGIC ("TcpSocketBase " << this << " got an endpoint: " << m_endPoint);