From c4e439ba84e0d6f95e9d247d1c39ae417ecfae6b Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Tue, 20 Dec 2011 06:55:59 -0200 Subject: [PATCH] PC-Lint warnings fixed: - Warning 1529: Symbol 'Class::operator=(const Class &)' not first checking for assignment to this --- src/host/pinger.cpp | 6 +++++- src/icmp/icmpmessage.cpp | 7 ++++++- src/icmp/icmppacket.cpp | 7 ++++++- src/tcp/tcpsegment.cpp | 7 ++++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/host/pinger.cpp b/src/host/pinger.cpp index 9de6e80..b841bf9 100644 --- a/src/host/pinger.cpp +++ b/src/host/pinger.cpp @@ -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; } diff --git a/src/icmp/icmpmessage.cpp b/src/icmp/icmpmessage.cpp index 82e3079..b73c30a 100644 --- a/src/icmp/icmpmessage.cpp +++ b/src/icmp/icmpmessage.cpp @@ -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; } diff --git a/src/icmp/icmppacket.cpp b/src/icmp/icmppacket.cpp index 4372765..e081321 100644 --- a/src/icmp/icmppacket.cpp +++ b/src/icmp/icmppacket.cpp @@ -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; } diff --git a/src/tcp/tcpsegment.cpp b/src/tcp/tcpsegment.cpp index 43790f3..35234e5 100644 --- a/src/tcp/tcpsegment.cpp +++ b/src/tcp/tcpsegment.cpp @@ -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; } -- 1.7.1