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

Re: [libvirt] [PATCH] virSocketAddrIsWildcard: Drop IN6_IS_ADDR_UNSPECIFIED



Hi Michal,

The IN6_IS_ADDR_UNSPECIFIED() function needs a struct in6_addr as argument. So changing the line in this way:

-        return IN6_IS_ADDR_UNSPECIFIED(&addr->data.inet6.sin6_addr.s6_addr);
+        return IN6_IS_ADDR_UNSPECIFIED(&addr->data.inet6.sin6_addr);

it should work.

Regards,



On Mon, Jun 10, 2013 at 12:31 PM, Michal Privoznik <mprivozn redhat com> wrote:
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;
 }
--
1.8.1.5

--
libvir-list mailing list
libvir-list redhat com
https://www.redhat.com/mailman/listinfo/libvir-list



--
Michele Paolino 
Virtual Open Systems
Open Source  KVM  Virtualization  Developments
Multicore Systems Virtualization Porting Services
Web: www.virtualopensystems.com

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