[PATCH 2/2] virSocketAddrIsPrivate: Work on 32bits platforms

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

 



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@xxxxxxxxxx>
---
 src/util/virsocketaddr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index a0c92ea..98cb4ca 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -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 ||
-- 
2.8.3

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]