From: Sage Weil Date: Wed, 2 Sep 2009 23:05:40 +0000 (-0700) Subject: msgr: fix entity_inst_t comparators X-Git-Tag: v0.14~53 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=85aa24228e3ddde76b98e57952f88f30d532be1f;p=ceph.git msgr: fix entity_inst_t comparators Do not use memcmp on unpacked type entity_inst_t! --- diff --git a/src/msg/msg_types.h b/src/msg/msg_types.h index 8767e811fca..83f38defab9 100644 --- a/src/msg/msg_types.h +++ b/src/msg/msg_types.h @@ -224,12 +224,20 @@ inline void decode(entity_inst_t &i, bufferlist::iterator& p) { decode(i.addr, p); } -inline bool operator==(const entity_inst_t& a, const entity_inst_t& b) { return memcmp(&a, &b, sizeof(a)) == 0; } -inline bool operator!=(const entity_inst_t& a, const entity_inst_t& b) { return memcmp(&a, &b, sizeof(a)) != 0; } -inline bool operator<(const entity_inst_t& a, const entity_inst_t& b) { return memcmp(&a, &b, sizeof(a)) < 0; } -inline bool operator<=(const entity_inst_t& a, const entity_inst_t& b) { return memcmp(&a, &b, sizeof(a)) <= 0; } -inline bool operator>(const entity_inst_t& a, const entity_inst_t& b) { return memcmp(&a, &b, sizeof(a)) > 0; } -inline bool operator>=(const entity_inst_t& a, const entity_inst_t& b) { return memcmp(&a, &b, sizeof(a)) >= 0; } +inline bool operator==(const entity_inst_t& a, const entity_inst_t& b) { + return a.name == b.name && a.addr == b.addr; +} +inline bool operator!=(const entity_inst_t& a, const entity_inst_t& b) { + return a.name != b.name || a.addr != b.addr; +} +inline bool operator<(const entity_inst_t& a, const entity_inst_t& b) { + return a.name < b.name || (a.name == b.name && a.addr < b.addr); +} +inline bool operator<=(const entity_inst_t& a, const entity_inst_t& b) { + return a.name < b.name || (a.name == b.name && a.addr <= b.addr); +} +inline bool operator>(const entity_inst_t& a, const entity_inst_t& b) { return b < a; } +inline bool operator>=(const entity_inst_t& a, const entity_inst_t& b) { return b <= a; } namespace __gnu_cxx { template<> struct hash< entity_inst_t >