2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Replace custom isc_boolean_t with C standard bool type

This commit is contained in:
Ondřej Surý
2018-04-17 08:29:14 -07:00
parent cb6a185c69
commit 994e656977
546 changed files with 10785 additions and 10367 deletions

View File

@@ -20,6 +20,7 @@
#include <config.h>
#include <inttypes.h>
#include <stdbool.h>
#include <isc/mem.h>
#include <isc/net.h>
@@ -36,7 +37,7 @@
#include <dns/view.h>
static void
log_end(dns_rrl_t *rrl, dns_rrl_entry_t *e, isc_boolean_t early,
log_end(dns_rrl_t *rrl, dns_rrl_entry_t *e, bool early,
char *log_buf, unsigned int log_buf_len);
/*
@@ -170,7 +171,7 @@ set_age(dns_rrl_t *rrl, dns_rrl_entry_t *e, isc_stdtime_t now) {
!ISC_LINK_LINKED(e_old, hlink));
e_old = ISC_LIST_PREV(e_old, lru), ++i)
{
e_old->ts_valid = ISC_FALSE;
e_old->ts_valid = false;
}
if (i != 0)
isc_log_write(dns_lctx, DNS_LOGCATEGORY_RRL,
@@ -191,7 +192,7 @@ set_age(dns_rrl_t *rrl, dns_rrl_entry_t *e, isc_stdtime_t now) {
e->ts_gen = ts_gen;
e->ts = ts;
e->ts_valid = ISC_TRUE;
e->ts_valid = true;
}
static isc_result_t
@@ -362,11 +363,11 @@ ref_entry(dns_rrl_t *rrl, dns_rrl_entry_t *e, int probes, isc_stdtime_t now) {
}
}
static inline isc_boolean_t
static inline bool
key_cmp(const dns_rrl_key_t *a, const dns_rrl_key_t *b) {
if (memcmp(a, b, sizeof(dns_rrl_key_t)) == 0)
return (ISC_TRUE);
return (ISC_FALSE);
return (true);
return (false);
}
static inline uint32_t
@@ -425,10 +426,10 @@ make_key(const dns_rrl_t *rrl, dns_rrl_key_t *key,
dns_name_init(&base, base_offsets);
dns_name_getlabelsequence(qname, 1, labels-1, &base);
key->s.qname_hash =
dns_name_fullhash(&base, ISC_FALSE);
dns_name_fullhash(&base, false);
} else {
key->s.qname_hash =
dns_name_fullhash(qname, ISC_FALSE);
dns_name_fullhash(qname, false);
}
}
@@ -438,7 +439,7 @@ make_key(const dns_rrl_t *rrl, dns_rrl_key_t *key,
rrl->ipv4_mask);
break;
case AF_INET6:
key->s.ipv6 = ISC_TRUE;
key->s.ipv6 = true;
memmove(key->s.ip, &client_addr->type.sin6.sin6_addr,
sizeof(key->s.ip));
for (i = 0; i < DNS_RRL_MAX_PREFIX/32; ++i)
@@ -493,7 +494,7 @@ static dns_rrl_entry_t *
get_entry(dns_rrl_t *rrl, const isc_sockaddr_t *client_addr,
dns_rdataclass_t qclass, dns_rdatatype_t qtype,
const dns_name_t *qname, dns_rrl_rtype_t rtype, isc_stdtime_t now,
isc_boolean_t create, char *log_buf, unsigned int log_buf_len)
bool create, char *log_buf, unsigned int log_buf_len)
{
dns_rrl_key_t key;
uint32_t hval;
@@ -573,7 +574,7 @@ get_entry(dns_rrl_t *rrl, const isc_sockaddr_t *client_addr,
e = ISC_LIST_TAIL(rrl->lru);
}
if (e->logged)
log_end(rrl, e, ISC_TRUE, log_buf, log_buf_len);
log_end(rrl, e, true, log_buf, log_buf_len);
if (ISC_LINK_LINKED(e, hlink)) {
if (e->hash_gen == rrl->hash_gen)
hash = rrl->hash;
@@ -585,7 +586,7 @@ get_entry(dns_rrl_t *rrl, const isc_sockaddr_t *client_addr,
ISC_LIST_PREPEND(*new_bin, e, hlink);
e->hash_gen = rrl->hash_gen;
e->key = key;
e->ts_valid = ISC_FALSE;
e->ts_valid = false;
ref_entry(rrl, e, probes, now);
return (e);
}
@@ -631,7 +632,7 @@ debit_rrl_entry(dns_rrl_t *rrl, dns_rrl_entry_t *e, double qps, double scale,
*/
credit_e = get_entry(rrl, client_addr,
0, dns_rdatatype_none, NULL,
DNS_RRL_RTYPE_TCP, now, ISC_FALSE,
DNS_RRL_RTYPE_TCP, now, false,
log_buf, log_buf_len);
if (credit_e != NULL) {
age = get_age(rrl, e, now);
@@ -787,8 +788,8 @@ add_log_str(isc_buffer_t *lb, const char *str, unsigned int str_len) {
*/
static void
make_log_buf(dns_rrl_t *rrl, dns_rrl_entry_t *e,
const char *str1, const char *str2, isc_boolean_t plural,
const dns_name_t *qname, isc_boolean_t save_qname,
const char *str1, const char *str2, bool plural,
const dns_name_t *qname, bool save_qname,
dns_rrl_result_t rrl_result, isc_result_t resp_result,
char *log_buf, unsigned int log_buf_len)
{
@@ -917,7 +918,7 @@ make_log_buf(dns_rrl_t *rrl, dns_rrl_entry_t *e,
qname = dns_fixedname_name(&qbuf->qname);
if (qname != NULL) {
ADD_LOG_CSTR(&lb, " for ");
(void)dns_name_totext(qname, ISC_TRUE, &lb);
(void)dns_name_totext(qname, true, &lb);
} else {
ADD_LOG_CSTR(&lb, " for (?)");
}
@@ -941,7 +942,7 @@ make_log_buf(dns_rrl_t *rrl, dns_rrl_entry_t *e,
}
static void
log_end(dns_rrl_t *rrl, dns_rrl_entry_t *e, isc_boolean_t early,
log_end(dns_rrl_t *rrl, dns_rrl_entry_t *e, bool early,
char *log_buf, unsigned int log_buf_len)
{
if (e->logged) {
@@ -949,14 +950,14 @@ log_end(dns_rrl_t *rrl, dns_rrl_entry_t *e, isc_boolean_t early,
early ? "*" : NULL,
rrl->log_only ? "would stop limiting "
: "stop limiting ",
ISC_TRUE, NULL, ISC_FALSE,
true, NULL, false,
DNS_RRL_RESULT_OK, ISC_R_SUCCESS,
log_buf, log_buf_len);
isc_log_write(dns_lctx, DNS_LOGCATEGORY_RRL,
DNS_LOGMODULE_REQUEST, DNS_RRL_LOG_DROP,
"%s", log_buf);
free_qname(rrl, e);
e->logged = ISC_FALSE;
e->logged = false;
--rrl->num_logged;
}
}
@@ -1005,10 +1006,10 @@ log_stops(dns_rrl_t *rrl, isc_stdtime_t now, int limit,
*/
dns_rrl_result_t
dns_rrl(dns_view_t *view,
const isc_sockaddr_t *client_addr, isc_boolean_t is_tcp,
const isc_sockaddr_t *client_addr, bool is_tcp,
dns_rdataclass_t qclass, dns_rdatatype_t qtype,
const dns_name_t *qname, isc_result_t resp_result, isc_stdtime_t now,
isc_boolean_t wouldlog, char *log_buf, unsigned int log_buf_len)
bool wouldlog, char *log_buf, unsigned int log_buf_len)
{
dns_rrl_t *rrl;
dns_rrl_rtype_t rtype;
@@ -1081,7 +1082,7 @@ dns_rrl(dns_view_t *view,
if (scale < 1.0) {
e = get_entry(rrl, client_addr,
0, dns_rdatatype_none, NULL,
DNS_RRL_RTYPE_TCP, now, ISC_TRUE,
DNS_RRL_RTYPE_TCP, now, true,
log_buf, log_buf_len);
if (e != NULL) {
e->responses = -(rrl->window+1);
@@ -1114,7 +1115,7 @@ dns_rrl(dns_view_t *view,
break;
}
e = get_entry(rrl, client_addr, qclass, qtype, qname, rtype,
now, ISC_TRUE, log_buf, log_buf_len);
now, true, log_buf, log_buf_len);
if (e == NULL) {
UNLOCK(&rrl->lock);
return (DNS_RRL_RESULT_OK);
@@ -1125,8 +1126,8 @@ dns_rrl(dns_view_t *view,
* Do not worry about speed or releasing the lock.
* This message appears before messages from debit_rrl_entry().
*/
make_log_buf(rrl, e, "consider limiting ", NULL, ISC_FALSE,
qname, ISC_FALSE, DNS_RRL_RESULT_OK, resp_result,
make_log_buf(rrl, e, "consider limiting ", NULL, false,
qname, false, DNS_RRL_RESULT_OK, resp_result,
log_buf, log_buf_len);
isc_log_write(dns_lctx, DNS_LOGCATEGORY_RRL,
DNS_LOGMODULE_REQUEST, DNS_RRL_LOG_DEBUG1,
@@ -1150,7 +1151,7 @@ dns_rrl(dns_view_t *view,
e_all = get_entry(rrl, client_addr,
0, dns_rdatatype_none, NULL,
DNS_RRL_RTYPE_ALL, now, ISC_TRUE,
DNS_RRL_RTYPE_ALL, now, true,
log_buf, log_buf_len);
if (e_all == NULL) {
UNLOCK(&rrl->lock);
@@ -1165,7 +1166,7 @@ dns_rrl(dns_view_t *view,
if (isc_log_wouldlog(dns_lctx, DNS_RRL_LOG_DEBUG1)) {
make_log_buf(rrl, e,
"prefer all-per-second limiting ",
NULL, ISC_TRUE, qname, ISC_FALSE,
NULL, true, qname, false,
DNS_RRL_RESULT_OK, resp_result,
log_buf, log_buf_len);
isc_log_write(dns_lctx, DNS_LOGCATEGORY_RRL,
@@ -1188,11 +1189,11 @@ dns_rrl(dns_view_t *view,
isc_log_wouldlog(dns_lctx, DNS_RRL_LOG_DROP)) {
make_log_buf(rrl, e, rrl->log_only ? "would " : NULL,
e->logged ? "continue limiting " : "limit ",
ISC_TRUE, qname, ISC_TRUE,
true, qname, true,
DNS_RRL_RESULT_OK, resp_result,
log_buf, log_buf_len);
if (!e->logged) {
e->logged = ISC_TRUE;
e->logged = true;
if (++rrl->num_logged <= 1)
rrl->last_logged = e;
}
@@ -1216,7 +1217,7 @@ dns_rrl(dns_view_t *view,
if (wouldlog)
make_log_buf(rrl, e,
rrl->log_only ? "would rate limit " : "rate limit ",
NULL, ISC_FALSE, qname, ISC_FALSE,
NULL, false, qname, false,
rrl_result, resp_result, log_buf, log_buf_len);
if (e != NULL) {