From: Leandro Lucarella Date: Fri, 27 Feb 2009 18:15:33 +0000 (-0200) Subject: Fix tipc::sockaddr::operator == () X-Git-Url: https://git.llucax.com/software/posixx.git/commitdiff_plain/11f96e553f3214bd668fecc088d36529d4805e4a?hp=8e9d621e4cf9a60cbf238df92fc60022a1d941cd Fix tipc::sockaddr::operator == () Since sockaddr_tipc has an union, a memcmp() is not enough for comparison, because a currently unused chunk of memory could be different but the addresses are conceptually the same. --- diff --git a/src/linux/tipc.hpp b/src/linux/tipc.hpp index 7c1535a..b16bc51 100644 --- a/src/linux/tipc.hpp +++ b/src/linux/tipc.hpp @@ -689,7 +689,20 @@ inline bool posixx::linux::tipc::sockaddr::operator == (const sockaddr& other) const throw () { - return !memcmp(this, &other, sizeof(*this)); + if (family != other.family) + return false; + if (addrtype != other.addrtype) + return false; + if (scope != other.scope) + return false; + if (addrtype == ID) + return port_id() == other.port_id(); + if (addrtype == NAME) + return name_domain() == other.name_domain() + && port_name() == other.port_name(); + if (addrtype == NAMESEQ) + return name_seq() == other.name_seq(); + return memcmp(this, &other, sizeof(*this)) == 0; } inline