diff --git a/src/core/mac/channel_mask.hpp b/src/core/mac/channel_mask.hpp index 58b2cb7d9..2c7fc8247 100644 --- a/src/core/mac/channel_mask.hpp +++ b/src/core/mac/channel_mask.hpp @@ -234,7 +234,7 @@ public: * @returns TRUE if the two masks are different, FALSE otherwise. * */ - bool operator!=(const ChannelMask &aAnother) const { return (mMask != aAnother.mMask); } + bool operator!=(const ChannelMask &aAnother) const { return !(*this == aAnother); } /** * This method converts the channel mask into a human-readable string. diff --git a/src/core/mac/mac_frame.cpp b/src/core/mac/mac_frame.cpp index b2899c1e8..7d1ae8c33 100644 --- a/src/core/mac/mac_frame.cpp +++ b/src/core/mac/mac_frame.cpp @@ -56,11 +56,6 @@ bool ExtAddress::operator==(const ExtAddress &aOther) const return memcmp(m8, aOther.m8, sizeof(ExtAddress)) == 0; } -bool ExtAddress::operator!=(const ExtAddress &aOther) const -{ - return memcmp(m8, aOther.m8, sizeof(ExtAddress)) != 0; -} - ExtAddress::InfoString ExtAddress::ToString(void) const { return InfoString("%02x%02x%02x%02x%02x%02x%02x%02x", m8[0], m8[1], m8[2], m8[3], m8[4], m8[5], m8[6], m8[7]); @@ -95,11 +90,6 @@ bool ExtendedPanId::operator==(const ExtendedPanId &aOther) const return memcmp(m8, aOther.m8, sizeof(ExtendedPanId)) == 0; } -bool ExtendedPanId::operator!=(const ExtendedPanId &aOther) const -{ - return memcmp(m8, aOther.m8, sizeof(ExtendedPanId)) != 0; -} - ExtendedPanId::InfoString ExtendedPanId::ToString(void) const { return InfoString("%02x%02x%02x%02x%02x%02x%02x%02x", m8[0], m8[1], m8[2], m8[3], m8[4], m8[5], m8[6], m8[7]); diff --git a/src/core/mac/mac_frame.hpp b/src/core/mac/mac_frame.hpp index 8f636890b..9daf15314 100644 --- a/src/core/mac/mac_frame.hpp +++ b/src/core/mac/mac_frame.hpp @@ -223,7 +223,7 @@ public: * @retval FALSE If the Extended Addresses match. * */ - bool operator!=(const ExtAddress &aOther) const; + bool operator!=(const ExtAddress &aOther) const { return !(*this == aOther); } /** * This method converts an address to a string. @@ -463,7 +463,7 @@ public: * @retval FALSE If the Extended Addresses match. * */ - bool operator!=(const ExtendedPanId &aOther) const; + bool operator!=(const ExtendedPanId &aOther) const { return !(*this == aOther); } /** * This method converts an address to a string. diff --git a/src/core/net/ip6_address.cpp b/src/core/net/ip6_address.cpp index a67b150d7..6cdb6805c 100644 --- a/src/core/net/ip6_address.cpp +++ b/src/core/net/ip6_address.cpp @@ -252,11 +252,6 @@ bool Address::operator==(const Address &aOther) const return memcmp(mFields.m8, aOther.mFields.m8, sizeof(mFields.m8)) == 0; } -bool Address::operator!=(const Address &aOther) const -{ - return memcmp(mFields.m8, aOther.mFields.m8, sizeof(mFields.m8)) != 0; -} - otError Address::FromString(const char *aBuf) { otError error = OT_ERROR_NONE; diff --git a/src/core/net/ip6_address.hpp b/src/core/net/ip6_address.hpp index c8927c55c..10e83a8ec 100644 --- a/src/core/net/ip6_address.hpp +++ b/src/core/net/ip6_address.hpp @@ -365,7 +365,7 @@ public: * @retval FALSE If the IPv6 addresses do not differ. * */ - bool operator!=(const Address &aOther) const; + bool operator!=(const Address &aOther) const { return !(*this == aOther); } /** * This method converts an IPv6 address string to binary. diff --git a/src/core/thread/device_mode.hpp b/src/core/thread/device_mode.hpp index b68c99d4b..32507aca2 100644 --- a/src/core/thread/device_mode.hpp +++ b/src/core/thread/device_mode.hpp @@ -221,7 +221,7 @@ public: * @retval FALSE If the device modes are equal. * */ - bool operator!=(const DeviceMode &aOther) const { return (mMode != aOther.mMode); } + bool operator!=(const DeviceMode &aOther) const { return !(*this == aOther); } /** * This method converts the device mode into a human-readable string. diff --git a/src/core/thread/key_manager.hpp b/src/core/thread/key_manager.hpp index 5c23485da..9eab0c160 100644 --- a/src/core/thread/key_manager.hpp +++ b/src/core/thread/key_manager.hpp @@ -85,7 +85,7 @@ public: * @retval FALSE If the Thread Master Keys match. * */ - bool operator!=(const MasterKey &aOther) const { return memcmp(m8, aOther.m8, sizeof(MasterKey)) != 0; } + bool operator!=(const MasterKey &aOther) const { return !(*this == aOther); } } OT_TOOL_PACKED_END;