[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] virSocketAddrIsWildcard: Drop IN6_IS_ADDR_UNSPECIFIED

There's this macro IN6_IS_ADDR_UNSPECIFIED which seems to be portable,
but it is not. On other architectures many errors are produced, e.g. on
my ARM box I get:

  CC       libvirt_util_la-virsocketaddr.lo
util/virsocketaddr.c: In function 'virSocketAddrIsWildcard':
util/virsocketaddr.c:244:16: error: cast increases required alignment of target type [-Werror=cast-align]
util/virsocketaddr.c: At top level:
cc1: error: unrecognized command line option "-Wno-unused-command-line-argument" [-Werror]
cc1: all warnings being treated as errors

Hence, we should drop its usage and move to memcmp instead.
 src/util/virsocketaddr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index e84c58e..1cefda7 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -241,7 +241,8 @@ virSocketAddrIsWildcard(const virSocketAddrPtr addr)
         return memcmp(&addr->data.inet4.sin_addr.s_addr, &tmp,
                       sizeof(addr->data.inet4.sin_addr.s_addr)) == 0;
     case AF_INET6:
-        return IN6_IS_ADDR_UNSPECIFIED(&addr->data.inet6.sin6_addr.s6_addr);
+        return memcmp(addr->data.inet6.sin6_addr.s6_addr, &in6addr_any,
+                      sizeof(addr->data.inet6.sin6_addr.s6_addr)) == 0;
     return false;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]