Re: /bzr/squid3/trunk/ r9584: Various errors detected by Coverity scan

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Thu, 19 Mar 2009 13:31:20 -0600

On 03/19/2009 08:44 AM, Amos Jeffries wrote:
> ------------------------------------------------------------
> revno: 9584
> committer: Amos Jeffries <squid3_at_treenet.co.nz>
> branch nick: trunk
> timestamp: Fri 2009-03-20 03:44:22 +1300
> message:
> Various errors detected by Coverity scan

=== modified file 'src/ip/IpAddress.cc'
--- a/src/ip/IpAddress.cc 2009-03-10 14:29:30 +0000
+++ b/src/ip/IpAddress.cc 2009-03-19 14:44:22 +0000
@@ -651,10 +651,8 @@

 IpAddress& IpAddress::operator =(IpAddress *s)
 {
- IpAddress *tmp = NULL;
     if (!s) return *this;
- tmp = dynamic_cast<IpAddress*>(s);
- if (!tmp) return *this;
+ IpAddress *tmp = static_cast<IpAddress*>(s);
     return operator=(*tmp);
 }

Is there a reason to cast "s" to its own type?

Thanks,

Alex.
P.S. The assignment operator above essentially converts a "pointer to an
IP address" to an "IP address", which is, to put it mildly, strange. Do
we really need this operator?
Received on Thu Mar 19 2009 - 19:31:29 MDT

This archive was generated by hypermail 2.2.0 : Fri Mar 20 2009 - 12:00:04 MDT