On 03/19/2009 08:44 AM, Amos Jeffries wrote:
> ------------------------------------------------------------
> revno: 9584
> committer: Amos Jeffries <[email protected]>
> 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?

Reply via email to