1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-11 09:17:52 +03:00

virSocketAddrIsPrivate: Work on 32bits platforms

Yet another one of those where signed int (or long int) is not
enough. And useless to as we're aiming at unsigned anyway.

../../src/util/virsocketaddr.c: In function 'virSocketAddrIsPrivate':
../../src/util/virsocketaddr.c:289:45: error: result of '192l << 24' requires 33 bits to represent, but 'long int' only has 32 bits [-Werror=shift-overflow=]
        return ((val & 0xFFFF0000) == ((192L << 24) + (168 << 16)) ||
                                             ^~
../../src/util/virsocketaddr.c:290:45: error: result of '172l << 24' requires 33 bits to represent, but 'long int' only has 32 bits [-Werror=shift-overflow=]
                (val & 0xFFF00000) == ((172L << 24) + (16  << 16)) ||
                                             ^~
cc1: all warnings being treated as errors

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2016-05-30 15:45:19 +02:00
parent 3864d86385
commit 2bd61c8448

View File

@ -286,9 +286,9 @@ virSocketAddrIsPrivate(const virSocketAddr *addr)
case AF_INET:
val = ntohl(addr->data.inet4.sin_addr.s_addr);
return ((val & 0xFFFF0000) == ((192L << 24) + (168 << 16)) ||
(val & 0xFFF00000) == ((172L << 24) + (16 << 16)) ||
(val & 0xFF000000) == ((10L << 24)));
return ((val & 0xFFFF0000) == ((192UL << 24) + (168 << 16)) ||
(val & 0xFFF00000) == ((172UL << 24) + (16 << 16)) ||
(val & 0xFF000000) == ((10UL << 24)));
case AF_INET6:
return ((addr->data.inet6.sin6_addr.s6_addr[0] & 0xFE) == 0xFC ||