diff --git a/cocci/dns_message_create.spatch b/cocci/dns_message_create.spatch index bab6d587f6..74d290e419 100644 --- a/cocci/dns_message_create.spatch +++ b/cocci/dns_message_create.spatch @@ -66,15 +66,6 @@ expression V; dns_message_create(...); - CHECK(..., V); -@@ -expression V; -statement S; -@@ - -- V = - dns_message_create(...); -- if (ISC_UNLIKELY(V != ISC_R_SUCCESS)) S - @@ expression V; @@ diff --git a/cocci/isc_buffer_allocate_never_fail.spatch b/cocci/isc_buffer_allocate_never_fail.spatch index b632e4e3b9..bc02f1429e 100644 --- a/cocci/isc_buffer_allocate_never_fail.spatch +++ b/cocci/isc_buffer_allocate_never_fail.spatch @@ -66,15 +66,6 @@ expression V; isc_buffer_allocate(...); - CHECK(..., V); -@@ -expression V; -statement S; -@@ - -- V = - isc_buffer_allocate(...); -- if (ISC_UNLIKELY(V != ISC_R_SUCCESS)) S - @@ expression V; @@ diff --git a/lib/dns/compress.c b/lib/dns/compress.c index 01d2d31225..2ed8b29fe1 100644 --- a/lib/dns/compress.c +++ b/lib/dns/compress.c @@ -227,7 +227,7 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name, REQUIRE(dns_name_isabsolute(name)); REQUIRE(offset != NULL); - if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0)) { + if ((cctx->allowed & DNS_COMPRESS_ENABLED) == 0) { return (false); } @@ -256,16 +256,14 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name, */ ch = p[1]; i = tableindex[ch]; - if (ISC_LIKELY((cctx->allowed & DNS_COMPRESS_CASESENSITIVE) != - 0)) { + if ((cctx->allowed & DNS_COMPRESS_CASESENSITIVE) != 0) { for (node = cctx->table[i]; node != NULL; node = node->next) { - if (ISC_UNLIKELY(node->name.length != length)) { + if (node->name.length != length) { continue; } - if (ISC_LIKELY(memcmp(node->name.ndata, p, - length) == 0)) { + if (memcmp(node->name.ndata, p, length) == 0) { goto found; } } @@ -276,18 +274,18 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name, unsigned char c; unsigned char *label1, *label2; - if (ISC_UNLIKELY(node->name.length != length)) { + if (node->name.length != length) { continue; } l = labels - n; - if (ISC_UNLIKELY(node->name.labels != l)) { + if (node->name.labels != l) { continue; } label1 = node->name.ndata; label2 = p; - while (ISC_LIKELY(l-- > 0)) { + while (l-- > 0) { count = *label1++; if (count != *label2++) { goto cont1; @@ -297,7 +295,7 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name, INSIST(count <= 63); /* Loop unrolled for performance */ - while (ISC_LIKELY(count > 3)) { + while (count > 3) { c = maptolower[label1[0]]; if (c != maptolower[label2[0]]) { @@ -322,7 +320,7 @@ dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name, label1 += 4; label2 += 4; } - while (ISC_LIKELY(count-- > 0)) { + while (count-- > 0) { c = maptolower[*label1++]; if (c != maptolower[*label2++]) { @@ -388,7 +386,7 @@ dns_compress_add(dns_compress_t *cctx, const dns_name_t *name, REQUIRE(VALID_CCTX(cctx)); REQUIRE(dns_name_isabsolute(name)); - if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0)) { + if ((cctx->allowed & DNS_COMPRESS_ENABLED) == 0) { return; } @@ -489,7 +487,7 @@ dns_compress_rollback(dns_compress_t *cctx, uint16_t offset) { REQUIRE(VALID_CCTX(cctx)); - if (ISC_UNLIKELY((cctx->allowed & DNS_COMPRESS_ENABLED) == 0)) { + if ((cctx->allowed & DNS_COMPRESS_ENABLED) == 0) { return; } diff --git a/lib/dns/message.c b/lib/dns/message.c index 76bf8435b0..3ecf79b273 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -835,7 +835,7 @@ dns_message_findtype(const dns_name_t *name, dns_rdatatype_t type, curr = ISC_LIST_PREV(curr, link)) { if (curr->type == type && curr->covers == covers) { - if (ISC_UNLIKELY(rdataset != NULL)) { + if (rdataset != NULL) { *rdataset = curr; } return (ISC_R_SUCCESS); @@ -2450,7 +2450,7 @@ dns_message_findname(dns_message_t *msg, dns_section_t section, /* * And now look for the type. */ - if (ISC_UNLIKELY(type == dns_rdatatype_any)) { + if (type == dns_rdatatype_any) { return (ISC_R_SUCCESS); } diff --git a/lib/dns/name.c b/lib/dns/name.c index 909064c19d..295a527188 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -514,7 +514,7 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2, REQUIRE((name1->attributes & DNS_NAMEATTR_ABSOLUTE) == (name2->attributes & DNS_NAMEATTR_ABSOLUTE)); - if (ISC_UNLIKELY(name1 == name2)) { + if (name1 == name2) { *orderp = 0; *nlabelsp = name1->labels; return (dns_namereln_equal); @@ -537,7 +537,7 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2, offsets1 += l1; offsets2 += l2; - while (ISC_LIKELY(l > 0)) { + while (l > 0) { l--; offsets1--; offsets2--; @@ -560,7 +560,7 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2, } /* Loop unrolled for performance */ - while (ISC_LIKELY(count > 3)) { + while (count > 3) { chdiff = (int)maptolower[label1[0]] - (int)maptolower[label2[0]]; if (chdiff != 0) { @@ -589,7 +589,7 @@ dns_name_fullcompare(const dns_name_t *name1, const dns_name_t *name2, label1 += 4; label2 += 4; } - while (ISC_LIKELY(count-- > 0)) { + while (count-- > 0) { chdiff = (int)maptolower[*label1++] - (int)maptolower[*label2++]; if (chdiff != 0) { @@ -667,7 +667,7 @@ dns_name_equal(const dns_name_t *name1, const dns_name_t *name2) { REQUIRE((name1->attributes & DNS_NAMEATTR_ABSOLUTE) == (name2->attributes & DNS_NAMEATTR_ABSOLUTE)); - if (ISC_UNLIKELY(name1 == name2)) { + if (name1 == name2) { return (true); } @@ -683,7 +683,7 @@ dns_name_equal(const dns_name_t *name1, const dns_name_t *name2) { label1 = name1->ndata; label2 = name2->ndata; - while (ISC_LIKELY(l-- > 0)) { + while (l-- > 0) { count = *label1++; if (count != *label2++) { return (false); @@ -692,7 +692,7 @@ dns_name_equal(const dns_name_t *name1, const dns_name_t *name2) { INSIST(count <= 63); /* no bitstring support */ /* Loop unrolled for performance */ - while (ISC_LIKELY(count > 3)) { + while (count > 3) { c = maptolower[label1[0]]; if (c != maptolower[label2[0]]) { return (false); @@ -713,7 +713,7 @@ dns_name_equal(const dns_name_t *name1, const dns_name_t *name2) { label1 += 4; label2 += 4; } - while (ISC_LIKELY(count-- > 0)) { + while (count-- > 0) { c = maptolower[*label1++]; if (c != maptolower[*label2++]) { return (false); @@ -923,7 +923,7 @@ dns_name_getlabelsequence(const dns_name_t *source, unsigned int first, REQUIRE(BINDABLE(target)); p = source->ndata; - if (ISC_UNLIKELY(first == source->labels)) { + if (first == source->labels) { firstoffset = source->length; } else { for (i = 0; i < first; i++) { @@ -933,7 +933,7 @@ dns_name_getlabelsequence(const dns_name_t *source, unsigned int first, firstoffset = (unsigned int)(p - source->ndata); } - if (ISC_LIKELY(first + n == source->labels)) { + if (first + n == source->labels) { endoffset = source->length; } else { for (i = 0; i < n; i++) { @@ -1714,7 +1714,7 @@ set_offsets(const dns_name_t *name, unsigned char *offsets, offset = 0; nlabels = 0; absolute = false; - while (ISC_LIKELY(offset != length)) { + while (offset != length) { INSIST(nlabels < 128); offsets[nlabels++] = offset; count = *ndata; @@ -1722,7 +1722,7 @@ set_offsets(const dns_name_t *name, unsigned char *offsets, offset += count + 1; ndata += count + 1; INSIST(offset <= length); - if (ISC_UNLIKELY(count == 0)) { + if (count == 0) { absolute = true; break; } @@ -1961,7 +1961,7 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx, (name->attributes & DNS_NAMEATTR_NOCOMPRESS) == 0 && (methods & DNS_COMPRESS_GLOBAL14) != 0) { - if (ISC_UNLIKELY(target->length - target->used < 2)) { + if (target->length - target->used < 2) { return (ISC_R_NOSPACE); } offset = *comp_offsetp; @@ -2001,7 +2001,7 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx, * If the offset is too high for 14 bit global compression, we're * out of luck. */ - if (gf && ISC_UNLIKELY(go >= 0x4000)) { + if (gf && go >= 0x4000) { gf = false; } @@ -2013,7 +2013,7 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx, } if (gf) { - if (ISC_UNLIKELY(target->length - target->used < gp.length)) { + if (target->length - target->used < gp.length) { return (ISC_R_NOSPACE); } if (gp.length != 0) { @@ -2022,7 +2022,7 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx, (size_t)gp.length); } isc_buffer_add(target, gp.length); - if (ISC_UNLIKELY(target->length - target->used < 2)) { + if (target->length - target->used < 2) { return (ISC_R_NOSPACE); } isc_buffer_putuint16(target, go | 0xc000); @@ -2035,8 +2035,7 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx, *comp_offsetp = go; } } else { - if (ISC_UNLIKELY(target->length - target->used < name->length)) - { + if (target->length - target->used < name->length) { return (ISC_R_NOSPACE); } if (name->length != 0) { diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c index 05f6e2d2ec..b8e8a6c9e6 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -258,9 +258,8 @@ maybe_rehash(dns_rbt_t *rbt, size_t size); static inline bool rehashing_in_progress(dns_rbt_t *rbt); -#define TRY_NEXTTABLE(hindex, rbt) \ - (ISC_LIKELY(hindex == rbt->hindex) && \ - ISC_UNLIKELY(rehashing_in_progress(rbt))) +#define TRY_NEXTTABLE(hindex, rbt) \ + (hindex == rbt->hindex && rehashing_in_progress(rbt)) static inline void rotate_left(dns_rbtnode_t *node, dns_rbtnode_t **rootp); @@ -507,7 +506,7 @@ dns_rbt_addnode(dns_rbt_t *rbt, const dns_name_t *name, dns_rbtnode_t **nodep) { INSIST(add_name != NULL); dns_name_clone(name, add_name); - if (ISC_UNLIKELY(rbt->root == NULL)) { + if (rbt->root == NULL) { result = create_node(rbt->mctx, add_name, &new_current); if (result == ISC_R_SUCCESS) { rbt->nodecount++; @@ -738,13 +737,13 @@ dns_rbt_addnode(dns_rbt_t *rbt, const dns_name_t *name, dns_rbtnode_t **nodep) { } } } - } while (ISC_LIKELY(child != NULL)); + } while (child != NULL); - if (ISC_LIKELY(result == ISC_R_SUCCESS)) { + if (result == ISC_R_SUCCESS) { result = create_node(rbt->mctx, add_name, &new_current); } - if (ISC_LIKELY(result == ISC_R_SUCCESS)) { + if (result == ISC_R_SUCCESS) { if (*root == NULL) { UPPERNODE(new_current) = current; } else { @@ -828,7 +827,7 @@ dns_rbt_findnode(dns_rbt_t *rbt, const dns_name_t *name, dns_name_t *foundname, dns_rbtnodechain_reset(chain); } - if (ISC_UNLIKELY(rbt->root == NULL)) { + if (rbt->root == NULL) { return (ISC_R_NOTFOUND); } @@ -858,7 +857,7 @@ dns_rbt_findnode(dns_rbt_t *rbt, const dns_name_t *name, dns_name_t *foundname, saved_result = ISC_R_SUCCESS; current = rbt->root; - while (ISC_LIKELY(current != NULL)) { + while (current != NULL) { NODENAME(current, ¤t_name); compared = dns_name_fullcompare(search_name, ¤t_name, &order, &common_labels); @@ -945,7 +944,7 @@ dns_rbt_findnode(dns_rbt_t *rbt, const dns_name_t *name, dns_name_t *foundname, { dns_name_t hnode_name; - if (ISC_LIKELY(hashval != HASHVAL(hnode))) { + if (hashval != HASHVAL(hnode)) { continue; } /* @@ -954,15 +953,13 @@ dns_rbt_findnode(dns_rbt_t *rbt, const dns_name_t *name, dns_name_t *foundname, * that we don't match a labelsequence from some * other subdomain. */ - if (ISC_LIKELY(get_upper_node(hnode) != - up_current)) { + if (get_upper_node(hnode) != up_current) { continue; } dns_name_init(&hnode_name, NULL); NODENAME(hnode, &hnode_name); - if (ISC_LIKELY(dns_name_equal(&hnode_name, - &hash_name))) { + if (dns_name_equal(&hnode_name, &hash_name)) { break; } } @@ -1760,10 +1757,10 @@ static inline void hash_node(dns_rbt_t *rbt, dns_rbtnode_t *node, const dns_name_t *name) { REQUIRE(DNS_RBTNODE_VALID(node)); - if (ISC_UNLIKELY(rehashing_in_progress(rbt))) { + if (rehashing_in_progress(rbt)) { /* Rehash in progress */ hashtable_rehash_one(rbt); - } else if (ISC_UNLIKELY(hashtable_is_overcommited(rbt))) { + } else if (hashtable_is_overcommited(rbt)) { /* Rehash requested */ maybe_rehash(rbt, rbt->nodecount); } diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 602a62cdc4..8cc29119f9 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -9360,7 +9360,7 @@ setownercase(rdatasetheader_t *header, const dns_name_t *name) { } } RDATASET_ATTR_SET(header, RDATASET_ATTR_CASESET); - if (ISC_LIKELY(fully_lower)) { + if (fully_lower) { RDATASET_ATTR_SET(header, RDATASET_ATTR_CASEFULLYLOWER); } } @@ -9399,7 +9399,7 @@ rdataset_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) { goto unlock; } - if (ISC_LIKELY(CASEFULLYLOWER(header))) { + if (CASEFULLYLOWER(header)) { for (size_t i = 0; i < name->length; i++) { name->ndata[i] = tolower(name->ndata[i]); } @@ -9568,7 +9568,7 @@ static void maybe_rehash_gluetable(rbtdb_version_t *version) { size_t overcommit = HASHSIZE(version->glue_table_bits) * RBTDB_GLUE_TABLE_OVERCOMMIT; - if (ISC_LIKELY(version->glue_table_nodecount < overcommit)) { + if (version->glue_table_nodecount < overcommit) { return; } @@ -9775,7 +9775,7 @@ restart: dns_name_t *gluename = dns_fixedname_name(&ge->fixedname); result = dns_message_gettempname(msg, &name); - if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) { + if (result != ISC_R_SUCCESS) { goto no_glue; } @@ -9783,7 +9783,7 @@ restart: if (dns_rdataset_isassociated(&ge->rdataset_a)) { result = dns_message_gettemprdataset(msg, &rdataset_a); - if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) { + if (result != ISC_R_SUCCESS) { dns_message_puttempname(msg, &name); goto no_glue; } @@ -9792,7 +9792,7 @@ restart: if (dns_rdataset_isassociated(&ge->sigrdataset_a)) { result = dns_message_gettemprdataset(msg, &sigrdataset_a); - if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) { + if (result != ISC_R_SUCCESS) { if (rdataset_a != NULL) { dns_message_puttemprdataset( msg, &rdataset_a); @@ -9805,7 +9805,7 @@ restart: if (dns_rdataset_isassociated(&ge->rdataset_aaaa)) { result = dns_message_gettemprdataset(msg, &rdataset_aaaa); - if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) { + if (result != ISC_R_SUCCESS) { dns_message_puttempname(msg, &name); if (rdataset_a != NULL) { dns_message_puttemprdataset( @@ -9822,7 +9822,7 @@ restart: if (dns_rdataset_isassociated(&ge->sigrdataset_aaaa)) { result = dns_message_gettemprdataset(msg, &sigrdataset_aaaa); - if (ISC_UNLIKELY(result != ISC_R_SUCCESS)) { + if (result != ISC_R_SUCCESS) { dns_message_puttempname(msg, &name); if (rdataset_a != NULL) { dns_message_puttemprdataset( @@ -9840,7 +9840,7 @@ restart: } } - if (ISC_LIKELY(rdataset_a != NULL)) { + if (rdataset_a != NULL) { dns_rdataset_clone(&ge->rdataset_a, rdataset_a); ISC_LIST_APPEND(name->list, rdataset_a, link); } diff --git a/lib/dns/rdataset.c b/lib/dns/rdataset.c index c51916e7dd..6cd95ea0d2 100644 --- a/lib/dns/rdataset.c +++ b/lib/dns/rdataset.c @@ -406,18 +406,17 @@ towiresorted(dns_rdataset_t *rdataset, const dns_name_t *owner_name, } INSIST(i == count); - if (ISC_LIKELY(want_random)) { + if (want_random) { seed = isc_random32(); } - if (ISC_UNLIKELY(want_cyclic) && - (rdataset->count != DNS_RDATASET_COUNT_UNDEFINED)) - { + if (want_cyclic && + (rdataset->count != DNS_RDATASET_COUNT_UNDEFINED)) { j = rdataset->count % count; } for (i = 0; i < count; i++) { - if (ISC_LIKELY(want_random)) { + if (want_random) { swap_rdata(in, j, j + seed % (count - j)); } diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 1402dd786f..8e2e85ae62 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -4963,7 +4963,7 @@ same_question(fetchctx_t *fctx, dns_message_t *message) { /* * XXXRTH Currently we support only one question. */ - if (ISC_UNLIKELY(message->counts[DNS_SECTION_QUESTION] == 0)) { + if (message->counts[DNS_SECTION_QUESTION] == 0) { if ((message->flags & DNS_MESSAGEFLAG_TC) != 0) { /* * If TC=1 and the question section is empty, we @@ -4987,7 +4987,7 @@ same_question(fetchctx_t *fctx, dns_message_t *message) { log_formerr(fctx, "empty question section"); return (DNS_R_FORMERR); } - } else if (ISC_UNLIKELY(message->counts[DNS_SECTION_QUESTION] > 1)) { + } else if (message->counts[DNS_SECTION_QUESTION] > 1) { log_formerr(fctx, "too many questions"); return (DNS_R_FORMERR); } diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index b5f882b364..ffca94bc7a 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -1087,7 +1087,7 @@ diff_keys(const dns_rpz_cidr_key_t *key1, dns_rpz_prefix_t prefix1, */ for (i = 0; bit < maxbit; i++, bit += DNS_RPZ_CIDR_WORD_BITS) { delta = key1->w[i] ^ key2->w[i]; - if (ISC_UNLIKELY(delta != 0)) { + if (delta != 0) { #ifdef HAVE_BUILTIN_CLZ bit += __builtin_clz(delta); #else /* ifdef HAVE_BUILTIN_CLZ */ diff --git a/lib/isc/Makefile.am b/lib/isc/Makefile.am index 3ee7cc2fa9..639b1b7b2d 100644 --- a/lib/isc/Makefile.am +++ b/lib/isc/Makefile.am @@ -45,7 +45,6 @@ libisc_la_HEADERS = \ include/isc/iterated_hash.h \ include/isc/lang.h \ include/isc/lex.h \ - include/isc/likely.h \ include/isc/list.h \ include/isc/log.h \ include/isc/magic.h \ diff --git a/lib/isc/buffer.c b/lib/isc/buffer.c index 05bf4143b4..46b38ff2f7 100644 --- a/lib/isc/buffer.c +++ b/lib/isc/buffer.c @@ -292,7 +292,7 @@ void isc__buffer_putuint8(isc_buffer_t *b, uint8_t val) { isc_result_t result; REQUIRE(ISC_BUFFER_VALID(b)); - if (ISC_UNLIKELY(b->autore)) { + if (b->autore) { result = isc_buffer_reserve(&b, 1); REQUIRE(result == ISC_R_SUCCESS); } @@ -326,7 +326,7 @@ void isc__buffer_putuint16(isc_buffer_t *b, uint16_t val) { isc_result_t result; REQUIRE(ISC_BUFFER_VALID(b)); - if (ISC_UNLIKELY(b->autore)) { + if (b->autore) { result = isc_buffer_reserve(&b, 2); REQUIRE(result == ISC_R_SUCCESS); } @@ -339,7 +339,7 @@ void isc__buffer_putuint24(isc_buffer_t *b, uint32_t val) { isc_result_t result; REQUIRE(ISC_BUFFER_VALID(b)); - if (ISC_UNLIKELY(b->autore)) { + if (b->autore) { result = isc_buffer_reserve(&b, 3); REQUIRE(result == ISC_R_SUCCESS); } @@ -375,7 +375,7 @@ void isc__buffer_putuint32(isc_buffer_t *b, uint32_t val) { isc_result_t result; REQUIRE(ISC_BUFFER_VALID(b)); - if (ISC_UNLIKELY(b->autore)) { + if (b->autore) { result = isc_buffer_reserve(&b, 4); REQUIRE(result == ISC_R_SUCCESS); } @@ -416,7 +416,7 @@ isc__buffer_putuint48(isc_buffer_t *b, uint64_t val) { uint32_t vallo; REQUIRE(ISC_BUFFER_VALID(b)); - if (ISC_UNLIKELY(b->autore)) { + if (b->autore) { result = isc_buffer_reserve(&b, 6); REQUIRE(result == ISC_R_SUCCESS); } @@ -433,7 +433,7 @@ isc__buffer_putmem(isc_buffer_t *b, const unsigned char *base, unsigned int length) { isc_result_t result; REQUIRE(ISC_BUFFER_VALID(b)); - if (ISC_UNLIKELY(b->autore)) { + if (b->autore) { result = isc_buffer_reserve(&b, length); REQUIRE(result == ISC_R_SUCCESS); } @@ -455,7 +455,7 @@ isc__buffer_putstr(isc_buffer_t *b, const char *source) { * Do not use ISC__BUFFER_PUTSTR(), so strlen is only done once. */ l = strlen(source); - if (ISC_UNLIKELY(b->autore)) { + if (b->autore) { result = isc_buffer_reserve(&b, l); REQUIRE(result == ISC_R_SUCCESS); } @@ -478,7 +478,7 @@ isc_buffer_putdecint(isc_buffer_t *b, int64_t v) { /* xxxwpk do it more low-level way ? */ l = snprintf(buf, 21, "%" PRId64, v); RUNTIME_CHECK(l <= 21); - if (ISC_UNLIKELY(b->autore)) { + if (b->autore) { result = isc_buffer_reserve(&b, l); REQUIRE(result == ISC_R_SUCCESS); } @@ -515,7 +515,7 @@ isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r) { REQUIRE(ISC_BUFFER_VALID(b)); REQUIRE(r != NULL); - if (ISC_UNLIKELY(b->autore)) { + if (b->autore) { result = isc_buffer_reserve(&b, r->length); if (result != ISC_R_SUCCESS) { return (result); @@ -623,7 +623,7 @@ isc_buffer_printf(isc_buffer_t *b, const char *format, ...) { return (ISC_R_FAILURE); } - if (ISC_UNLIKELY(b->autore)) { + if (b->autore) { result = isc_buffer_reserve(&b, n + 1); if (result != ISC_R_SUCCESS) { return (result); diff --git a/lib/isc/hash.c b/lib/isc/hash.c index 6f3c701c6a..d73c570109 100644 --- a/lib/isc/hash.c +++ b/lib/isc/hash.c @@ -15,7 +15,6 @@ #include "entropy_private.h" #include "isc/hash.h" /* IWYU pragma: keep */ -#include "isc/likely.h" #include "isc/once.h" #include "isc/random.h" #include "isc/result.h" @@ -74,7 +73,7 @@ static uint8_t maptolower[] = { const void * isc_hash_get_initializer(void) { - if (ISC_UNLIKELY(!hash_initialized)) { + if (!hash_initialized) { RUNTIME_CHECK( isc_once_do(&isc_hash_once, isc_hash_initialize) == ISC_R_SUCCESS); @@ -91,7 +90,7 @@ isc_hash_set_initializer(const void *initializer) { * Ensure that isc_hash_initialize() is not called after * isc_hash_set_initializer() is called. */ - if (ISC_UNLIKELY(!hash_initialized)) { + if (!hash_initialized) { RUNTIME_CHECK( isc_once_do(&isc_hash_once, isc_hash_initialize) == ISC_R_SUCCESS); diff --git a/lib/isc/hmac.c b/lib/isc/hmac.c index b3940de52f..de5d453521 100644 --- a/lib/isc/hmac.c +++ b/lib/isc/hmac.c @@ -31,7 +31,7 @@ isc_hmac_new(void) { void isc_hmac_free(isc_hmac_t *hmac) { - if (ISC_UNLIKELY(hmac == NULL)) { + if (hmac == NULL) { return; } @@ -70,7 +70,7 @@ isc_result_t isc_hmac_update(isc_hmac_t *hmac, const unsigned char *buf, const size_t len) { REQUIRE(hmac != NULL); - if (ISC_UNLIKELY(buf == NULL || len == 0)) { + if (buf == NULL || len == 0) { return (ISC_R_SUCCESS); } diff --git a/lib/isc/include/isc/assertions.h b/lib/isc/include/isc/assertions.h index 5de20ce06c..7c22a0f634 100644 --- a/lib/isc/include/isc/assertions.h +++ b/lib/isc/include/isc/assertions.h @@ -16,7 +16,6 @@ #include #include -#include ISC_LANG_BEGINDECLS @@ -42,25 +41,25 @@ const char * isc_assertion_typetotext(isc_assertiontype_t type); #define ISC_REQUIRE(cond) \ - ((void)(ISC_LIKELY(cond) || \ + ((void)((cond) || \ ((isc_assertion_failed)(__FILE__, __LINE__, \ isc_assertiontype_require, #cond), \ 0))) #define ISC_ENSURE(cond) \ - ((void)(ISC_LIKELY(cond) || \ + ((void)((cond) || \ ((isc_assertion_failed)(__FILE__, __LINE__, \ isc_assertiontype_ensure, #cond), \ 0))) #define ISC_INSIST(cond) \ - ((void)(ISC_LIKELY(cond) || \ + ((void)((cond) || \ ((isc_assertion_failed)(__FILE__, __LINE__, \ isc_assertiontype_insist, #cond), \ 0))) #define ISC_INVARIANT(cond) \ - ((void)(ISC_LIKELY(cond) || \ + ((void)((cond) || \ ((isc_assertion_failed)(__FILE__, __LINE__, \ isc_assertiontype_invariant, #cond), \ 0))) diff --git a/lib/isc/include/isc/buffer.h b/lib/isc/include/isc/buffer.h index 9ecdc8aea4..062ee3e986 100644 --- a/lib/isc/include/isc/buffer.h +++ b/lib/isc/include/isc/buffer.h @@ -104,7 +104,6 @@ #include #include #include -#include #include #include @@ -899,7 +898,7 @@ ISC_LANG_ENDDECLS #define ISC__BUFFER_PUTMEM(_b, _base, _length) \ do { \ - if (ISC_UNLIKELY((_b)->autore)) { \ + if ((_b)->autore) { \ isc_buffer_t *_tmp = _b; \ ISC_REQUIRE(isc_buffer_reserve(&_tmp, _length) == \ ISC_R_SUCCESS); \ @@ -917,7 +916,7 @@ ISC_LANG_ENDDECLS unsigned int _length; \ unsigned char *_cp; \ _length = (unsigned int)strlen(_source); \ - if (ISC_UNLIKELY((_b)->autore)) { \ + if ((_b)->autore) { \ isc_buffer_t *_tmp = _b; \ ISC_REQUIRE(isc_buffer_reserve(&_tmp, _length) == \ ISC_R_SUCCESS); \ @@ -933,7 +932,7 @@ ISC_LANG_ENDDECLS unsigned char *_cp; \ /* evaluate (_val) only once */ \ uint8_t _val2 = (_val); \ - if (ISC_UNLIKELY((_b)->autore)) { \ + if ((_b)->autore) { \ isc_buffer_t *_tmp = _b; \ ISC_REQUIRE(isc_buffer_reserve(&_tmp, 1) == \ ISC_R_SUCCESS); \ @@ -949,7 +948,7 @@ ISC_LANG_ENDDECLS unsigned char *_cp; \ /* evaluate (_val) only once */ \ uint16_t _val2 = (_val); \ - if (ISC_UNLIKELY((_b)->autore)) { \ + if ((_b)->autore) { \ isc_buffer_t *_tmp = _b; \ ISC_REQUIRE(isc_buffer_reserve(&_tmp, 2) == \ ISC_R_SUCCESS); \ @@ -966,7 +965,7 @@ ISC_LANG_ENDDECLS unsigned char *_cp; \ /* evaluate (_val) only once */ \ uint32_t _val2 = (_val); \ - if (ISC_UNLIKELY((_b)->autore)) { \ + if ((_b)->autore) { \ isc_buffer_t *_tmp = _b; \ ISC_REQUIRE(isc_buffer_reserve(&_tmp, 3) == \ ISC_R_SUCCESS); \ @@ -984,7 +983,7 @@ ISC_LANG_ENDDECLS unsigned char *_cp; \ /* evaluate (_val) only once */ \ uint32_t _val2 = (_val); \ - if (ISC_UNLIKELY((_b)->autore)) { \ + if ((_b)->autore) { \ isc_buffer_t *_tmp = _b; \ ISC_REQUIRE(isc_buffer_reserve(&_tmp, 4) == \ ISC_R_SUCCESS); \ diff --git a/lib/isc/include/isc/error.h b/lib/isc/include/isc/error.h index 5c11fb153d..bd4d8b5a22 100644 --- a/lib/isc/include/isc/error.h +++ b/lib/isc/include/isc/error.h @@ -18,7 +18,6 @@ #include #include #include -#include ISC_LANG_BEGINDECLS @@ -44,7 +43,7 @@ ISC_NORETURN void isc_error_runtimecheck(const char *, int, const char *); #define ISC_ERROR_RUNTIMECHECK(cond) \ - ((void)(ISC_LIKELY(cond) || \ + ((void)((cond) || \ ((isc_error_runtimecheck)(__FILE__, __LINE__, #cond), 0))) ISC_LANG_ENDDECLS diff --git a/lib/isc/include/isc/likely.h b/lib/isc/include/isc/likely.h deleted file mode 100644 index 7daa675633..0000000000 --- a/lib/isc/include/isc/likely.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#pragma once - -/*% - * Performance - */ -#ifdef CPPCHECK -#define ISC_LIKELY(x) (x) -#define ISC_UNLIKELY(x) (x) -#else /* ifdef CPPCHECK */ -#ifdef HAVE_BUILTIN_EXPECT -#define ISC_LIKELY(x) __builtin_expect(!!(x), 1) -#define ISC_UNLIKELY(x) __builtin_expect(!!(x), 0) -#else /* ifdef HAVE_BUILTIN_EXPECT */ -#define ISC_LIKELY(x) (x) -#define ISC_UNLIKELY(x) (x) -#endif /* ifdef HAVE_BUILTIN_EXPECT */ -#endif /* ifdef CPPCHECK */ diff --git a/lib/isc/include/isc/magic.h b/lib/isc/include/isc/magic.h index c5eadb1bf5..df60482ede 100644 --- a/lib/isc/include/isc/magic.h +++ b/lib/isc/include/isc/magic.h @@ -11,8 +11,6 @@ #pragma once -#include - /*! \file isc/magic.h */ typedef struct { @@ -25,8 +23,7 @@ typedef struct { * The intent of this is to allow magic numbers to be checked even though * the object is otherwise opaque. */ -#define ISC_MAGIC_VALID(a, b) \ - (ISC_LIKELY((a) != NULL) && \ - ISC_LIKELY(((const isc__magic_t *)(a))->magic == (b))) +#define ISC_MAGIC_VALID(a, b) \ + ((a) != NULL && ((const isc__magic_t *)(a))->magic == (b)) #define ISC_MAGIC(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d)) diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index 89c76b6ef6..65ac46c4f1 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -195,7 +195,6 @@ /*% * Performance */ -#include #ifdef HAVE_BUILTIN_UNREACHABLE #define ISC_UNREACHABLE() __builtin_unreachable(); diff --git a/lib/isc/md.c b/lib/isc/md.c index dbe64ac6fe..10e4b04bcc 100644 --- a/lib/isc/md.c +++ b/lib/isc/md.c @@ -29,7 +29,7 @@ isc_md_new(void) { void isc_md_free(isc_md_t *md) { - if (ISC_UNLIKELY(md == NULL)) { + if (md == NULL) { return; } @@ -66,7 +66,7 @@ isc_result_t isc_md_update(isc_md_t *md, const unsigned char *buf, const size_t len) { REQUIRE(md != NULL); - if (ISC_UNLIKELY(buf == NULL || len == 0)) { + if (buf == NULL || len == 0) { return (ISC_R_SUCCESS); } diff --git a/lib/isc/mem.c b/lib/isc/mem.c index a75524ece3..f6459df737 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -187,9 +187,8 @@ struct isc_mempool { #else /* if !ISC_MEM_TRACKLINES */ #define TRACE_OR_RECORD (ISC_MEM_DEBUGTRACE | ISC_MEM_DEBUGRECORD) -#define SHOULD_TRACE_OR_RECORD(ptr) \ - (ISC_UNLIKELY((isc_mem_debugging & TRACE_OR_RECORD) != 0) && \ - ptr != NULL) +#define SHOULD_TRACE_OR_RECORD(ptr) \ + ((isc_mem_debugging & TRACE_OR_RECORD) != 0 && ptr != NULL) #define ADD_TRACE(a, b, c, d, e) \ if (SHOULD_TRACE_OR_RECORD(b)) { \ @@ -303,8 +302,8 @@ delete_trace_entry(isc_mem_t *mctx, const void *ptr, size_t size, idx = hash % DEBUG_TABLE_COUNT; dl = ISC_LIST_HEAD(mctx->debuglist[idx]); - while (ISC_LIKELY(dl != NULL)) { - if (ISC_UNLIKELY(dl->ptr == ptr)) { + while (dl != NULL) { + if (dl->ptr == ptr) { ISC_LIST_UNLINK(mctx->debuglist[idx], dl, link); decrement_malloced(mctx, sizeof(*dl)); sdallocx(dl, sizeof(*dl), 0); @@ -325,7 +324,7 @@ unlock: #endif /* ISC_MEM_TRACKLINES */ #define ADJUST_ZERO_ALLOCATION_SIZE(s) \ - if (ISC_UNLIKELY(s == 0)) { \ + if (s == 0) { \ s = ZERO_ALLOCATION_SIZE; \ } @@ -341,7 +340,7 @@ mem_get(isc_mem_t *ctx, size_t size) { ret = mallocx(size, 0); INSIST(ret != NULL); - if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) { + if ((ctx->flags & ISC_MEMFLAG_FILL) != 0) { memset(ret, 0xbe, size); /* Mnemonic for "beef". */ } @@ -356,7 +355,7 @@ static inline void mem_put(isc_mem_t *ctx, void *mem, size_t size) { ADJUST_ZERO_ALLOCATION_SIZE(size); - if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) { + if ((ctx->flags & ISC_MEMFLAG_FILL) != 0) { memset(mem, 0xde, size); /* Mnemonic for "dead". */ } sdallocx(mem, size, 0); @@ -371,7 +370,7 @@ mem_realloc(isc_mem_t *ctx, void *old_ptr, size_t old_size, size_t new_size) { new_ptr = rallocx(old_ptr, new_size, 0); INSIST(new_ptr != NULL); - if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) { + if ((ctx->flags & ISC_MEMFLAG_FILL) != 0) { ssize_t diff_size = new_size - old_size; void *diff_ptr = (uint8_t *)new_ptr + old_size; if (diff_size > 0) { @@ -483,7 +482,7 @@ mem_create(isc_mem_t **ctxp, unsigned int flags) { ISC_LIST_INIT(ctx->pools); #if ISC_MEM_TRACKLINES - if (ISC_UNLIKELY((isc_mem_debugging & ISC_MEM_DEBUGRECORD) != 0)) { + if ((isc_mem_debugging & ISC_MEM_DEBUGRECORD) != 0) { unsigned int i; ctx->debuglist = @@ -524,7 +523,7 @@ destroy(isc_mem_t *ctx) { INSIST(ISC_LIST_EMPTY(ctx->pools)); #if ISC_MEM_TRACKLINES - if (ISC_UNLIKELY(ctx->debuglist != NULL)) { + if (ctx->debuglist != NULL) { debuglink_t *dl; for (i = 0; i < DEBUG_TABLE_COUNT; i++) { for (dl = ISC_LIST_HEAD(ctx->debuglist[i]); dl != NULL; @@ -903,10 +902,10 @@ isc__mem_reget(isc_mem_t *ctx, void *old_ptr, size_t old_size, size_t new_size FLARG) { void *new_ptr = NULL; - if (ISC_UNLIKELY(old_ptr == NULL)) { + if (old_ptr == NULL) { REQUIRE(old_size == 0); new_ptr = isc__mem_get(ctx, new_size FLARG_PASS); - } else if (ISC_UNLIKELY(new_size == 0)) { + } else if (new_size == 0) { isc__mem_put(ctx, old_ptr, old_size FLARG_PASS); } else { DELETE_TRACE(ctx, old_ptr, old_size, file, line); @@ -935,9 +934,9 @@ isc__mem_reallocate(isc_mem_t *ctx, void *old_ptr, size_t new_size FLARG) { REQUIRE(VALID_CONTEXT(ctx)); - if (ISC_UNLIKELY(old_ptr == NULL)) { + if (old_ptr == NULL) { new_ptr = isc__mem_allocate(ctx, new_size FLARG_PASS); - } else if (ISC_UNLIKELY(new_size == 0)) { + } else if (new_size == 0) { isc__mem_free(ctx, old_ptr FLARG_PASS); } else { size_t old_size = sallocx(old_ptr, 0); @@ -1289,7 +1288,7 @@ isc__mempool_get(isc_mempool_t *restrict mpctx FLARG) { mpctx->allocated++; - if (ISC_UNLIKELY(mpctx->items == NULL)) { + if (mpctx->items == NULL) { isc_mem_t *mctx = mpctx->mctx; const size_t fillcount = mpctx->fillcount; /* @@ -1442,7 +1441,7 @@ isc__mem_checkdestroyed(void) { LOCK(&contextslock); if (!ISC_LIST_EMPTY(contexts)) { #if ISC_MEM_TRACKLINES - if (ISC_UNLIKELY((isc_mem_debugging & TRACE_OR_RECORD) != 0)) { + if ((isc_mem_debugging & TRACE_OR_RECORD) != 0) { print_contexts(file); } #endif /* if ISC_MEM_TRACKLINES */ diff --git a/lib/isc/netmgr/tlsstream.c b/lib/isc/netmgr/tlsstream.c index 49edb68191..f5290890cd 100644 --- a/lib/isc/netmgr/tlsstream.c +++ b/lib/isc/netmgr/tlsstream.c @@ -126,7 +126,7 @@ tls_senddone(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) { /* We are tying to avoid a memory allocation for small write * requests. See the mirroring code in the tls_send_outgoing() * function. */ - if (ISC_UNLIKELY(send_req->data.length > sizeof(send_req->smallbuf))) { + if (send_req->data.length > sizeof(send_req->smallbuf)) { isc_mem_put(handle->sock->mgr->mctx, send_req->data.base, send_req->data.length); } else { @@ -247,7 +247,7 @@ tls_send_outgoing(isc_nmsocket_t *sock, bool finish, isc_nmhandle_t *tlshandle, .data.length = pending }; /* Let's try to avoid a memory allocation for small write requests */ - if (ISC_UNLIKELY((size_t)pending > sizeof(send_req->smallbuf))) { + if ((size_t)pending > sizeof(send_req->smallbuf)) { send_req->data.base = isc_mem_get(sock->mgr->mctx, pending); } else { send_req->data.base = &send_req->smallbuf[0]; diff --git a/lib/ns/query.c b/lib/ns/query.c index 58d973404d..1c942ebce6 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -1369,9 +1369,8 @@ query_getdb(ns_client_t *client, dns_name_t *name, dns_rdatatype_t qtype, * If # zone labels < # name labels, try to find an even better match * Only try if DLZ drivers are loaded for this view */ - if (ISC_UNLIKELY(zonelabels < namelabels && - !ISC_LIST_EMPTY(client->view->dlz_searched))) - { + if (zonelabels < namelabels && + !ISC_LIST_EMPTY(client->view->dlz_searched)) { dns_clientinfomethods_t cm; dns_clientinfo_t ci; dns_db_t *tdbp; @@ -5497,10 +5496,9 @@ ns__query_start(query_ctx_t *qctx) { result = query_getdb(qctx->client, qctx->client->query.qname, qctx->qtype, qctx->options, &qctx->zone, &qctx->db, &qctx->version, &qctx->is_zone); - if (ISC_UNLIKELY((result != ISC_R_SUCCESS || !qctx->is_zone) && - qctx->qtype == dns_rdatatype_ds && - !RECURSIONOK(qctx->client) && - (qctx->options & DNS_GETDB_NOEXACT) != 0)) + if ((result != ISC_R_SUCCESS || !qctx->is_zone) && + qctx->qtype == dns_rdatatype_ds && !RECURSIONOK(qctx->client) && + (qctx->options & DNS_GETDB_NOEXACT) != 0) { /* * This is a non-recursive QTYPE=DS query with QNAME whose @@ -5655,7 +5653,7 @@ qctx_prepare_buffers(query_ctx_t *qctx, isc_buffer_t *buffer) { REQUIRE(buffer != NULL); qctx->dbuf = ns_client_getnamebuf(qctx->client); - if (ISC_UNLIKELY(qctx->dbuf == NULL)) { + if (qctx->dbuf == NULL) { CCTRACE(ISC_LOG_ERROR, "qctx_prepare_buffers: ns_client_getnamebuf " "failed"); @@ -5663,7 +5661,7 @@ qctx_prepare_buffers(query_ctx_t *qctx, isc_buffer_t *buffer) { } qctx->fname = ns_client_newname(qctx->client, qctx->dbuf, buffer); - if (ISC_UNLIKELY(qctx->fname == NULL)) { + if (qctx->fname == NULL) { CCTRACE(ISC_LOG_ERROR, "qctx_prepare_buffers: ns_client_newname failed"); @@ -5671,7 +5669,7 @@ qctx_prepare_buffers(query_ctx_t *qctx, isc_buffer_t *buffer) { } qctx->rdataset = ns_client_newrdataset(qctx->client); - if (ISC_UNLIKELY(qctx->rdataset == NULL)) { + if (qctx->rdataset == NULL) { CCTRACE(ISC_LOG_ERROR, "qctx_prepare_buffers: ns_client_newrdataset failed"); goto error; diff --git a/util/copyrights b/util/copyrights index 553ad00317..49911e7604 100644 --- a/util/copyrights +++ b/util/copyrights @@ -1654,7 +1654,6 @@ ./lib/isc/include/isc/iterated_hash.h C 2008,2014,2016,2018,2019,2020,2021 ./lib/isc/include/isc/lang.h C 1999,2000,2001,2004,2005,2006,2007,2016,2018,2019,2020,2021 ./lib/isc/include/isc/lex.h C 1998,1999,2000,2001,2002,2004,2005,2007,2008,2015,2016,2017,2018,2019,2020,2021 -./lib/isc/include/isc/likely.h C 2017,2018,2019,2020,2021 ./lib/isc/include/isc/list.h C 1997,1998,1999,2000,2001,2002,2004,2006,2007,2011,2012,2013,2016,2018,2019,2020,2021 ./lib/isc/include/isc/log.h C 1999,2000,2001,2002,2004,2005,2006,2007,2009,2014,2016,2017,2018,2019,2020,2021 ./lib/isc/include/isc/magic.h C 1999,2000,2001,2004,2005,2006,2007,2016,2017,2018,2019,2020,2021