From b2b43fd235b88b24bd68ca21ae6b9e37aad87440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 11 Oct 2018 11:57:57 +0200 Subject: [PATCH] Turn (int & flag) into (int & flag) != 0 when implicitly typed to bool --- bin/named/server.c | 8 ++--- lib/dns/adb.c | 7 ++--- lib/dns/client.c | 10 +++---- lib/dns/dispatch.c | 4 +-- lib/dns/dnssec.c | 12 ++++---- lib/dns/dst_api.c | 8 ++--- lib/dns/ecdb.c | 2 +- lib/dns/journal.c | 9 +++--- lib/dns/master.c | 2 +- lib/dns/masterdump.c | 6 ++-- lib/dns/message.c | 8 ++--- lib/dns/name.c | 11 +++---- lib/dns/nsec.c | 2 +- lib/dns/nsec3.c | 13 ++++---- lib/dns/openssl_link.c | 2 +- lib/dns/private.c | 6 ++-- lib/dns/rbtdb.c | 6 ++-- lib/dns/rdata/generic/keydata_65533.c | 8 +++-- lib/dns/rdata/generic/soa_6.c | 9 +++--- lib/dns/request.c | 6 ++-- lib/dns/resolver.c | 14 ++++----- lib/dns/rpz.c | 4 +-- lib/dns/sdb.c | 2 +- lib/dns/sdlz.c | 3 +- lib/dns/tsig.c | 2 +- lib/dns/update.c | 6 ++-- lib/dns/zone.c | 18 ++++++----- lib/dns/zoneverify.c | 4 +-- lib/irs/getaddrinfo.c | 2 +- lib/irs/getnameinfo.c | 2 +- lib/isc/httpd.c | 2 +- lib/isc/include/isc/radix.h | 2 -- lib/isc/lex.c | 6 ++-- lib/isc/log.c | 18 +++++------ lib/isc/radix.c | 2 ++ lib/isc/task.c | 4 +-- lib/isc/tests/socket_test.c | 2 +- lib/isc/tests/task_test.c | 3 +- lib/isc/tm.c | 2 +- lib/isc/unix/socket.c | 32 +++++++++++--------- lib/isc/win32/fsaccess.c | 43 +++++++++++++++++---------- lib/isc/win32/socket.c | 20 ++++++------- lib/isccfg/namedconf.c | 14 +++++---- lib/isccfg/parser.c | 30 +++++++++++-------- lib/ns/query.c | 7 +++-- lib/ns/server.c | 2 +- lib/ns/xfrout.c | 2 +- 47 files changed, 210 insertions(+), 177 deletions(-) diff --git a/bin/named/server.c b/bin/named/server.c index 93924b2afe..2aecc63092 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -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) diff --git a/lib/dns/adb.c b/lib/dns/adb.c index b284268da5..c9b8510161 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -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. */ diff --git a/lib/dns/client.c b/lib/dns/client.c index eea0ed8ace..4a196156a3 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -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. diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 9c440d370e..007b35e0c1 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -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 diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c index ff7396f3c9..c12ecacc5a 100644 --- a/lib/dns/dnssec.c +++ b/lib/dns/dnssec.c @@ -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); diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index 40ee709de0..4e54af0f63 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -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); diff --git a/lib/dns/ecdb.c b/lib/dns/ecdb.c index 465b96c3c9..e75a624157 100644 --- a/lib/dns/ecdb.c +++ b/lib/dns/ecdb.c @@ -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++; diff --git a/lib/dns/journal.c b/lib/dns/journal.c index b38c2ff653..b8bbe78c81 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -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) { diff --git a/lib/dns/master.c b/lib/dns/master.c index 8b39beca3b..832509d9f7 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -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; diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 198b7f251c..796a5955a8 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -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)); diff --git a/lib/dns/message.c b/lib/dns/message.c index 03daefd175..ec6dde5155 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -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; diff --git a/lib/dns/name.c b/lib/dns/name.c index 2f720a4914..74452934e9 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -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 diff --git a/lib/dns/nsec.c b/lib/dns/nsec.c index 3fa975d830..cd31886220 100644 --- a/lib/dns/nsec.c +++ b/lib/dns/nsec.c @@ -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 diff --git a/lib/dns/nsec3.c b/lib/dns/nsec3.c index ec226e7744..861e909422 100644 --- a/lib/dns/nsec3.c +++ b/lib/dns/nsec3.c @@ -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; } diff --git a/lib/dns/openssl_link.c b/lib/dns/openssl_link.c index 261254a00d..b3b7ca2609 100644 --- a/lib/dns/openssl_link.c +++ b/lib/dns/openssl_link.c @@ -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: diff --git a/lib/dns/private.c b/lib/dns/private.c index 2fa35b700a..e68ec0c3a2 100644 --- a/lib/dns/private.c +++ b/lib/dns/private.c @@ -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| diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index b2da8abddf..2f5db4fa7b 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -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); diff --git a/lib/dns/rdata/generic/keydata_65533.c b/lib/dns/rdata/generic/keydata_65533.c index 06b56c1e1a..30ba9676e7 100644 --- a/lib/dns/rdata/generic/keydata_65533.c +++ b/lib/dns/rdata/generic/keydata_65533.c @@ -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]); diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c index 1495232c01..805aaa1882 100644 --- a/lib/dns/rdata/generic/soa_6.c +++ b/lib/dns/rdata/generic/soa_6.c @@ -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); diff --git a/lib/dns/request.c b/lib/dns/request.c index 99a5924409..d9902907c0 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -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 diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index e911dae34a..9fdbe583e3 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -2336,7 +2336,7 @@ resquery_send(resquery_t *query) { dns_compress_t cctx; bool cleanup_cctx = false; bool secure_domain; - bool tcp = (query->options & DNS_FETCHOPT_TCP); + bool tcp = ((query->options & DNS_FETCHOPT_TCP) != 0); dns_ednsopt_t ednsopts[DNS_EDNSOPTIONS]; unsigned ednsopt = 0; uint16_t hint = 0, udpsize = 0; /* No EDNS */ @@ -2425,7 +2425,7 @@ resquery_send(resquery_t *query) { else if (res->view->enablevalidation && ((fctx->qmessage->flags & DNS_MESSAGEFLAG_RD) != 0)) { - bool checknta = !(query->options & DNS_FETCHOPT_NONTA); + bool checknta = ((query->options & DNS_FETCHOPT_NONTA) == 0); result = issecuredomain(res->view, &fctx->name, fctx->type, isc_time_seconds(&query->start), checknta, &secure_domain); @@ -3305,7 +3305,7 @@ findname(fetchctx_t *fctx, const dns_name_t *name, in_port_t port, FCTXTRACE("FINDNAME"); res = fctx->res; - unshared = (fctx->options & DNS_FETCHOPT_UNSHARED); + unshared = ((fctx->options & DNS_FETCHOPT_UNSHARED) != 0); /* * If this name is a subdomain of the query domain, tell * the ADB to start looking using zone/hint data. This keeps us @@ -5295,7 +5295,7 @@ validated(isc_task_t *task, isc_event_t *event) { negative = (vevent->rdataset == NULL); - sentresponse = (fctx->options & DNS_FETCHOPT_NOVALIDATE); + sentresponse = ((fctx->options & DNS_FETCHOPT_NOVALIDATE) != 0); /* * If shutting down, ignore the results. Check to see if we're @@ -5919,7 +5919,7 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, dns_adbaddrinfo_t *addrinfo, /* * Cache or validate each cacheable rdataset. */ - fail = (fctx->res->options & DNS_RESOLVER_CHECKNAMESFAIL); + fail = ((fctx->res->options & DNS_RESOLVER_CHECKNAMESFAIL) != 0); for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL; rdataset = ISC_LIST_NEXT(rdataset, link)) @@ -7614,7 +7614,7 @@ static void rctx_answer_init(respctx_t *rctx) { fetchctx_t *fctx = rctx->fctx; - rctx->aa = (fctx->rmessage->flags & DNS_MESSAGEFLAG_AA); + rctx->aa = ((fctx->rmessage->flags & DNS_MESSAGEFLAG_AA) != 0); if (rctx->aa) { rctx->trust = dns_trust_authanswer; } else { @@ -9487,7 +9487,7 @@ rctx_logpacket(respctx_t *rctx) { dns_dt_send(fctx->res->view, dtmsgtype, la, &rctx->query->addrinfo->sockaddr, - (rctx->query->options & DNS_FETCHOPT_TCP), + ((rctx->query->options & DNS_FETCHOPT_TCP) != 0), &zr, &rctx->query->start, NULL, &rctx->devent->buffer); #endif /* HAVE_DNSTAP */ } diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index 7a70ce2b4d..798ce84c99 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -567,8 +567,8 @@ adj_trigger_cnt(dns_rpz_zones_t *rpzs, dns_rpz_num_t rpz_num, const dns_rpz_cidr_key_t *tgt_ip, dns_rpz_prefix_t tgt_prefix, bool inc) { - dns_rpz_trigger_counter_t *cnt = 0; - dns_rpz_zbits_t *have = 0; + dns_rpz_trigger_counter_t *cnt = NULL; + dns_rpz_zbits_t *have = NULL; switch (rpz_type) { case DNS_RPZ_TYPE_CLIENT_IP: diff --git a/lib/dns/sdb.c b/lib/dns/sdb.c index f70c17f4bc..f00fdb00bd 100644 --- a/lib/dns/sdb.c +++ b/lib/dns/sdb.c @@ -1087,7 +1087,7 @@ createiterator(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp) sdbiter->common.methods = &dbiterator_methods; sdbiter->common.db = NULL; dns_db_attach(db, &sdbiter->common.db); - sdbiter->common.relative_names = (options & DNS_DB_RELATIVENAMES); + sdbiter->common.relative_names = ((options & DNS_DB_RELATIVENAMES) != 0); sdbiter->common.magic = DNS_DBITERATOR_MAGIC; ISC_LIST_INIT(sdbiter->nodelist); sdbiter->current = NULL; diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index 8bb66e8f1b..c7538c686c 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -823,7 +823,8 @@ createiterator(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp) sdlziter->common.methods = &dbiterator_methods; sdlziter->common.db = NULL; dns_db_attach(db, &sdlziter->common.db); - sdlziter->common.relative_names = (options & DNS_DB_RELATIVENAMES); + sdlziter->common.relative_names = + ((options & DNS_DB_RELATIVENAMES) != 0); sdlziter->common.magic = DNS_DBITERATOR_MAGIC; ISC_LIST_INIT(sdlziter->nodelist); sdlziter->current = NULL; diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c index 71580418ac..2afccef53e 100644 --- a/lib/dns/tsig.c +++ b/lib/dns/tsig.c @@ -50,7 +50,7 @@ #define DNS_TSIG_MAXGENERATEDKEYS 4096 #endif -#define is_response(msg) (msg->flags & DNS_MESSAGEFLAG_QR) +#define is_response(msg) ((msg->flags & DNS_MESSAGEFLAG_QR) != 0) #define BADTIMELEN 6 diff --git a/lib/dns/update.c b/lib/dns/update.c index da7494c760..2cd439ee12 100644 --- a/lib/dns/update.c +++ b/lib/dns/update.c @@ -1439,9 +1439,11 @@ dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, * and one doesn't. */ state->check_ksk = - (dns_zone_getoptions(zone) & DNS_ZONEOPT_UPDATECHECKKSK); + ((dns_zone_getoptions(zone) & + DNS_ZONEOPT_UPDATECHECKKSK) != 0); state->keyset_kskonly = - (dns_zone_getoptions(zone) & DNS_ZONEOPT_DNSKEYKSKONLY); + ((dns_zone_getoptions(zone) & + DNS_ZONEOPT_DNSKEYKSKONLY) != 0); /* * Get the NSEC/NSEC3 TTL from the SOA MINIMUM field. diff --git a/lib/dns/zone.c b/lib/dns/zone.c index edb64235ce..6b52d102bc 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -3388,27 +3388,28 @@ zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param) { strlcpy(flags, "NONE", sizeof(flags)); else { flags[0] = '\0'; - if (nsec3param->flags & DNS_NSEC3FLAG_REMOVE) + if ((nsec3param->flags & DNS_NSEC3FLAG_REMOVE) != 0) { strlcat(flags, "REMOVE", sizeof(flags)); - if (nsec3param->flags & DNS_NSEC3FLAG_INITIAL) { + } + if ((nsec3param->flags & DNS_NSEC3FLAG_INITIAL) != 0) { if (flags[0] == '\0') strlcpy(flags, "INITIAL", sizeof(flags)); else strlcat(flags, "|INITIAL", sizeof(flags)); } - if (nsec3param->flags & DNS_NSEC3FLAG_CREATE) { + if ((nsec3param->flags & DNS_NSEC3FLAG_CREATE) != 0) { if (flags[0] == '\0') strlcpy(flags, "CREATE", sizeof(flags)); else strlcat(flags, "|CREATE", sizeof(flags)); } - if (nsec3param->flags & DNS_NSEC3FLAG_NONSEC) { + if ((nsec3param->flags & DNS_NSEC3FLAG_NONSEC) != 0) { if (flags[0] == '\0') strlcpy(flags, "NONSEC", sizeof(flags)); else strlcat(flags, "|NONSEC", sizeof(flags)); } - if (nsec3param->flags & DNS_NSEC3FLAG_OPTOUT) { + if ((nsec3param->flags & DNS_NSEC3FLAG_OPTOUT) != 0) { if (flags[0] == '\0') strlcpy(flags, "OPTOUT", sizeof(flags)); else @@ -9532,13 +9533,14 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { RUNTIME_CHECK(result == ISC_R_SUCCESS); /* Skip ZSK's */ - if (!(dnskey.flags & DNS_KEYFLAG_KSK)) + if ((dnskey.flags & DNS_KEYFLAG_KSK) == 0) { continue; + } result = compute_tag(keyname, &dnskey, mctx, &keytag); RUNTIME_CHECK(result == ISC_R_SUCCESS); - revoked = (dnskey.flags & DNS_KEYFLAG_REVOKE); + revoked = ((dnskey.flags & DNS_KEYFLAG_REVOKE) != 0); if (matchkey(&kfetch->keydataset, &dnskeyrr)) { dns_rdata_reset(&keydatarr); @@ -11234,7 +11236,7 @@ notify_send(dns_notify_t *notify) { zone_iattach(notify->zone, &newnotify->zone); ISC_LIST_APPEND(newnotify->zone->notifies, newnotify, link); newnotify->dst = dst; - startup = (notify->flags & DNS_NOTIFY_STARTUP); + startup = ((notify->flags & DNS_NOTIFY_STARTUP) != 0); result = notify_send_queue(newnotify, startup); if (result != ISC_R_SUCCESS) goto cleanup; diff --git a/lib/dns/zoneverify.c b/lib/dns/zoneverify.c index a348d1f554..9d92f147e4 100644 --- a/lib/dns/zoneverify.c +++ b/lib/dns/zoneverify.c @@ -721,7 +721,7 @@ isoptout(const vctx_t *vctx, const dns_rdata_t *nsec3rdata, result = dns_rdata_tostruct(&rdata, &nsec3, NULL); RUNTIME_CHECK(result == ISC_R_SUCCESS); - *optout = (nsec3.flags & DNS_NSEC3FLAG_OPTOUT); + *optout = ((nsec3.flags & DNS_NSEC3FLAG_OPTOUT) != 0); done: if (dns_rdataset_isassociated(&rdataset)) { @@ -1629,7 +1629,7 @@ check_dnskey(vctx_t *vctx) { dns_rdataset_current(&vctx->keyset, &rdata); result = dns_rdata_tostruct(&rdata, &dnskey, NULL); RUNTIME_CHECK(result == ISC_R_SUCCESS); - is_ksk = (dnskey.flags & DNS_KEYFLAG_KSK); + is_ksk = ((dnskey.flags & DNS_KEYFLAG_KSK) != 0); if ((dnskey.flags & DNS_KEYOWNER_ZONE) == 0) { ; diff --git a/lib/irs/getaddrinfo.c b/lib/irs/getaddrinfo.c index d5481c7afa..c2f756264d 100644 --- a/lib/irs/getaddrinfo.c +++ b/lib/irs/getaddrinfo.c @@ -748,7 +748,7 @@ process_answer(isc_task_t *task, isc_event_t *event) { goto done; } - wantcname = (resstate->head->ai_flags & AI_CANONNAME); + wantcname = ((resstate->head->ai_flags & AI_CANONNAME) != 0); /* Parse the response and construct the addrinfo chain */ for (name = ISC_LIST_HEAD(rev->answerlist); name != NULL; diff --git a/lib/irs/getnameinfo.c b/lib/irs/getnameinfo.c index 2af8aaee28..0da6ba1eb9 100644 --- a/lib/irs/getnameinfo.c +++ b/lib/irs/getnameinfo.c @@ -197,7 +197,7 @@ getnameinfo(const struct sockaddr *sa, socklen_t salen, default: INSIST(0); } - proto = (flags & NI_DGRAM) ? "udp" : "tcp"; + proto = ((flags & NI_DGRAM) != 0) ? "udp" : "tcp"; if (serv == NULL || servlen == 0U) { /* diff --git a/lib/isc/httpd.c b/lib/isc/httpd.c index 2eeb047f1d..87a2187128 100644 --- a/lib/isc/httpd.c +++ b/lib/isc/httpd.c @@ -923,7 +923,7 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev) { } #ifdef HAVE_ZLIB - if (httpd->flags & HTTPD_ACCEPT_DEFLATE) { + if ((httpd->flags & HTTPD_ACCEPT_DEFLATE) != 0) { result = isc_httpd_compress(httpd); if (result == ISC_R_SUCCESS) { is_compressed = true; diff --git a/lib/isc/include/isc/radix.h b/lib/isc/include/isc/radix.h index 3b5aa7a607..feaf2e3157 100644 --- a/lib/isc/include/isc/radix.h +++ b/lib/isc/include/isc/radix.h @@ -59,8 +59,6 @@ typedef void (*isc_radix_processfunc_t)(isc_prefix_t *, void **); #define isc_prefix_tochar(prefix) ((char *)&(prefix)->add.sin) #define isc_prefix_touchar(prefix) ((u_char *)&(prefix)->add.sin) -#define BIT_TEST(f, b) ((f) & (b)) - /* * We need "first match" when we search the radix tree to preserve * compatibility with the existing ACL implementation. Radix trees diff --git a/lib/isc/lex.c b/lib/isc/lex.c index a8955bc78d..c9758872a6 100644 --- a/lib/isc/lex.c +++ b/lib/isc/lex.c @@ -650,10 +650,10 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { goto done; done = true; continue; - } else if (!(options & ISC_LEXOPT_CNUMBER) || + } else if ((options & ISC_LEXOPT_CNUMBER) == 0 || ((c != 'x' && c != 'X') || - (curr != &lex->data[1]) || - (lex->data[0] != '0'))) { + (curr != &lex->data[1]) || + (lex->data[0] != '0'))) { /* Above test supports hex numbers */ state = lexstate_string; } diff --git a/lib/isc/log.c b/lib/isc/log.c index e34ab1b732..b42d030d7d 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -1835,18 +1835,18 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, } } - utc = (channel->flags & ISC_LOG_UTC); - iso8601 = (channel->flags & ISC_LOG_ISO8601); - printtime = (channel->flags & ISC_LOG_PRINTTIME); + utc = ((channel->flags & ISC_LOG_UTC) != 0); + iso8601 = ((channel->flags & ISC_LOG_ISO8601) != 0); + printtime = ((channel->flags & ISC_LOG_PRINTTIME) != 0); printtag = ((channel->flags & - (ISC_LOG_PRINTTAG|ISC_LOG_PRINTPREFIX)) && + (ISC_LOG_PRINTTAG|ISC_LOG_PRINTPREFIX)) != 0 && lcfg->tag != NULL); - printcolon = ((channel->flags & ISC_LOG_PRINTTAG) && + printcolon = ((channel->flags & ISC_LOG_PRINTTAG) != 0 && lcfg->tag != NULL); - printcategory = (channel->flags & ISC_LOG_PRINTCATEGORY); - printmodule = (channel->flags & ISC_LOG_PRINTMODULE); - printlevel = (channel->flags & ISC_LOG_PRINTLEVEL); - buffered = (channel->flags & ISC_LOG_BUFFERED); + printcategory = ((channel->flags & ISC_LOG_PRINTCATEGORY) != 0); + printmodule = ((channel->flags & ISC_LOG_PRINTMODULE) != 0); + printlevel = ((channel->flags & ISC_LOG_PRINTLEVEL) != 0); + buffered = ((channel->flags & ISC_LOG_BUFFERED) != 0); if (printtime) { if (iso8601) { diff --git a/lib/isc/radix.c b/lib/isc/radix.c index 8f5de8217f..1e8f15a5a6 100644 --- a/lib/isc/radix.c +++ b/lib/isc/radix.c @@ -24,6 +24,8 @@ #include #include +#define BIT_TEST(f, b) (((f) & (b)) != 0) + static isc_result_t _new_prefix(isc_mem_t *mctx, isc_prefix_t **target, int family, void *dest, int bitlen); diff --git a/lib/isc/task.c b/lib/isc/task.c index 6e5b9a031e..ce291cb247 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -1602,7 +1602,7 @@ isc_task_setprivilege(isc_task_t *task0, bool priv) { bool oldpriv; LOCK(&task->lock); - oldpriv = (task->flags & TASK_F_PRIVILEGED); + oldpriv = ((task->flags & TASK_F_PRIVILEGED) != 0); if (priv) task->flags |= TASK_F_PRIVILEGED; else @@ -1629,7 +1629,7 @@ isc_task_privilege(isc_task_t *task0) { REQUIRE(VALID_TASK(task)); LOCK(&task->lock); - priv = (task->flags & TASK_F_PRIVILEGED); + priv = ((task->flags & TASK_F_PRIVILEGED) != 0); UNLOCK(&task->lock); return (priv); } diff --git a/lib/isc/tests/socket_test.c b/lib/isc/tests/socket_test.c index 1bfe65f3a2..5342961fa7 100644 --- a/lib/isc/tests/socket_test.c +++ b/lib/isc/tests/socket_test.c @@ -78,7 +78,7 @@ event_done(isc_task_t *task, isc_event_t *event) { } else { recv_dscp = false; } - recv_trunc = (dev->attributes & ISC_SOCKEVENTATTR_TRUNC); + recv_trunc = ((dev->attributes & ISC_SOCKEVENTATTR_TRUNC) != 0); isc_event_free(&event); } diff --git a/lib/isc/tests/task_test.c b/lib/isc/tests/task_test.c index fb1ce8499b..c4dad42aed 100644 --- a/lib/isc/tests/task_test.c +++ b/lib/isc/tests/task_test.c @@ -985,7 +985,7 @@ pg_event2(isc_task_t *task, isc_event_t *event) { } if (sender_match && type_match && tag_match) { - if (event->ev_attributes & ISC_EVENTATTR_NOPURGE) { + if ((event->ev_attributes & ISC_EVENTATTR_NOPURGE) != 0) { printf("event %p,%d,%p matched but was not purgeable\n", event->ev_sender, (int)event->ev_type, event->ev_tag); @@ -1439,4 +1439,3 @@ ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, purgeevent_notpurge); return (atf_no_error()); } - diff --git a/lib/isc/tm.c b/lib/isc/tm.c index c39039663d..338157ade5 100644 --- a/lib/isc/tm.c +++ b/lib/isc/tm.c @@ -61,7 +61,7 @@ */ #define ALT_E 0x01 #define ALT_O 0x02 -#define LEGAL_ALT(x) { if (alt_format & ~(x)) return (0); } +#define LEGAL_ALT(x) { if ((alt_format & ~(x)) != 0) return (0); } #ifndef TM_YEAR_BASE #define TM_YEAR_BASE 1900 diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 4ec0504496..0a79e2eeb1 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -1094,13 +1094,15 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { UNUSED(dev); #ifdef MSG_TRUNC - if ((msg->msg_flags & MSG_TRUNC) == MSG_TRUNC) + if ((msg->msg_flags & MSG_TRUNC) != 0) { dev->attributes |= ISC_SOCKEVENTATTR_TRUNC; + } #endif #ifdef MSG_CTRUNC - if ((msg->msg_flags & MSG_CTRUNC) == MSG_CTRUNC) + if ((msg->msg_flags & MSG_CTRUNC) != 0) { dev->attributes |= ISC_SOCKEVENTATTR_CTRUNC; + } #endif #ifndef USE_CMSG @@ -2786,10 +2788,12 @@ isc_socket_fdwatchcreate(isc_socketmgr_t *manager0, int fd, int flags, #endif UNLOCK(&manager->lock); - if (flags & ISC_SOCKFDWATCH_READ) + if ((flags & ISC_SOCKFDWATCH_READ) != 0) { select_poke(sock->manager, sock->fd, SELECT_POKE_READ); - if (flags & ISC_SOCKFDWATCH_WRITE) + } + if ((flags & ISC_SOCKFDWATCH_WRITE) != 0) { select_poke(sock->manager, sock->fd, SELECT_POKE_WRITE); + } socket_log(sock, NULL, CREATION, isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_CREATED, "fdwatch-created"); @@ -3067,11 +3071,11 @@ send_recvdone_event(isc__socket_t *sock, isc_socketevent_t **dev) { if (ISC_LINK_LINKED(*dev, ev_link)) ISC_LIST_DEQUEUE(sock->recv_list, *dev, ev_link); - if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) - == ISC_SOCKEVENTATTR_ATTACHED) + if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) != 0) { isc_task_sendanddetach(&task, (isc_event_t **)dev); - else + } else { isc_task_send(task, (isc_event_t **)dev); + } } /* @@ -3091,11 +3095,11 @@ send_senddone_event(isc__socket_t *sock, isc_socketevent_t **dev) { if (ISC_LINK_LINKED(*dev, ev_link)) ISC_LIST_DEQUEUE(sock->send_list, *dev, ev_link); - if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) - == ISC_SOCKEVENTATTR_ATTACHED) + if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) != 0) { isc_task_sendanddetach(&task, (isc_event_t **)dev); - else + } else { isc_task_send(task, (isc_event_t **)dev); + } } /* @@ -5615,7 +5619,7 @@ isc_socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) { * its done event with status of "ISC_R_CANCELED". * o Reset any state needed. */ - if (((how & ISC_SOCKCANCEL_RECV) == ISC_SOCKCANCEL_RECV) + if (((how & ISC_SOCKCANCEL_RECV) != 0) && !ISC_LIST_EMPTY(sock->recv_list)) { isc_socketevent_t *dev; isc_socketevent_t *next; @@ -5635,7 +5639,7 @@ isc_socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) { } } - if (((how & ISC_SOCKCANCEL_SEND) == ISC_SOCKCANCEL_SEND) + if (((how & ISC_SOCKCANCEL_SEND) != 0) && !ISC_LIST_EMPTY(sock->send_list)) { isc_socketevent_t *dev; isc_socketevent_t *next; @@ -5655,7 +5659,7 @@ isc_socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) { } } - if (((how & ISC_SOCKCANCEL_ACCEPT) == ISC_SOCKCANCEL_ACCEPT) + if (((how & ISC_SOCKCANCEL_ACCEPT) != 0) && !ISC_LIST_EMPTY(sock->accept_list)) { isc_socket_newconnev_t *dev; isc_socket_newconnev_t *next; @@ -5684,7 +5688,7 @@ isc_socket_cancel(isc_socket_t *sock0, isc_task_t *task, unsigned int how) { } } - if (((how & ISC_SOCKCANCEL_CONNECT) == ISC_SOCKCANCEL_CONNECT) + if (((how & ISC_SOCKCANCEL_CONNECT) != 0) && !ISC_LIST_EMPTY(sock->connect_list)) { isc_socket_connev_t *dev; isc_socket_connev_t *next; diff --git a/lib/isc/win32/fsaccess.c b/lib/isc/win32/fsaccess.c index 1398171228..28bc8a569f 100644 --- a/lib/isc/win32/fsaccess.c +++ b/lib/isc/win32/fsaccess.c @@ -191,23 +191,30 @@ NTFS_Access_Control(const char *filename, const char *user, int access, /* Owner check */ NTFSbits = 0; - if (caccess & ISC_FSACCESS_READ) + if ((caccess & ISC_FSACCESS_READ) != 0) { NTFSbits |= FILE_GENERIC_READ; - if (caccess & ISC_FSACCESS_WRITE) + } + if ((caccess & ISC_FSACCESS_WRITE) != 0) { NTFSbits |= FILE_GENERIC_WRITE; - if (caccess & ISC_FSACCESS_EXECUTE) + } + if ((caccess & ISC_FSACCESS_EXECUTE) != 0) { NTFSbits |= FILE_GENERIC_EXECUTE; + } /* For directories check the directory-specific bits */ if (isdir == true) { - if (caccess & ISC_FSACCESS_CREATECHILD) + if ((caccess & ISC_FSACCESS_CREATECHILD) != 0) { NTFSbits |= FILE_ADD_SUBDIRECTORY | FILE_ADD_FILE; - if (caccess & ISC_FSACCESS_DELETECHILD) + } + if ((caccess & ISC_FSACCESS_DELETECHILD) != 0) { NTFSbits |= FILE_DELETE_CHILD; - if (caccess & ISC_FSACCESS_LISTDIRECTORY) + } + if ((caccess & ISC_FSACCESS_LISTDIRECTORY) != 0) { NTFSbits |= FILE_LIST_DIRECTORY; - if (caccess & ISC_FSACCESS_ACCESSCHILD) + } + if ((caccess & ISC_FSACCESS_ACCESSCHILD) != 0) { NTFSbits |= FILE_TRAVERSE; + } } if (NTFSbits == (FILE_GENERIC_READ | FILE_GENERIC_WRITE @@ -240,23 +247,30 @@ NTFS_Access_Control(const char *filename, const char *user, int access, caccess = caccess >> STEP; NTFSbits = 0; - if (caccess & ISC_FSACCESS_READ) + if ((caccess & ISC_FSACCESS_READ) != 0) { NTFSbits |= FILE_GENERIC_READ; - if (caccess & ISC_FSACCESS_WRITE) + } + if ((caccess & ISC_FSACCESS_WRITE) != 0) { NTFSbits |= FILE_GENERIC_WRITE; - if (caccess & ISC_FSACCESS_EXECUTE) + } + if ((caccess & ISC_FSACCESS_EXECUTE) != 0) { NTFSbits |= FILE_GENERIC_EXECUTE; + } /* For directories check the directory-specific bits */ if (isdir == TRUE) { - if (caccess & ISC_FSACCESS_CREATECHILD) + if ((caccess & ISC_FSACCESS_CREATECHILD) != 0) { NTFSbits |= FILE_ADD_SUBDIRECTORY | FILE_ADD_FILE; - if (caccess & ISC_FSACCESS_DELETECHILD) + } + if ((caccess & ISC_FSACCESS_DELETECHILD) != 0) { NTFSbits |= FILE_DELETE_CHILD; - if (caccess & ISC_FSACCESS_LISTDIRECTORY) + } + if ((caccess & ISC_FSACCESS_LISTDIRECTORY) != 0) { NTFSbits |= FILE_LIST_DIRECTORY; - if (caccess & ISC_FSACCESS_ACCESSCHILD) + } + if ((caccess & ISC_FSACCESS_ACCESSCHILD) != 0) { NTFSbits |= FILE_TRAVERSE; + } } /* Add the ACE to the ACL */ if (!AddAccessAllowedAce(pacl, ACL_REVISION, NTFSbits, @@ -365,4 +379,3 @@ isc_fsaccess_changeowner(const char *filename, const char *user) { return (ISC_R_SUCCESS); } - diff --git a/lib/isc/win32/socket.c b/lib/isc/win32/socket.c index d1d465afe5..d96133e9ec 100644 --- a/lib/isc/win32/socket.c +++ b/lib/isc/win32/socket.c @@ -1840,11 +1840,11 @@ send_recvdone_event(isc_socket_t *sock, isc_socketevent_t **dev) { if (ISC_LINK_LINKED(*dev, ev_link)) ISC_LIST_DEQUEUE(sock->recv_list, *dev, ev_link); - if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) - == ISC_SOCKEVENTATTR_ATTACHED) + if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) != 0) { isc_task_sendanddetach(&task, (isc_event_t **)dev); - else + } else { isc_task_send(task, (isc_event_t **)dev); + } CONSISTENT(sock); } @@ -1864,11 +1864,11 @@ send_senddone_event(isc_socket_t *sock, isc_socketevent_t **dev) { if (ISC_LINK_LINKED(*dev, ev_link)) ISC_LIST_DEQUEUE(sock->send_list, *dev, ev_link); - if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) - == ISC_SOCKEVENTATTR_ATTACHED) + if (((*dev)->attributes & ISC_SOCKEVENTATTR_ATTACHED) != 0) { isc_task_sendanddetach(&task, (isc_event_t **)dev); - else + } else { isc_task_send(task, (isc_event_t **)dev); + } CONSISTENT(sock); } @@ -3476,7 +3476,7 @@ isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) { * o Reset any state needed. */ - if ((how & ISC_SOCKCANCEL_RECV) == ISC_SOCKCANCEL_RECV) { + if ((how & ISC_SOCKCANCEL_RECV) != 0) { isc_socketevent_t *dev; isc_socketevent_t *next; isc_task_t *current_task; @@ -3494,7 +3494,7 @@ isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) { } how &= ~ISC_SOCKCANCEL_RECV; - if ((how & ISC_SOCKCANCEL_SEND) == ISC_SOCKCANCEL_SEND) { + if ((how & ISC_SOCKCANCEL_SEND) != 0) { isc_socketevent_t *dev; isc_socketevent_t *next; isc_task_t *current_task; @@ -3513,7 +3513,7 @@ isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) { } how &= ~ISC_SOCKCANCEL_SEND; - if (((how & ISC_SOCKCANCEL_ACCEPT) == ISC_SOCKCANCEL_ACCEPT) + if (((how & ISC_SOCKCANCEL_ACCEPT) != 0) && !ISC_LIST_EMPTY(sock->accept_list)) { isc_socket_newconnev_t *dev; isc_socket_newconnev_t *next; @@ -3540,7 +3540,7 @@ isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) { } how &= ~ISC_SOCKCANCEL_ACCEPT; - if (((how & ISC_SOCKCANCEL_CONNECT) == ISC_SOCKCANCEL_CONNECT) + if (((how & ISC_SOCKCANCEL_CONNECT) != 0) && !ISC_LIST_EMPTY(sock->connect_list)) { isc_socket_connev_t *dev; isc_socket_connev_t *next; diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index 5af0396034..8abd76c6af 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -3349,20 +3349,22 @@ doc_querysource(cfg_printer_t *pctx, const cfg_type_t *type) { const unsigned int *flagp = type->of; cfg_print_cstr(pctx, "( ( [ address ] ( "); - if (*flagp & CFG_ADDR_V4OK) + if ((*flagp & CFG_ADDR_V4OK) != 0) { cfg_print_cstr(pctx, ""); - else if (*flagp & CFG_ADDR_V6OK) + } else if ((*flagp & CFG_ADDR_V6OK) != 0) { cfg_print_cstr(pctx, ""); - else + } else { INSIST(0); + } cfg_print_cstr(pctx, " | * ) [ port ( | * ) ] ) | " "( [ [ address ] ( "); - if (*flagp & CFG_ADDR_V4OK) + if ((*flagp & CFG_ADDR_V4OK) != 0) { cfg_print_cstr(pctx, ""); - else if (*flagp & CFG_ADDR_V6OK) + } else if ((*flagp & CFG_ADDR_V6OK) != 0) { cfg_print_cstr(pctx, ""); - else + } else { INSIST(0); + } cfg_print_cstr(pctx, " | * ) ] port ( | * ) ) )" " [ dscp ]"); } diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index c370b1980e..39c15ab363 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -1796,7 +1796,8 @@ cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) /* Single-valued clause */ if (result == ISC_R_NOTFOUND) { bool callback = - (clause->flags & CFG_CLAUSEFLAG_CALLBACK); + ((clause->flags & + CFG_CLAUSEFLAG_CALLBACK) != 0); CHECK(parse_symtab_elt(pctx, clause->name, clause->type, obj->value.map.symtab, @@ -2493,27 +2494,29 @@ static void cfg_doc_netaddr(cfg_printer_t *pctx, const cfg_type_t *type) { const unsigned int *flagp = type->of; int n = 0; - if (*flagp != CFG_ADDR_V4OK && *flagp != CFG_ADDR_V6OK) + if (*flagp != CFG_ADDR_V4OK && *flagp != CFG_ADDR_V6OK) { cfg_print_cstr(pctx, "( "); - if (*flagp & CFG_ADDR_V4OK) { + } + if ((*flagp & CFG_ADDR_V4OK) != 0) { cfg_print_cstr(pctx, ""); n++; } - if (*flagp & CFG_ADDR_V6OK) { + if ((*flagp & CFG_ADDR_V6OK) != 0) { if (n != 0) cfg_print_cstr(pctx, " | "); cfg_print_cstr(pctx, ""); n++; } - if (*flagp & CFG_ADDR_WILDOK) { + if ((*flagp & CFG_ADDR_WILDOK) != 0) { if (n != 0) cfg_print_cstr(pctx, " | "); cfg_print_cstr(pctx, "*"); n++; POST(n); } - if (*flagp != CFG_ADDR_V4OK && *flagp != CFG_ADDR_V6OK) + if (*flagp != CFG_ADDR_V4OK && *flagp != CFG_ADDR_V6OK) { cfg_print_cstr(pctx, " )"); + } } LIBISCCFG_EXTERNAL_DATA cfg_type_t cfg_type_netaddr = { @@ -2741,17 +2744,17 @@ cfg_doc_sockaddr(cfg_printer_t *pctx, const cfg_type_t *type) { REQUIRE(type != NULL); cfg_print_cstr(pctx, "( "); - if (*flagp & CFG_ADDR_V4OK) { + if ((*flagp & CFG_ADDR_V4OK) != 0) { cfg_print_cstr(pctx, ""); n++; } - if (*flagp & CFG_ADDR_V6OK) { + if ((*flagp & CFG_ADDR_V6OK) != 0) { if (n != 0) cfg_print_cstr(pctx, " | "); cfg_print_cstr(pctx, ""); n++; } - if (*flagp & CFG_ADDR_WILDOK) { + if ((*flagp & CFG_ADDR_WILDOK) != 0) { if (n != 0) cfg_print_cstr(pctx, " | "); cfg_print_cstr(pctx, "*"); @@ -2759,7 +2762,7 @@ cfg_doc_sockaddr(cfg_printer_t *pctx, const cfg_type_t *type) { POST(n); } cfg_print_cstr(pctx, " ) "); - if (*flagp & CFG_ADDR_WILDOK) { + if ((*flagp & CFG_ADDR_WILDOK) != 0) { cfg_print_cstr(pctx, "[ port ( | * ) ]"); } else { cfg_print_cstr(pctx, "[ port ]"); @@ -3000,12 +3003,13 @@ parser_complain(cfg_parser_t *pctx, bool is_warning, } /* Choose a preposition. */ - if (flags & CFG_LOG_NEAR) + if ((flags & CFG_LOG_NEAR) != 0) { prep = " near "; - else if (flags & CFG_LOG_BEFORE) + } else if ((flags & CFG_LOG_BEFORE) != 0) { prep = " before "; - else + } else { prep = " "; + } } else { tokenbuf[0] = '\0'; } diff --git a/lib/ns/query.c b/lib/ns/query.c index 71aa3824d9..39e87bca7d 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -4554,7 +4554,7 @@ query_findclosestnsec3(dns_name_t *qname, dns_db_t *db, result = dns_rdata_tostruct(&rdata, &nsec3, NULL); RUNTIME_CHECK(result == ISC_R_SUCCESS); dns_rdata_reset(&rdata); - optout = (nsec3.flags & DNS_NSEC3FLAG_OPTOUT); + optout = ((nsec3.flags & DNS_NSEC3FLAG_OPTOUT) != 0); if (found != NULL && optout && dns_name_issubdomain(&name, dns_db_origin(db))) { @@ -11101,7 +11101,7 @@ ns_query_start(ns_client_t *client) { * We don't need to set DNS_DBFIND_PENDINGOK when validation is * disabled as there will be no pending data. */ - if (message->flags & DNS_MESSAGEFLAG_CD || + if ((message->flags & DNS_MESSAGEFLAG_CD) != 0 || qtype == dns_rdatatype_rrsig) { client->query.dboptions |= DNS_DBFIND_PENDINGOK; @@ -11121,8 +11121,9 @@ ns_query_start(ns_client_t *client) { * Allow glue NS records to be added to the authority section * if the answer is secure. */ - if (message->flags & DNS_MESSAGEFLAG_CD) + if ((message->flags & DNS_MESSAGEFLAG_CD) != 0) { client->query.attributes &= ~NS_QUERYATTR_SECURE; + } /* * Set NS_CLIENTATTR_WANTAD if the client has set AD in the query. diff --git a/lib/ns/server.c b/lib/ns/server.c index 91ae32d692..ad7f3815a4 100644 --- a/lib/ns/server.c +++ b/lib/ns/server.c @@ -249,5 +249,5 @@ bool ns_server_getoption(ns_server_t *sctx, unsigned int option) { REQUIRE(SCTX_VALID(sctx)); - return (sctx->options & option); + return ((sctx->options & option) != 0); } diff --git a/lib/ns/xfrout.c b/lib/ns/xfrout.c index 4573d52248..0410276209 100644 --- a/lib/ns/xfrout.c +++ b/lib/ns/xfrout.c @@ -1285,7 +1285,7 @@ sendstream(xfrout_ctx_t *xfr) { isc_buffer_clear(&xfr->txlenbuf); isc_buffer_clear(&xfr->txbuf); - is_tcp = (xfr->client->attributes & NS_CLIENTATTR_TCP); + is_tcp = ((xfr->client->attributes & NS_CLIENTATTR_TCP) != 0); if (!is_tcp) { /* * In the UDP case, we put the response data directly into