If a virSocketAddr has family AF_UNSPEC that means it is
unspecified/empty. If two virSocketAddrs are AF_UNSPEC then they are
equal, but virSocketAddrEqual() was countint that as *not* equal. This
doesn't make a difference for current uses of the function since they
all check that at least one of the virSocketAddrs is *not* AF_UNSPEC
before calling virSocketAddrEqual(), but an upcoming patch using
virSocketAddrEqual() will not be making that check, so let's fix the
utility function.

Signed-off-by: Laine Stump <[email protected]>
---
 src/util/virsocketaddr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index f53768878e..4d4a6b2a0f 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -369,6 +369,8 @@ virSocketAddrEqual(const virSocketAddr *s1, const 
virSocketAddr *s2)
         return false;
 
     switch (s1->data.stor.ss_family) {
+    case AF_UNSPEC:
+        return true;
     case AF_INET:
         return (memcmp(&s1->data.inet4.sin_addr.s_addr,
                        &s2->data.inet4.sin_addr.s_addr,
-- 
2.52.0

Reply via email to