From 659b66eb54ff1bc87ab9fc7ba600503eccd6d8eb Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 19 Oct 2017 16:39:53 +1100 Subject: [PATCH] s/REQUIRE/ISC_REQUIRE/; include if ISC_REQUIRE is used; include if ISC_{UN}LIKELY is used (cherry picked from commit 0fab171196490bde19bbd73831e1a7654649115f) --- lib/dns/include/dns/rbt.h | 11 ++++----- lib/isc/include/isc/assertions.h | 1 + lib/isc/include/isc/buffer.h | 38 +++++++++++++++++--------------- lib/isc/include/isc/error.h | 1 + 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/lib/dns/include/dns/rbt.h b/lib/dns/include/dns/rbt.h index e2f910c2b9..fad97101c6 100644 --- a/lib/dns/include/dns/rbt.h +++ b/lib/dns/include/dns/rbt.h @@ -13,6 +13,7 @@ /*! \file dns/rbt.h */ +#include #include #include #include @@ -1076,7 +1077,7 @@ dns_rbtnodechain_nextflat(dns_rbtnodechain_t *chain, dns_name_t *name); } while (0) #else /* DNS_RBT_USEISCREFCOUNT */ #define dns_rbtnode_refinit(node, n) ((node)->references = (n)) -#define dns_rbtnode_refdestroy(node) REQUIRE((node)->references == 0) +#define dns_rbtnode_refdestroy(node) ISC_REQUIRE((node)->references == 0) #define dns_rbtnode_refcurrent(node) ((node)->references) #if (__STDC_VERSION__ + 0) >= 199901L || defined __GNUC__ @@ -1089,7 +1090,7 @@ dns_rbtnode_refincrement0(dns_rbtnode_t *node, unsigned int *refs) { static inline void dns_rbtnode_refincrement(dns_rbtnode_t *node, unsigned int *refs) { - REQUIRE(node->references > 0); + ISC_REQUIRE(node->references > 0); node->references++; if (refs != NULL) *refs = node->references; @@ -1097,7 +1098,7 @@ dns_rbtnode_refincrement(dns_rbtnode_t *node, unsigned int *refs) { static inline void dns_rbtnode_refdecrement(dns_rbtnode_t *node, unsigned int *refs) { - REQUIRE(node->references > 0); + ISC_REQUIRE(node->references > 0); node->references--; if (refs != NULL) *refs = node->references; @@ -1112,14 +1113,14 @@ dns_rbtnode_refdecrement(dns_rbtnode_t *node, unsigned int *refs) { } while (0) #define dns_rbtnode_refincrement(node, refs) \ do { \ - REQUIRE((node)->references > 0); \ + ISC_REQUIRE((node)->references > 0); \ (node)->references++; \ if ((refs) != NULL) \ (*refs) = (node)->references; \ } while (0) #define dns_rbtnode_refdecrement(node, refs) \ do { \ - REQUIRE((node)->references > 0); \ + ISC_REQUIRE((node)->references > 0); \ (node)->references--; \ if ((refs) != NULL) \ (*refs) = (node)->references; \ diff --git a/lib/isc/include/isc/assertions.h b/lib/isc/include/isc/assertions.h index a3c5ee6077..cb67f61679 100644 --- a/lib/isc/include/isc/assertions.h +++ b/lib/isc/include/isc/assertions.h @@ -16,6 +16,7 @@ #define ISC_ASSERTIONS_H 1 #include +#include #include ISC_LANG_BEGINDECLS diff --git a/lib/isc/include/isc/buffer.h b/lib/isc/include/isc/buffer.h index 6c37983bfd..fd9e470267 100644 --- a/lib/isc/include/isc/buffer.h +++ b/lib/isc/include/isc/buffer.h @@ -96,8 +96,10 @@ *** Imports ***/ +#include #include #include +#include #include #include @@ -878,11 +880,11 @@ ISC_LANG_ENDDECLS #define ISC__BUFFER_PUTMEM(_b, _base, _length) \ do { \ if (ISC_UNLIKELY((_b)->autore)) { \ - isc_buffer_t *tmpbuf = _b; \ - REQUIRE(isc_buffer_reserve(&tmpbuf, _length) \ + isc_buffer_t *_tmp = _b; \ + ISC_REQUIRE(isc_buffer_reserve(&_tmp, _length) \ == ISC_R_SUCCESS); \ } \ - REQUIRE(isc_buffer_availablelength(_b) >= (unsigned int) _length); \ + ISC_REQUIRE(isc_buffer_availablelength(_b) >= (unsigned int) _length); \ memmove(isc_buffer_used(_b), (_base), (_length)); \ (_b)->used += (_length); \ } while (0) @@ -893,11 +895,11 @@ ISC_LANG_ENDDECLS unsigned char *_cp; \ _length = strlen(_source); \ if (ISC_UNLIKELY((_b)->autore)) { \ - isc_buffer_t *tmpbuf = _b; \ - REQUIRE(isc_buffer_reserve(&tmpbuf, _length) \ + isc_buffer_t *_tmp = _b; \ + ISC_REQUIRE(isc_buffer_reserve(&_tmp, _length) \ == ISC_R_SUCCESS); \ } \ - REQUIRE(isc_buffer_availablelength(_b) >= (unsigned int) _length); \ + ISC_REQUIRE(isc_buffer_availablelength(_b) >= (unsigned int) _length); \ _cp = isc_buffer_used(_b); \ memmove(_cp, (_source), _length); \ (_b)->used += (_length); \ @@ -908,11 +910,11 @@ ISC_LANG_ENDDECLS unsigned char *_cp; \ isc_uint8_t _val2 = (_val); \ if (ISC_UNLIKELY((_b)->autore)) { \ - isc_buffer_t *tmpbuf = _b; \ - REQUIRE(isc_buffer_reserve(&tmpbuf, 1) \ + isc_buffer_t *_tmp = _b; \ + ISC_REQUIRE(isc_buffer_reserve(&_tmp, 1) \ == ISC_R_SUCCESS); \ } \ - REQUIRE(isc_buffer_availablelength(_b) >= 1U); \ + ISC_REQUIRE(isc_buffer_availablelength(_b) >= 1U); \ _cp = isc_buffer_used(_b); \ (_b)->used++; \ _cp[0] = _val2 & 0x00ff; \ @@ -923,11 +925,11 @@ ISC_LANG_ENDDECLS unsigned char *_cp; \ isc_uint16_t _val2 = (_val); \ if (ISC_UNLIKELY((_b)->autore)) { \ - isc_buffer_t *tmpbuf = _b; \ - REQUIRE(isc_buffer_reserve(&tmpbuf, 2) \ + isc_buffer_t *_tmp = _b; \ + ISC_REQUIRE(isc_buffer_reserve(&_tmp, 2) \ == ISC_R_SUCCESS); \ } \ - REQUIRE(isc_buffer_availablelength(_b) >= 2U); \ + ISC_REQUIRE(isc_buffer_availablelength(_b) >= 2U); \ _cp = isc_buffer_used(_b); \ (_b)->used += 2; \ _cp[0] = (unsigned char)((_val2 & 0xff00U) >> 8); \ @@ -939,11 +941,11 @@ ISC_LANG_ENDDECLS unsigned char *_cp; \ isc_uint32_t _val2 = (_val); \ if (ISC_UNLIKELY((_b)->autore)) { \ - isc_buffer_t *tmpbuf = _b; \ - REQUIRE(isc_buffer_reserve(&tmpbuf, 3) \ + isc_buffer_t *_tmp = _b; \ + ISC_REQUIRE(isc_buffer_reserve(&_tmp, 3) \ == ISC_R_SUCCESS); \ } \ - REQUIRE(isc_buffer_availablelength(_b) >= 3U); \ + ISC_REQUIRE(isc_buffer_availablelength(_b) >= 3U); \ _cp = isc_buffer_used(_b); \ (_b)->used += 3; \ _cp[0] = (unsigned char)((_val2 & 0xff0000U) >> 16); \ @@ -956,11 +958,11 @@ ISC_LANG_ENDDECLS unsigned char *_cp; \ isc_uint32_t _val2 = (_val); \ if (ISC_UNLIKELY((_b)->autore)) { \ - isc_buffer_t *tmpbuf = _b; \ - REQUIRE(isc_buffer_reserve(&tmpbuf, 4) \ + isc_buffer_t *_tmp = _b; \ + ISC_REQUIRE(isc_buffer_reserve(&_tmp, 4) \ == ISC_R_SUCCESS); \ } \ - REQUIRE(isc_buffer_availablelength(_b) >= 4U); \ + ISC_REQUIRE(isc_buffer_availablelength(_b) >= 4U); \ _cp = isc_buffer_used(_b); \ (_b)->used += 4; \ _cp[0] = (unsigned char)((_val2 & 0xff000000) >> 24); \ diff --git a/lib/isc/include/isc/error.h b/lib/isc/include/isc/error.h index 78804042a2..f808f6d4ef 100644 --- a/lib/isc/include/isc/error.h +++ b/lib/isc/include/isc/error.h @@ -17,6 +17,7 @@ #include #include +#include #include ISC_LANG_BEGINDECLS