Commit b2b43fd2 authored by Ondřej Surý's avatar Ondřej Surý
Browse files

Turn (int & flag) into (int & flag) != 0 when implicitly typed to bool

parent fbd2e47f
......@@ -8906,7 +8906,7 @@ load_configuration(const char *filename, named_server_t *server,
named_g_memstatistics = cfg_obj_asboolean(obj);
} else {
named_g_memstatistics =
(isc_mem_debugging & ISC_MEM_DEBUGRECORD);
((isc_mem_debugging & ISC_MEM_DEBUGRECORD) != 0);
}
obj = NULL;
......@@ -14096,8 +14096,8 @@ named_server_zonestatus(named_server_t *server, isc_lex_t *lex,
/* Security */
secure = dns_db_issecure(db);
allow = (dns_zone_getkeyopts(zone) & DNS_ZONEKEY_ALLOW);
maintain = (dns_zone_getkeyopts(zone) & DNS_ZONEKEY_MAINTAIN);
allow = ((dns_zone_getkeyopts(zone) & DNS_ZONEKEY_ALLOW) != 0);
maintain = ((dns_zone_getkeyopts(zone) & DNS_ZONEKEY_MAINTAIN) != 0);
/* Master files */
file = dns_zone_getfile(mayberaw);
......@@ -14798,7 +14798,7 @@ mkey_dumpzone(dns_view_t *view, isc_buffer_t **text) {
snprintf(buf, sizeof(buf), "\n\talgorithm: %s", alg);
CHECK(putstr(text, buf));
revoked = (kd.flags & DNS_KEYFLAG_REVOKE);
revoked = ((kd.flags & DNS_KEYFLAG_REVOKE) != 0);
snprintf(buf, sizeof(buf), "\n\tflags:%s%s%s",
revoked ? " REVOKE" : "",
((kd.flags & DNS_KEYFLAG_KSK) != 0)
......
......@@ -2188,7 +2188,7 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find,
bucket = DNS_ADB_INVALIDBUCKET;
if (find->options & DNS_ADBFIND_INET) {
if ((find->options & DNS_ADBFIND_INET) != 0) {
namehook = ISC_LIST_HEAD(name->v4);
while (namehook != NULL) {
entry = namehook->entry;
......@@ -2228,7 +2228,7 @@ copy_namehook_lists(dns_adb_t *adb, dns_adbfind_t *find,
}
}
if (find->options & DNS_ADBFIND_INET6) {
if ((find->options & DNS_ADBFIND_INET6) != 0) {
namehook = ISC_LIST_HEAD(name->v6);
while (namehook != NULL) {
entry = namehook->entry;
......@@ -3701,8 +3701,7 @@ dbfind_name(dns_adbname_t *adbname, isc_stdtime_t now, dns_rdatatype_t rdtype)
result = dns_view_find(adb->view, &adbname->name, rdtype, now,
NAME_GLUEOK(adbname) ? DNS_DBFIND_GLUEOK : 0,
NAME_HINTOK(adbname),
(adbname->flags & NAME_STARTATZONE) != 0 ?
true : false,
((adbname->flags & NAME_STARTATZONE) != 0),
NULL, NULL, fname, &rdataset, NULL);
/* XXXVIX this switch statement is too sparse to gen a jump table. */
......
......@@ -1331,10 +1331,10 @@ dns_client_startresolve(dns_client_t *client, const dns_name_t *name,
mctx = client->mctx;
rdataset = NULL;
sigrdataset = NULL;
want_dnssec = !(options & DNS_CLIENTRESOPT_NODNSSEC);
want_validation = !(options & DNS_CLIENTRESOPT_NOVALIDATE);
want_cdflag = !(options & DNS_CLIENTRESOPT_NOCDFLAG);
want_tcp = (options & DNS_CLIENTRESOPT_TCP);
want_dnssec = ((options & DNS_CLIENTRESOPT_NODNSSEC) == 0);
want_validation = ((options & DNS_CLIENTRESOPT_NOVALIDATE) == 0);
want_cdflag = ((options & DNS_CLIENTRESOPT_NOCDFLAG) == 0);
want_tcp = ((options & DNS_CLIENTRESOPT_TCP) != 0);
/*
* Prepare some intermediate resources
......@@ -2848,7 +2848,7 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
if (result != ISC_R_SUCCESS)
return (result);
want_tcp = (options & DNS_CLIENTUPDOPT_TCP);
want_tcp = ((options & DNS_CLIENTUPDOPT_TCP) != 0);
/*
* Create a context and prepare some resources.
......
......@@ -1160,7 +1160,7 @@ udp_recv(isc_event_t *ev_in, dns_dispatch_t *disp, dispsocket_t *dispsock) {
dispatch_log(disp, LVL(92),
"got valid DNS message header, /QR %c, id %u",
((flags & DNS_MESSAGEFLAG_QR) ? '1' : '0'), id);
(((flags & DNS_MESSAGEFLAG_QR) != 0) ? '1' : '0'), id);
/*
* Look at flags. If query, drop it. If response,
......@@ -1413,7 +1413,7 @@ tcp_recv(isc_task_t *task, isc_event_t *ev_in) {
dispatch_log(disp, LVL(92),
"got valid DNS message header, /QR %c, id %u",
((flags & DNS_MESSAGEFLAG_QR) ? '1' : '0'), id);
(((flags & DNS_MESSAGEFLAG_QR) != 0) ? '1' : '0'), id);
/*
* Allocate an event to send to the query or response client, and
......
......@@ -46,7 +46,7 @@
LIBDNS_EXTERNAL_DATA isc_stats_t *dns_dnssec_stats;
#define is_response(msg) (msg->flags & DNS_MESSAGEFLAG_QR)
#define is_response(msg) ((msg->flags & DNS_MESSAGEFLAG_QR) != 0)
#define RETERR(x) do { \
result = (x); \
......@@ -220,10 +220,12 @@ dns_dnssec_sign(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
* Is the key allowed to sign data?
*/
flags = dst_key_flags(key);
if (flags & DNS_KEYTYPE_NOAUTH)
if ((flags & DNS_KEYTYPE_NOAUTH) != 0) {
return (DNS_R_KEYUNAUTHORIZED);
if ((flags & DNS_KEYFLAG_OWNERMASK) != DNS_KEYOWNER_ZONE)
}
if ((flags & DNS_KEYFLAG_OWNERMASK) != DNS_KEYOWNER_ZONE) {
return (DNS_R_KEYUNAUTHORIZED);
}
sig.mctx = mctx;
sig.common.rdclass = set->rdclass;
......@@ -447,7 +449,7 @@ dns_dnssec_verify(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
* Is the key allowed to sign data?
*/
flags = dst_key_flags(key);
if (flags & DNS_KEYTYPE_NOAUTH) {
if ((flags & DNS_KEYTYPE_NOAUTH) != 0) {
inc_stat(dns_dnssecstats_fail);
return (DNS_R_KEYUNAUTHORIZED);
}
......@@ -1237,7 +1239,7 @@ dns_dnsseckey_create(isc_mem_t *mctx, dst_key_t **dstkey,
dk->index = 0;
/* KSK or ZSK? */
dk->ksk = (dst_key_flags(dk->key) & DNS_KEYFLAG_KSK);
dk->ksk = ((dst_key_flags(dk->key) & DNS_KEYFLAG_KSK) != 0);
/* Is this an old-style key? */
result = dst_key_getprivateformat(dk->key, &major, &minor);
......
......@@ -386,13 +386,13 @@ dst_key_tofile(const dst_key_t *key, int type, const char *directory) {
if (key->func->tofile == NULL)
return (DST_R_UNSUPPORTEDALG);
if (type & DST_TYPE_PUBLIC) {
if ((type & DST_TYPE_PUBLIC) != 0) {
ret = write_public_key(key, type, directory);
if (ret != ISC_R_SUCCESS)
return (ret);
}
if ((type & DST_TYPE_PRIVATE) &&
if (((type & DST_TYPE_PRIVATE) != 0) &&
(key->key_flags & DNS_KEYFLAG_TYPEMASK) != DNS_KEYTYPE_NOKEY)
return (key->func->tofile(key, directory));
else
......@@ -608,7 +608,7 @@ dst_key_todns(const dst_key_t *key, isc_buffer_t *target) {
isc_buffer_putuint8(target, (uint8_t)key->key_proto);
isc_buffer_putuint8(target, (uint8_t)key->key_alg);
if (key->key_flags & DNS_KEYFLAG_EXTENDED) {
if ((key->key_flags & DNS_KEYFLAG_EXTENDED) != 0) {
if (isc_buffer_availablelength(target) < 2)
return (ISC_R_NOSPACE);
isc_buffer_putuint16(target,
......@@ -646,7 +646,7 @@ dst_key_fromdns(const dns_name_t *name, dns_rdataclass_t rdclass,
id = dst_region_computeid(&r, alg);
rid = dst_region_computerid(&r, alg);
if (flags & DNS_KEYFLAG_EXTENDED) {
if ((flags & DNS_KEYFLAG_EXTENDED) != 0) {
if (isc_buffer_remaininglength(source) < 2)
return (DST_R_INVALIDPUBLICKEY);
extflags = isc_buffer_getuint16(source);
......
......@@ -727,7 +727,7 @@ rdataset_current(dns_rdataset_t *rdataset, dns_rdata_t *rdata) {
raw += 2;
#endif
if (rdataset->type == dns_rdatatype_rrsig) {
if (*raw & DNS_RDATASLAB_OFFLINE)
if ((*raw & DNS_RDATASLAB_OFFLINE) != 0)
flags |= DNS_RDATA_OFFLINE;
length--;
raw++;
......
......@@ -354,7 +354,7 @@ journal_header_decode(journal_rawheader_t *raw, journal_header_t *cooked) {
journal_pos_decode(&raw->h.end, &cooked->end);
cooked->index_size = decode_uint32(raw->h.index_size);
cooked->sourceserial = decode_uint32(raw->h.sourceserial);
cooked->serialset = (raw->h.flags & JOURNAL_SERIALSET);
cooked->serialset = ((raw->h.flags & JOURNAL_SERIALSET) != 0);
}
static void
......@@ -368,8 +368,9 @@ journal_header_encode(journal_header_t *cooked, journal_rawheader_t *raw) {
journal_pos_encode(&raw->h.end, &cooked->end);
encode_uint32(cooked->index_size, raw->h.index_size);
encode_uint32(cooked->sourceserial, raw->h.sourceserial);
if (cooked->serialset)
if (cooked->serialset) {
flags |= JOURNAL_SERIALSET;
}
raw->h.flags = flags;
}
......@@ -692,8 +693,8 @@ dns_journal_open(isc_mem_t *mctx, const char *filename, unsigned int mode,
char backup[1024];
bool writable, create;
create = (mode & DNS_JOURNAL_CREATE);
writable = (mode & (DNS_JOURNAL_WRITE|DNS_JOURNAL_CREATE));
create = ((mode & DNS_JOURNAL_CREATE) != 0);
writable = ((mode & (DNS_JOURNAL_WRITE|DNS_JOURNAL_CREATE)) != 0);
result = journal_open(mctx, filename, writable, create, journalp);
if (result == ISC_R_NOTFOUND) {
......
......@@ -584,7 +584,7 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx,
isc_lex_setcomments(lctx->lex, ISC_LEXCOMMENT_DNSMASTERFILE);
}
lctx->ttl_known = (options & DNS_MASTER_NOTTL);
lctx->ttl_known = ((options & DNS_MASTER_NOTTL) != 0);
lctx->ttl = 0;
lctx->default_ttl_known = lctx->ttl_known;
lctx->default_ttl = 0;
......
......@@ -1025,7 +1025,7 @@ dump_rdatasets_text(isc_mem_t *mctx, const dns_name_t *name,
for (i = 0; i < n; i++) {
dns_rdataset_t *rds = sorted[i];
if (ctx->style.flags & DNS_STYLEFLAG_TRUST) {
if ((ctx->style.flags & DNS_STYLEFLAG_TRUST) != 0) {
if ((ctx->style.flags & DNS_STYLEFLAG_INDENT) != 0 ||
(ctx->style.flags & DNS_STYLEFLAG_YAML) != 0)
{
......@@ -1048,8 +1048,8 @@ dump_rdatasets_text(isc_mem_t *mctx, const dns_name_t *name,
if ((ctx->style.flags & DNS_STYLEFLAG_OMIT_OWNER) != 0)
name = NULL;
}
if (ctx->style.flags & DNS_STYLEFLAG_RESIGN &&
rds->attributes & DNS_RDATASETATTR_RESIGN) {
if (((ctx->style.flags & DNS_STYLEFLAG_RESIGN) != 0) &&
((rds->attributes & DNS_RDATASETATTR_RESIGN) != 0)) {
isc_buffer_t b;
char buf[sizeof("YYYYMMDDHHMMSS")];
memset(buf, 0, sizeof(buf));
......
......@@ -1008,7 +1008,7 @@ getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
section = &msg->sections[DNS_SECTION_QUESTION];
best_effort = (options & DNS_MESSAGEPARSE_BESTEFFORT);
best_effort = ((options & DNS_MESSAGEPARSE_BESTEFFORT) != 0);
seen_problem = false;
name = NULL;
......@@ -1240,8 +1240,8 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
bool preserve_order, best_effort, seen_problem;
bool issigzero;
preserve_order = (options & DNS_MESSAGEPARSE_PRESERVEORDER);
best_effort = (options & DNS_MESSAGEPARSE_BESTEFFORT);
preserve_order = ((options & DNS_MESSAGEPARSE_PRESERVEORDER) != 0);
best_effort = ((options & DNS_MESSAGEPARSE_BESTEFFORT) != 0);
seen_problem = false;
section = &msg->sections[sectionid];
......@@ -1677,7 +1677,7 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source,
REQUIRE(msg->from_to_wire == DNS_MESSAGE_INTENTPARSE);
seen_problem = false;
ignore_tc = (options & DNS_MESSAGEPARSE_IGNORETRUNCATION);
ignore_tc = ((options & DNS_MESSAGEPARSE_IGNORETRUNCATION) != 0);
origsource = *source;
......
......@@ -1060,7 +1060,7 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source,
REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) ||
(target == NULL && ISC_BUFFER_VALID(name->buffer)));
downcase = (options & DNS_NAME_DOWNCASE);
downcase = ((options & DNS_NAME_DOWNCASE) != 0);
if (target == NULL && name->buffer != NULL) {
target = name->buffer;
......@@ -1351,7 +1351,7 @@ dns_name_totext2(const dns_name_t *name, unsigned int options,
dns_name_totextfilter_t *mem;
dns_name_totextfilter_t totext_filter_proc = NULL;
isc_result_t result;
bool omit_final_dot = (options & DNS_NAME_OMITFINALDOT);
bool omit_final_dot = ((options & DNS_NAME_OMITFINALDOT) != 0);
/*
* This function assumes the name is in proper uncompressed
......@@ -1763,7 +1763,7 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source,
REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) ||
(target == NULL && ISC_BUFFER_VALID(name->buffer)));
downcase = (options & DNS_NAME_DOWNCASE);
downcase = ((options & DNS_NAME_DOWNCASE) != 0);
if (target == NULL && name->buffer != NULL) {
target = name->buffer;
......@@ -1847,9 +1847,10 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source,
/*
* Ordinary 14-bit pointer.
*/
if ((dctx->allowed & DNS_COMPRESS_GLOBAL14) ==
0)
if ((dctx->allowed & DNS_COMPRESS_GLOBAL14) == 0)
{
return (DNS_R_DISALLOWED);
}
new_current = c & 0x3F;
state = fw_newcurrent;
} else
......
......@@ -58,7 +58,7 @@ dns_nsec_isset(const unsigned char *array, unsigned int type) {
shift = 7 - (type % 8);
mask = 1 << shift;
return (byte & mask);
return ((byte & mask) != 0);
}
unsigned int
......
......@@ -2100,13 +2100,12 @@ dns_nsec3_noexistnodata(dns_rdatatype_t type, const dns_name_t *name,
*exists = false;
*data = false;
if (optout != NULL) {
if ((nsec3.flags & DNS_NSEC3FLAG_OPTOUT) != 0)
(*logit)(arg, ISC_LOG_DEBUG(3),
"NSEC3 indicates optout");
else
(*logit)(arg, ISC_LOG_DEBUG(3),
"NSEC3 indicates secure range");
*optout = (nsec3.flags & DNS_NSEC3FLAG_OPTOUT);
*optout = ((nsec3.flags & DNS_NSEC3FLAG_OPTOUT)
!= 0);
(*logit)(arg, ISC_LOG_DEBUG(3),
(*optout
? "NSEC3 indicates optout"
: "NSEC3 indicates secure range"));
}
answer = ISC_R_SUCCESS;
}
......
......@@ -303,7 +303,7 @@ dst__openssl_toresult3(isc_logcategory_t *category,
isc_log_write(dns_lctx, category,
DNS_LOGMODULE_CRYPTO, ISC_LOG_INFO,
"%s:%s:%d:%s", buf, file, line,
(flags & ERR_TXT_STRING) ? data : "");
((flags & ERR_TXT_STRING) != 0) ? data : "");
}
done:
......
......@@ -312,9 +312,9 @@ dns_private_totext(dns_rdata_t *private, isc_buffer_t *buf) {
CHECK(dns_rdata_tostruct(&rdata, &nsec3param, NULL));
del = (nsec3param.flags & DNS_NSEC3FLAG_REMOVE);
init = (nsec3param.flags & DNS_NSEC3FLAG_INITIAL);
nonsec = (nsec3param.flags & DNS_NSEC3FLAG_NONSEC);
del = ((nsec3param.flags & DNS_NSEC3FLAG_REMOVE) != 0);
init = ((nsec3param.flags & DNS_NSEC3FLAG_INITIAL) != 0);
nonsec = ((nsec3param.flags & DNS_NSEC3FLAG_NONSEC) != 0);
nsec3param.flags &= ~(DNS_NSEC3FLAG_CREATE|
DNS_NSEC3FLAG_REMOVE|
......
......@@ -5406,7 +5406,7 @@ createiterator(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp)
rbtdbiter->common.db = NULL;
dns_db_attach(db, &rbtdbiter->common.db);
rbtdbiter->common.relative_names =
(options & DNS_DB_RELATIVENAMES);
((options & DNS_DB_RELATIVENAMES) != 0);
rbtdbiter->common.magic = DNS_DBITERATOR_MAGIC;
rbtdbiter->common.cleaning = false;
rbtdbiter->paused = true;
......@@ -5416,8 +5416,8 @@ createiterator(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp)
dns_fixedname_init(&rbtdbiter->origin);
rbtdbiter->node = NULL;
rbtdbiter->delcnt = 0;
rbtdbiter->nsec3only = (options & DNS_DB_NSEC3ONLY);
rbtdbiter->nonsec3 = (options & DNS_DB_NONSEC3);
rbtdbiter->nsec3only = ((options & DNS_DB_NSEC3ONLY) != 0);
rbtdbiter->nonsec3 = ((options & DNS_DB_NONSEC3) != 0);
memset(rbtdbiter->deletions, 0, sizeof(rbtdbiter->deletions));
dns_rbtnodechain_init(&rbtdbiter->chain, db->mctx);
dns_rbtnodechain_init(&rbtdbiter->nsec3chain, db->mctx);
......
......@@ -129,12 +129,14 @@ totext_keydata(ARGS_TOTEXT) {
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
if ((flags & DNS_KEYFLAG_KSK) != 0) {
if (flags & DNS_KEYFLAG_REVOKE)
if ((flags & DNS_KEYFLAG_REVOKE) != 0) {
keyinfo = "revoked KSK";
else
} else {
keyinfo = "KSK";
} else
}
} else {
keyinfo = "ZSK";
}
/* protocol */
snprintf(buf, sizeof(buf), "%u", sr.base[0]);
......
......@@ -91,11 +91,12 @@ totext_soa(ARGS_TOTEXT) {
REQUIRE(rdata->type == dns_rdatatype_soa);
REQUIRE(rdata->length != 0);
multiline = (tctx->flags & DNS_STYLEFLAG_MULTILINE);
if (multiline)
comm = (tctx->flags & DNS_STYLEFLAG_RRCOMMENT);
else
multiline = ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0);
if (multiline) {
comm = ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0);
} else {
comm = false;
}
dns_name_init(&mname, NULL);
......
......@@ -958,8 +958,8 @@ dns_request_createvia(dns_requestmgr_t *requestmgr, dns_message_t *message,
dns_tsigkey_attach(key, &request->tsigkey);
use_tcp:
tcp = (options & DNS_REQUESTOPT_TCP);
share = (options & DNS_REQUESTOPT_SHARE);
tcp = ((options & DNS_REQUESTOPT_TCP) != 0);
share = ((options & DNS_REQUESTOPT_SHARE) != 0);
result = get_dispatch(tcp, false, share,
requestmgr, srcaddr, destaddr,
dscp, &connected, &request->dispatch);
......@@ -1220,7 +1220,7 @@ bool
dns_request_usedtcp(dns_request_t *request) {
REQUIRE(VALID_REQUEST(request));
return (request->flags & DNS_REQUEST_F_TCP);
return ((request->flags & DNS_REQUEST_F_TCP) != 0);
}
void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment