From: Amos Jeffries Date: Tue, 24 Jun 2008 11:20:15 +0000 (+1200) Subject: Improved const correctness in IPAddress. X-Git-Tag: SQUID_3_1_0_1~49^2~192 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df9617b960ecd3e025f2bc05bc447fbe1c499a53;p=thirdparty%2Fsquid.git Improved const correctness in IPAddress. --- diff --git a/include/IPAddress.h b/include/IPAddress.h index 1ee310e4c6..5f86819fe2 100644 --- a/include/IPAddress.h +++ b/include/IPAddress.h @@ -232,7 +232,7 @@ public: * Valid results IF and only IF the stored IP address is actually a network bitmask \retval N number of bits which are set in the bitmask stored. */ - int GetCIDR(); + int GetCIDR() const; /** Apply a mask to the stored address. \param mask Netmask format to be bit-mask-AND'd over the stored address. diff --git a/lib/IPAddress.cc b/lib/IPAddress.cc index 1b5deaf721..08b94eb080 100644 --- a/lib/IPAddress.cc +++ b/lib/IPAddress.cc @@ -118,15 +118,15 @@ IPAddress::~IPAddress() } int -IPAddress::GetCIDR() +IPAddress::GetCIDR() const { uint8_t shift,byte; uint8_t bit,caught; int len = 0; #if USE_IPV6 - uint8_t *ptr= m_SocketAddr.sin6_addr.s6_addr; + const uint8_t *ptr= m_SocketAddr.sin6_addr.s6_addr; #else - uint8_t *ptr= (uint8_t *)&m_SocketAddr.sin_addr.s_addr; + const uint8_t *ptr= (uint8_t *)&m_SocketAddr.sin_addr.s_addr; #endif /* Let's scan all the bits from Most Significant to Least */