PC-Lint warnings fixed:
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 20 Dec 2011 08:55:59 +0000 (06:55 -0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Tue, 20 Dec 2011 08:55:59 +0000 (06:55 -0200)
- Warning 1529: Symbol 'Class::operator=(const Class &)' not first checking for assignment to this

src/host/pinger.cpp
src/icmp/icmpmessage.cpp
src/icmp/icmppacket.cpp
src/tcp/tcpsegment.cpp

index 9de6e80..b841bf9 100644 (file)
@@ -48,8 +48,12 @@ Pinger::~Pinger()
 /**
  * @brief Copy assignment operator.
  */
-Pinger& Pinger::operator=( const Pinger & )
+Pinger& Pinger::operator=( const Pinger &other )
 {
+    // checking for self-assignment (i.e. object1 = object1)
+    if ( &other == this ) {
+        return *this;
+    }
     // TODO: Not implemented at all? Then disable it in the class definition
     return *this;
 }
index 82e3079..b73c30a 100644 (file)
@@ -34,8 +34,13 @@ IcmpMessage::~IcmpMessage()
 /**
  * @brief Copy assignment operator.
  */
-IcmpMessage& IcmpMessage::operator=( const IcmpMessage & )
+IcmpMessage& IcmpMessage::operator=( const IcmpMessage &other )
 {
+    // checking for self-assignment (i.e. object1 = object1)
+    if ( &other == this ) {
+        return *this;
+    }
+
     // TODO: Not implemented at all. Fix it or disable it
     return *this;
 }
index 4372765..e081321 100644 (file)
@@ -48,8 +48,13 @@ IcmpPacket::~IcmpPacket()
 /**
  * @brief Copy assignment operator.
  */
-IcmpPacket& IcmpPacket::operator=( const IcmpPacket & )
+IcmpPacket& IcmpPacket::operator=( const IcmpPacket &other )
 {
+    // checking for self-assignment (i.e. object1 = object1)
+    if ( &other == this ) {
+        return *this;
+    }
+
     // TODO: Not implemented at all. Fix it or disable it
     return *this;
 }
index 43790f3..35234e5 100644 (file)
@@ -48,8 +48,13 @@ TcpSegment::~TcpSegment()
 /**
  * @brief Copy assignment operator.
  */
-TcpSegment& TcpSegment::operator=( const TcpSegment & )
+TcpSegment& TcpSegment::operator=( const TcpSegment &other )
 {
+    // checking for self-assignment (i.e. object1 = object1)
+    if ( &other == this ) {
+        return *this;
+    }
+
     // TODO: Not implemented at all. Fix it or disable it.
     return *this;
 }