2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +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

@@ -28,6 +28,7 @@
#include <config.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>
@@ -68,7 +69,7 @@
static dst_func_t *dst_t_func[DST_MAX_ALGS];
static isc_boolean_t dst_initialized = ISC_FALSE;
static bool dst_initialized = false;
void gss_log(int level, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
@@ -143,7 +144,7 @@ dst_lib_init(isc_mem_t *mctx, const char *engine) {
isc_result_t result;
REQUIRE(mctx != NULL);
REQUIRE(dst_initialized == ISC_FALSE);
REQUIRE(dst_initialized == false);
UNUSED(engine);
@@ -164,7 +165,7 @@ dst_lib_init(isc_mem_t *mctx, const char *engine) {
return (result);
isc_mem_setname(dst__memory_pool, "dst", NULL);
#ifndef OPENSSL_LEAKS
isc_mem_setdestroycheck(dst__memory_pool, ISC_FALSE);
isc_mem_setdestroycheck(dst__memory_pool, false);
#endif
dst_result_register();
@@ -223,12 +224,12 @@ dst_lib_init(isc_mem_t *mctx, const char *engine) {
RETERR(dst__gssapi_init(&dst_t_func[DST_ALG_GSSAPI]));
#endif
dst_initialized = ISC_TRUE;
dst_initialized = true;
return (ISC_R_SUCCESS);
out:
/* avoid immediate crash! */
dst_initialized = ISC_TRUE;
dst_initialized = true;
dst_lib_destroy();
return (result);
}
@@ -236,8 +237,8 @@ dst_lib_init(isc_mem_t *mctx, const char *engine) {
void
dst_lib_destroy(void) {
int i;
RUNTIME_CHECK(dst_initialized == ISC_TRUE);
dst_initialized = ISC_FALSE;
RUNTIME_CHECK(dst_initialized == true);
dst_initialized = false;
for (i = 0; i < DST_MAX_ALGS; i++)
if (dst_t_func[i] != NULL && dst_t_func[i]->cleanup != NULL)
@@ -250,31 +251,31 @@ dst_lib_destroy(void) {
isc_mem_detach(&dst__memory_pool);
}
isc_boolean_t
bool
dst_algorithm_supported(unsigned int alg) {
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
if (alg >= DST_MAX_ALGS || dst_t_func[alg] == NULL)
return (ISC_FALSE);
return (ISC_TRUE);
return (false);
return (true);
}
isc_boolean_t
bool
dst_ds_digest_supported(unsigned int digest_type) {
return (ISC_TF(digest_type == DNS_DSDIGEST_SHA1 ||
digest_type == DNS_DSDIGEST_SHA256 ||
digest_type == DNS_DSDIGEST_SHA384));
return (digest_type == DNS_DSDIGEST_SHA1 ||
digest_type == DNS_DSDIGEST_SHA256 ||
digest_type == DNS_DSDIGEST_SHA384);
}
isc_result_t
dst_context_create(dst_key_t *key, isc_mem_t *mctx,
isc_logcategory_t *category, isc_boolean_t useforsigning,
isc_logcategory_t *category, bool useforsigning,
int maxbits, dst_context_t **dctxp)
{
dst_context_t *dctx;
isc_result_t result;
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(VALID_KEY(key));
REQUIRE(mctx != NULL);
REQUIRE(dctxp != NULL && *dctxp == NULL);
@@ -351,7 +352,7 @@ dst_context_sign(dst_context_t *dctx, isc_buffer_t *sig) {
if (key->func->sign == NULL)
return (DST_R_NOTPRIVATEKEY);
if (key->func->isprivate == NULL ||
key->func->isprivate(key) == ISC_FALSE)
key->func->isprivate(key) == false)
return (DST_R_NOTPRIVATEKEY);
return (key->func->sign(dctx, sig));
@@ -394,7 +395,7 @@ isc_result_t
dst_key_computesecret(const dst_key_t *pub, const dst_key_t *priv,
isc_buffer_t *secret)
{
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(VALID_KEY(pub) && VALID_KEY(priv));
REQUIRE(secret != NULL);
@@ -409,7 +410,7 @@ dst_key_computesecret(const dst_key_t *pub, const dst_key_t *priv,
priv->func->computesecret == NULL)
return (DST_R_KEYCANNOTCOMPUTESECRET);
if (dst_key_isprivate(priv) == ISC_FALSE)
if (dst_key_isprivate(priv) == false)
return (DST_R_NOTPRIVATEKEY);
return (pub->func->computesecret(pub, priv, secret));
@@ -419,7 +420,7 @@ isc_result_t
dst_key_tofile(const dst_key_t *key, int type, const char *directory) {
isc_result_t ret = ISC_R_SUCCESS;
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(VALID_KEY(key));
REQUIRE((type & (DST_TYPE_PRIVATE | DST_TYPE_PUBLIC)) != 0);
@@ -442,11 +443,11 @@ dst_key_tofile(const dst_key_t *key, int type, const char *directory) {
}
void
dst_key_setexternal(dst_key_t *key, isc_boolean_t value) {
dst_key_setexternal(dst_key_t *key, bool value) {
key->external = value;
}
isc_boolean_t
bool
dst_key_isexternal(dst_key_t *key) {
return (key->external);
}
@@ -458,7 +459,7 @@ dst_key_getfilename(dns_name_t *name, dns_keytag_t id,
{
isc_result_t result;
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(dns_name_isabsolute(name));
REQUIRE((type & (DST_TYPE_PRIVATE | DST_TYPE_PUBLIC)) != 0);
REQUIRE(mctx != NULL);
@@ -487,7 +488,7 @@ dst_key_fromfile(dns_name_t *name, dns_keytag_t id,
isc_buffer_t buf;
dst_key_t *key;
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(dns_name_isabsolute(name));
REQUIRE((type & (DST_TYPE_PRIVATE | DST_TYPE_PUBLIC)) != 0);
REQUIRE(mctx != NULL);
@@ -536,7 +537,7 @@ dst_key_fromnamedfile(const char *filename, const char *dirname,
int newfilenamelen = 0;
isc_lex_t *lex = NULL;
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(filename != NULL);
REQUIRE((type & (DST_TYPE_PRIVATE | DST_TYPE_PUBLIC)) != 0);
REQUIRE(mctx != NULL);
@@ -635,7 +636,7 @@ dst_key_fromnamedfile(const char *filename, const char *dirname,
isc_result_t
dst_key_todns(const dst_key_t *key, isc_buffer_t *target) {
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(VALID_KEY(key));
REQUIRE(target != NULL);
@@ -734,7 +735,7 @@ dst_key_frombuffer(const dns_name_t *name, unsigned int alg,
isc_result_t
dst_key_tobuffer(const dst_key_t *key, isc_buffer_t *target) {
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(VALID_KEY(key));
REQUIRE(target != NULL);
@@ -751,7 +752,7 @@ dst_key_privatefrombuffer(dst_key_t *key, isc_buffer_t *buffer) {
isc_lex_t *lex = NULL;
isc_result_t result = ISC_R_SUCCESS;
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(VALID_KEY(key));
REQUIRE(!dst_key_isprivate(key));
REQUIRE(buffer != NULL);
@@ -817,7 +818,7 @@ dst_key_buildinternal(const dns_name_t *name, unsigned int alg,
dst_key_t *key;
isc_result_t result;
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(dns_name_isabsolute(name));
REQUIRE(mctx != NULL);
REQUIRE(keyp != NULL && *keyp == NULL);
@@ -851,7 +852,7 @@ dst_key_fromlabel(const dns_name_t *name, int alg, unsigned int flags,
dst_key_t *key;
isc_result_t result;
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(dns_name_isabsolute(name));
REQUIRE(mctx != NULL);
REQUIRE(keyp != NULL && *keyp == NULL);
@@ -895,7 +896,7 @@ dst_key_generate(const dns_name_t *name, unsigned int alg,
dst_key_t *key;
isc_result_t ret;
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(dns_name_isabsolute(name));
REQUIRE(mctx != NULL);
REQUIRE(keyp != NULL && *keyp == NULL);
@@ -952,7 +953,7 @@ dst_key_setnum(dst_key_t *key, int type, uint32_t value)
REQUIRE(VALID_KEY(key));
REQUIRE(type <= DST_MAX_NUMERIC);
key->nums[type] = value;
key->numset[type] = ISC_TRUE;
key->numset[type] = true;
}
void
@@ -960,7 +961,7 @@ dst_key_unsetnum(dst_key_t *key, int type)
{
REQUIRE(VALID_KEY(key));
REQUIRE(type <= DST_MAX_NUMERIC);
key->numset[type] = ISC_FALSE;
key->numset[type] = false;
}
isc_result_t
@@ -979,14 +980,14 @@ dst_key_settime(dst_key_t *key, int type, isc_stdtime_t when) {
REQUIRE(VALID_KEY(key));
REQUIRE(type <= DST_MAX_TIMES);
key->times[type] = when;
key->timeset[type] = ISC_TRUE;
key->timeset[type] = true;
}
void
dst_key_unsettime(dst_key_t *key, int type) {
REQUIRE(VALID_KEY(key));
REQUIRE(type <= DST_MAX_TIMES);
key->timeset[type] = ISC_FALSE;
key->timeset[type] = false;
}
isc_result_t
@@ -1006,39 +1007,39 @@ dst_key_setprivateformat(dst_key_t *key, int major, int minor) {
key->fmt_minor = minor;
}
static isc_boolean_t
static bool
comparekeys(const dst_key_t *key1, const dst_key_t *key2,
isc_boolean_t match_revoked_key,
isc_boolean_t (*compare)(const dst_key_t *key1,
bool match_revoked_key,
bool (*compare)(const dst_key_t *key1,
const dst_key_t *key2))
{
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(VALID_KEY(key1));
REQUIRE(VALID_KEY(key2));
if (key1 == key2)
return (ISC_TRUE);
return (true);
if (key1->key_alg != key2->key_alg)
return (ISC_FALSE);
return (false);
if (key1->key_id != key2->key_id) {
if (!match_revoked_key)
return (ISC_FALSE);
return (false);
if (key1->key_alg == DST_ALG_RSAMD5)
return (ISC_FALSE);
return (false);
if ((key1->key_flags & DNS_KEYFLAG_REVOKE) ==
(key2->key_flags & DNS_KEYFLAG_REVOKE))
return (ISC_FALSE);
return (false);
if (key1->key_id != key2->key_rid &&
key1->key_rid != key2->key_id)
return (ISC_FALSE);
return (false);
}
if (compare != NULL)
return (compare(key1, key2));
else
return (ISC_FALSE);
return (false);
}
@@ -1046,7 +1047,7 @@ comparekeys(const dst_key_t *key1, const dst_key_t *key2,
* Compares only the public portion of two keys, by converting them
* both to wire format and comparing the results.
*/
static isc_boolean_t
static bool
pub_compare(const dst_key_t *key1, const dst_key_t *key2) {
isc_result_t result;
unsigned char buf1[DST_KEY_MAXSIZE], buf2[DST_KEY_MAXSIZE];
@@ -1056,7 +1057,7 @@ pub_compare(const dst_key_t *key1, const dst_key_t *key2) {
isc_buffer_init(&b1, buf1, sizeof(buf1));
result = dst_key_todns(key1, &b1);
if (result != ISC_R_SUCCESS)
return (ISC_FALSE);
return (false);
/* Zero out flags. */
buf1[0] = buf1[1] = 0;
if ((key1->key_flags & DNS_KEYFLAG_EXTENDED) != 0)
@@ -1065,7 +1066,7 @@ pub_compare(const dst_key_t *key1, const dst_key_t *key2) {
isc_buffer_init(&b2, buf2, sizeof(buf2));
result = dst_key_todns(key2, &b2);
if (result != ISC_R_SUCCESS)
return (ISC_FALSE);
return (false);
/* Zero out flags. */
buf2[0] = buf2[1] = 0;
if ((key2->key_flags & DNS_KEYFLAG_EXTENDED) != 0)
@@ -1084,42 +1085,42 @@ pub_compare(const dst_key_t *key1, const dst_key_t *key2) {
memmove(&buf2[4], &buf2[6], r2.length - 6);
r2.length -= 2;
}
return (ISC_TF(isc_region_compare(&r1, &r2) == 0));
return (isc_region_compare(&r1, &r2) == 0);
}
isc_boolean_t
bool
dst_key_compare(const dst_key_t *key1, const dst_key_t *key2) {
return (comparekeys(key1, key2, ISC_FALSE, key1->func->compare));
return (comparekeys(key1, key2, false, key1->func->compare));
}
isc_boolean_t
bool
dst_key_pubcompare(const dst_key_t *key1, const dst_key_t *key2,
isc_boolean_t match_revoked_key)
bool match_revoked_key)
{
return (comparekeys(key1, key2, match_revoked_key, pub_compare));
}
isc_boolean_t
bool
dst_key_paramcompare(const dst_key_t *key1, const dst_key_t *key2) {
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(VALID_KEY(key1));
REQUIRE(VALID_KEY(key2));
if (key1 == key2)
return (ISC_TRUE);
return (true);
if (key1->key_alg == key2->key_alg &&
key1->func->paramcompare != NULL &&
key1->func->paramcompare(key1, key2) == ISC_TRUE)
return (ISC_TRUE);
key1->func->paramcompare(key1, key2) == true)
return (true);
else
return (ISC_FALSE);
return (false);
}
void
dst_key_attach(dst_key_t *source, dst_key_t **target) {
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(target != NULL && *target == NULL);
REQUIRE(VALID_KEY(source));
@@ -1133,7 +1134,7 @@ dst_key_free(dst_key_t **keyp) {
dst_key_t *key;
unsigned int refs;
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(keyp != NULL && VALID_KEY(*keyp));
key = *keyp;
@@ -1162,7 +1163,7 @@ dst_key_free(dst_key_t **keyp) {
*keyp = NULL;
}
isc_boolean_t
bool
dst_key_isprivate(const dst_key_t *key) {
REQUIRE(VALID_KEY(key));
INSIST(key->func->isprivate != NULL);
@@ -1183,7 +1184,7 @@ dst_key_buildfilename(const dst_key_t *key, int type,
isc_result_t
dst_key_sigsize(const dst_key_t *key, unsigned int *n) {
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(VALID_KEY(key));
REQUIRE(n != NULL);
@@ -1242,7 +1243,7 @@ dst_key_sigsize(const dst_key_t *key, unsigned int *n) {
isc_result_t
dst_key_secretsize(const dst_key_t *key, unsigned int *n) {
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(VALID_KEY(key));
REQUIRE(n != NULL);
@@ -1294,7 +1295,7 @@ dst_key_restore(dns_name_t *name, unsigned int alg, unsigned int flags,
isc_result_t result;
dst_key_t *key;
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(keyp != NULL && *keyp == NULL);
if (alg >= DST_MAX_ALGS || dst_t_func[alg] == NULL)
@@ -1373,14 +1374,14 @@ get_key_struct(const dns_name_t *name, unsigned int alg,
key->fmt_minor = 0;
for (i = 0; i < (DST_MAX_TIMES + 1); i++) {
key->times[i] = 0;
key->timeset[i] = ISC_FALSE;
key->timeset[i] = false;
}
key->inactive = ISC_FALSE;
key->inactive = false;
key->magic = KEY_MAGIC;
return (key);
}
isc_boolean_t
bool
dst_key_inactive(const dst_key_t *key) {
REQUIRE(VALID_KEY(key));
@@ -1389,7 +1390,7 @@ dst_key_inactive(const dst_key_t *key) {
}
void
dst_key_setinactive(dst_key_t *key, isc_boolean_t inactive) {
dst_key_setinactive(dst_key_t *key, bool inactive) {
REQUIRE(VALID_KEY(key));
@@ -1505,7 +1506,7 @@ dst_key_read_public(const char *filename, int type,
isc_buffer_init(&b, rdatabuf, sizeof(rdatabuf));
ret = dns_rdata_fromtext(&rdata, rdclass, keytype, lex, NULL,
ISC_FALSE, mctx, &b, NULL);
false, mctx, &b, NULL);
if (ret != ISC_R_SUCCESS)
goto cleanup;
@@ -1522,9 +1523,9 @@ dst_key_read_public(const char *filename, int type,
return (ret);
}
static isc_boolean_t
static bool
issymmetric(const dst_key_t *key) {
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
REQUIRE(VALID_KEY(key));
/* XXXVIX this switch statement is too sparse to gen a jump table. */
@@ -1541,7 +1542,7 @@ issymmetric(const dst_key_t *key) {
case DST_ALG_ECDSA384:
case DST_ALG_ED25519:
case DST_ALG_ED448:
return (ISC_FALSE);
return (false);
case DST_ALG_HMACMD5:
case DST_ALG_HMACSHA1:
case DST_ALG_HMACSHA224:
@@ -1549,9 +1550,9 @@ issymmetric(const dst_key_t *key) {
case DST_ALG_HMACSHA384:
case DST_ALG_HMACSHA512:
case DST_ALG_GSSAPI:
return (ISC_TRUE);
return (true);
default:
return (ISC_FALSE);
return (false);
}
}
@@ -1743,7 +1744,7 @@ buildfilename(dns_name_t *name, dns_keytag_t id,
if (isc_buffer_availablelength(out) < 1)
return (ISC_R_NOSPACE);
isc_buffer_putstr(out, "K");
result = dns_name_tofilenametext(name, ISC_FALSE, out);
result = dns_name_tofilenametext(name, false, out);
if (result != ISC_R_SUCCESS)
return (result);
@@ -1809,7 +1810,7 @@ frombuffer(const dns_name_t *name, unsigned int alg, unsigned int flags,
static isc_result_t
algorithm_status(unsigned int alg) {
REQUIRE(dst_initialized == ISC_TRUE);
REQUIRE(dst_initialized == true);
if (dst_algorithm_supported(alg)) {
return (ISC_R_SUCCESS);