From 48ed0dec09de247aee778bc857bb088e2e998a88 Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Wed, 13 Jul 2016 13:54:12 +0530 Subject: [PATCH] Make fixes for GCC 6 (#42721) (cherry picked from commit 4116177ac4f17ad0fc54c0fae7d0a8603a855bf6) (cherry picked from commit 2d5581de6e5d6606a8acef041ca808f4b8e24b1b) --- CHANGES | 3 +++ bin/dig/dighost.c | 2 +- bin/named/logconf.c | 18 +++++++++++++++++- lib/dns/rdata/generic/opt_41.c | 2 +- lib/isc/radix.c | 4 ++-- lib/isc/unix/include/isc/offset.h | 13 ------------- lib/isc/win32/include/isc/offset.h | 13 ------------- 7 files changed, 24 insertions(+), 31 deletions(-) diff --git a/CHANGES b/CHANGES index 1053eeac0e..60efcbbbd3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +4412. [cleanup] Make fixes for GCC 6. ISC_OFFSET_MAXIMUM macro was + removed. [RT #42721] + 4409. [bug] DNS64 should exclude mapped addresses by default when an exclude acl is not defined. [RT #42810] diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index ddadc640c6..b60e5dc623 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -2519,7 +2519,7 @@ setup_lookup(dig_lookup_t *lookup) { /* Mask off last address byte */ if (addrl > 0 && (plen % 8) != 0) - addr[addrl - 1] &= ~0 << (8 - (plen % 8)); + addr[addrl - 1] &= ~0U << (8 - (plen % 8)); /* family */ isc_buffer_putuint16(&b, family); diff --git a/bin/named/logconf.c b/bin/named/logconf.c index fd20d5a5ee..9f2b284930 100644 --- a/bin/named/logconf.c +++ b/bin/named/logconf.c @@ -144,6 +144,22 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) cfg_tuple_get(fileobj, "versions"); isc_int32_t versions = ISC_LOG_ROLLNEVER; isc_offset_t size = 0; + isc_uint64_t maxoffset; + + /* + * isc_offset_t is a signed integer type, so the maximum + * value is all 1s except for the MSB. + */ + switch (sizeof(isc_offset_t)) { + case 4: + maxoffset = 0x7fffffffLLU; + break; + case 8: + maxoffset = 0x7fffffffffffffffLLU; + break; + default: + INSIST(0); + } type = ISC_LOG_TOFILE; @@ -154,7 +170,7 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) versions = ISC_LOG_ROLLINFINITE; if (sizeobj != NULL && cfg_obj_isuint64(sizeobj) && - cfg_obj_asuint64(sizeobj) < ISC_OFFSET_MAXIMUM) + cfg_obj_asuint64(sizeobj) < maxoffset) size = (isc_offset_t)cfg_obj_asuint64(sizeobj); dest.file.stream = NULL; dest.file.name = cfg_obj_asstring(pathobj); diff --git a/lib/dns/rdata/generic/opt_41.c b/lib/dns/rdata/generic/opt_41.c index ea0e8cd44c..3df2b2192b 100644 --- a/lib/dns/rdata/generic/opt_41.c +++ b/lib/dns/rdata/generic/opt_41.c @@ -167,7 +167,7 @@ fromwire_opt(ARGS_FROMWIRE) { return (DNS_R_OPTERR); if (addrbytes != 0U && (addrlen % 8) != 0) { - isc_uint8_t bits = ~0 << (8 - (addrlen % 8)); + isc_uint8_t bits = ~0U << (8 - (addrlen % 8)); bits &= sregion.base[addrbytes - 1]; if (bits != sregion.base[addrbytes - 1]) return (DNS_R_OPTERR); diff --git a/lib/isc/radix.c b/lib/isc/radix.c index 1367def320..f562548fd3 100644 --- a/lib/isc/radix.c +++ b/lib/isc/radix.c @@ -129,8 +129,8 @@ _comp_with_mask(void *addr, void *dest, u_int mask) { return (1); if (memcmp(addr, dest, mask / 8) == 0) { - int n = mask / 8; - int m = ((~0) << (8 - (mask % 8))); + u_int n = mask / 8; + u_int m = ((~0U) << (8 - (mask % 8))); if ((mask % 8) == 0 || (((u_char *)addr)[n] & m) == (((u_char *)dest)[n] & m)) diff --git a/lib/isc/unix/include/isc/offset.h b/lib/isc/unix/include/isc/offset.h index 8bf3779997..4c9d4784c5 100644 --- a/lib/isc/unix/include/isc/offset.h +++ b/lib/isc/unix/include/isc/offset.h @@ -30,17 +30,4 @@ typedef off_t isc_offset_t; -/*% - * POSIX says "Additionally, blkcnt_t and off_t are extended signed integral - * types", so the maximum value is all 1s except for the high bit. - * This definition is more complex than it really needs to be because it was - * crafted to keep both the SunOS 5.6 and the HP/UX 11 compilers quiet about - * integer overflow. For example, though this is equivalent to just left - * shifting 1 to the high bit and then inverting the bits, the SunOS compiler - * is unhappy about shifting a positive "1" to negative in a signed integer. - */ -#define ISC_OFFSET_MAXIMUM \ - (~(((off_t)-1 >> (sizeof(off_t) * CHAR_BIT - 1)) \ - << (sizeof(off_t) * CHAR_BIT - 1))) - #endif /* ISC_OFFSET_H */ diff --git a/lib/isc/win32/include/isc/offset.h b/lib/isc/win32/include/isc/offset.h index f22fdce0a1..e66aa518a4 100644 --- a/lib/isc/win32/include/isc/offset.h +++ b/lib/isc/win32/include/isc/offset.h @@ -28,17 +28,4 @@ typedef _off_t isc_offset_t; -/* - * POSIX says "Additionally, blkcnt_t and off_t are extended signed integral - * types", so the maximum value is all 1s except for the high bit. - * This definition is more complex than it really needs to be because it was - * crafted to keep both the SunOS 5.6 and the HP/UX 11 compilers quiet about - * integer overflow. For example, though this is equivalent to just left - * shifting 1 to the high bit and then inverting the bits, the SunOS compiler - * is unhappy about shifting a positive "1" to negative in a signed integer. - */ -#define ISC_OFFSET_MAXIMUM \ - (~(((off_t)-1 >> (sizeof(off_t) * CHAR_BIT - 1)) \ - << (sizeof(off_t) * CHAR_BIT - 1))) - #endif /* ISC_OFFSET_H */