mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 22:45:39 +00:00
Use clang-tidy to add curly braces around one-line statements
The command used to reformat the files in this commit was: ./util/run-clang-tidy \ -clang-tidy-binary clang-tidy-11 -clang-apply-replacements-binary clang-apply-replacements-11 \ -checks=-*,readability-braces-around-statements \ -j 9 \ -fix \ -format \ -style=file \ -quiet clang-format -i --style=format $(git ls-files '*.c' '*.h') uncrustify -c .uncrustify.cfg --replace --no-backup $(git ls-files '*.c' '*.h') clang-format -i --style=format $(git ls-files '*.c' '*.h')
This commit is contained in:
115
lib/dns/rootns.c
115
lib/dns/rootns.c
@@ -84,22 +84,26 @@ in_rootns(dns_rdataset_t *rootns, dns_name_t *name)
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
dns_rdata_ns_t ns;
|
||||
|
||||
if (!dns_rdataset_isassociated(rootns))
|
||||
if (!dns_rdataset_isassociated(rootns)) {
|
||||
return (ISC_R_NOTFOUND);
|
||||
}
|
||||
|
||||
result = dns_rdataset_first(rootns);
|
||||
while (result == ISC_R_SUCCESS) {
|
||||
dns_rdataset_current(rootns, &rdata);
|
||||
result = dns_rdata_tostruct(&rdata, &ns, NULL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
if (dns_name_compare(name, &ns.name) == 0)
|
||||
}
|
||||
if (dns_name_compare(name, &ns.name) == 0) {
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
result = dns_rdataset_next(rootns);
|
||||
dns_rdata_reset(&rdata);
|
||||
}
|
||||
if (result == ISC_R_NOMORE)
|
||||
if (result == ISC_R_NOMORE) {
|
||||
result = ISC_R_NOTFOUND;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -118,13 +122,15 @@ check_node(dns_rdataset_t *rootns, dns_name_t *name,
|
||||
case dns_rdatatype_a:
|
||||
case dns_rdatatype_aaaa:
|
||||
result = in_rootns(rootns, name);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
break;
|
||||
case dns_rdatatype_ns:
|
||||
if (dns_name_compare(name, dns_rootname) == 0)
|
||||
if (dns_name_compare(name, dns_rootname) == 0) {
|
||||
break;
|
||||
/* FALLTHROUGH */
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
result = ISC_R_FAILURE;
|
||||
goto cleanup;
|
||||
@@ -132,11 +138,13 @@ check_node(dns_rdataset_t *rootns, dns_name_t *name,
|
||||
dns_rdataset_disassociate(&rdataset);
|
||||
result = dns_rdatasetiter_next(rdsiter);
|
||||
}
|
||||
if (result == ISC_R_NOMORE)
|
||||
if (result == ISC_R_NOMORE) {
|
||||
result = ISC_R_SUCCESS;
|
||||
}
|
||||
cleanup:
|
||||
if (dns_rdataset_isassociated(&rdataset))
|
||||
if (dns_rdataset_isassociated(&rdataset)) {
|
||||
dns_rdataset_disassociate(&rdataset);
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -160,35 +168,44 @@ check_hints(dns_db_t *db)
|
||||
(void)dns_db_find(db, dns_rootname, NULL, dns_rdatatype_ns, 0, now,
|
||||
NULL, name, &rootns, NULL);
|
||||
result = dns_db_createiterator(db, 0, &dbiter);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
result = dns_dbiterator_first(dbiter);
|
||||
while (result == ISC_R_SUCCESS) {
|
||||
result = dns_dbiterator_current(dbiter, &node, name);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
result = dns_db_allrdatasets(db, node, NULL, now, &rdsiter);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
result = check_node(&rootns, name, rdsiter);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
dns_rdatasetiter_destroy(&rdsiter);
|
||||
dns_db_detachnode(db, &node);
|
||||
result = dns_dbiterator_next(dbiter);
|
||||
}
|
||||
if (result == ISC_R_NOMORE)
|
||||
if (result == ISC_R_NOMORE) {
|
||||
result = ISC_R_SUCCESS;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (dns_rdataset_isassociated(&rootns))
|
||||
if (dns_rdataset_isassociated(&rootns)) {
|
||||
dns_rdataset_disassociate(&rootns);
|
||||
if (rdsiter != NULL)
|
||||
}
|
||||
if (rdsiter != NULL) {
|
||||
dns_rdatasetiter_destroy(&rdsiter);
|
||||
if (node != NULL)
|
||||
}
|
||||
if (node != NULL) {
|
||||
dns_db_detachnode(db, &node);
|
||||
if (dbiter != NULL)
|
||||
}
|
||||
if (dbiter != NULL) {
|
||||
dns_dbiterator_destroy(&dbiter);
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -206,8 +223,9 @@ dns_rootns_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
|
||||
|
||||
result = dns_db_create(mctx, "rbt", dns_rootname, dns_dbtype_zone,
|
||||
rdclass, 0, NULL, &db);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto failure;
|
||||
}
|
||||
|
||||
len = strlen(root_ns);
|
||||
isc_buffer_init(&source, root_ns, len);
|
||||
@@ -215,8 +233,9 @@ dns_rootns_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
|
||||
|
||||
dns_rdatacallbacks_init(&callbacks);
|
||||
result = dns_db_beginload(db, &callbacks);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto failure;
|
||||
}
|
||||
if (filename != NULL) {
|
||||
/*
|
||||
* Load the hints from the specified filename.
|
||||
@@ -232,18 +251,22 @@ dns_rootns_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
|
||||
result = dns_master_loadbuffer(
|
||||
&source, &db->origin, &db->origin, db->rdclass,
|
||||
DNS_MASTER_HINT, &callbacks, db->mctx);
|
||||
} else
|
||||
} else {
|
||||
result = ISC_R_NOTFOUND;
|
||||
}
|
||||
eresult = dns_db_endload(db, &callbacks);
|
||||
if (result == ISC_R_SUCCESS || result == DNS_R_SEENINCLUDE)
|
||||
if (result == ISC_R_SUCCESS || result == DNS_R_SEENINCLUDE) {
|
||||
result = eresult;
|
||||
if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE)
|
||||
}
|
||||
if (result != ISC_R_SUCCESS && result != DNS_R_SEENINCLUDE) {
|
||||
goto failure;
|
||||
if (check_hints(db) != ISC_R_SUCCESS)
|
||||
}
|
||||
if (check_hints(db) != ISC_R_SUCCESS) {
|
||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
||||
DNS_LOGMODULE_HINTS, ISC_LOG_WARNING,
|
||||
"extra data in root hints '%s'",
|
||||
(filename != NULL) ? filename : "<BUILT-IN>");
|
||||
}
|
||||
*target = db;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
@@ -255,8 +278,9 @@ failure:
|
||||
(filename != NULL) ? filename : "<BUILT-IN>",
|
||||
isc_result_totext(result));
|
||||
|
||||
if (db != NULL)
|
||||
if (db != NULL) {
|
||||
dns_db_detach(&db);
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
@@ -284,17 +308,18 @@ report(dns_view_t *view, dns_name_t *name, bool missing, dns_rdata_t *rdata)
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||
databuf[isc_buffer_usedlength(&buffer)] = '\0';
|
||||
|
||||
if (missing)
|
||||
if (missing) {
|
||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
||||
DNS_LOGMODULE_HINTS, ISC_LOG_WARNING,
|
||||
"checkhints%s%s: %s/%s (%s) missing from hints",
|
||||
sep, viewname, namebuf, typebuf, databuf);
|
||||
else
|
||||
} else {
|
||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
||||
DNS_LOGMODULE_HINTS, ISC_LOG_WARNING,
|
||||
"checkhints%s%s: %s/%s (%s) extra record "
|
||||
"in hints",
|
||||
sep, viewname, namebuf, typebuf, databuf);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
@@ -306,8 +331,9 @@ inrrset(dns_rdataset_t *rrset, dns_rdata_t *rdata)
|
||||
result = dns_rdataset_first(rrset);
|
||||
while (result == ISC_R_SUCCESS) {
|
||||
dns_rdataset_current(rrset, ¤t);
|
||||
if (dns_rdata_compare(rdata, ¤t) == 0)
|
||||
if (dns_rdata_compare(rdata, ¤t) == 0) {
|
||||
return (true);
|
||||
}
|
||||
dns_rdata_reset(¤t);
|
||||
result = dns_rdataset_next(rrset);
|
||||
}
|
||||
@@ -345,16 +371,18 @@ check_address_records(dns_view_t *view, dns_db_t *hints, dns_db_t *db,
|
||||
while (result == ISC_R_SUCCESS) {
|
||||
dns_rdata_reset(&rdata);
|
||||
dns_rdataset_current(&rootrrset, &rdata);
|
||||
if (!inrrset(&hintrrset, &rdata))
|
||||
if (!inrrset(&hintrrset, &rdata)) {
|
||||
report(view, name, true, &rdata);
|
||||
}
|
||||
result = dns_rdataset_next(&rootrrset);
|
||||
}
|
||||
result = dns_rdataset_first(&hintrrset);
|
||||
while (result == ISC_R_SUCCESS) {
|
||||
dns_rdata_reset(&rdata);
|
||||
dns_rdataset_current(&hintrrset, &rdata);
|
||||
if (!inrrset(&rootrrset, &rdata))
|
||||
if (!inrrset(&rootrrset, &rdata)) {
|
||||
report(view, name, false, &rdata);
|
||||
}
|
||||
result = dns_rdataset_next(&hintrrset);
|
||||
}
|
||||
}
|
||||
@@ -368,10 +396,12 @@ check_address_records(dns_view_t *view, dns_db_t *hints, dns_db_t *db,
|
||||
result = dns_rdataset_next(&rootrrset);
|
||||
}
|
||||
}
|
||||
if (dns_rdataset_isassociated(&rootrrset))
|
||||
if (dns_rdataset_isassociated(&rootrrset)) {
|
||||
dns_rdataset_disassociate(&rootrrset);
|
||||
if (dns_rdataset_isassociated(&hintrrset))
|
||||
}
|
||||
if (dns_rdataset_isassociated(&hintrrset)) {
|
||||
dns_rdataset_disassociate(&hintrrset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check AAAA records.
|
||||
@@ -387,8 +417,9 @@ check_address_records(dns_view_t *view, dns_db_t *hints, dns_db_t *db,
|
||||
while (result == ISC_R_SUCCESS) {
|
||||
dns_rdata_reset(&rdata);
|
||||
dns_rdataset_current(&rootrrset, &rdata);
|
||||
if (!inrrset(&hintrrset, &rdata))
|
||||
if (!inrrset(&hintrrset, &rdata)) {
|
||||
report(view, name, true, &rdata);
|
||||
}
|
||||
dns_rdata_reset(&rdata);
|
||||
result = dns_rdataset_next(&rootrrset);
|
||||
}
|
||||
@@ -396,8 +427,9 @@ check_address_records(dns_view_t *view, dns_db_t *hints, dns_db_t *db,
|
||||
while (result == ISC_R_SUCCESS) {
|
||||
dns_rdata_reset(&rdata);
|
||||
dns_rdataset_current(&hintrrset, &rdata);
|
||||
if (!inrrset(&rootrrset, &rdata))
|
||||
if (!inrrset(&rootrrset, &rdata)) {
|
||||
report(view, name, false, &rdata);
|
||||
}
|
||||
dns_rdata_reset(&rdata);
|
||||
result = dns_rdataset_next(&hintrrset);
|
||||
}
|
||||
@@ -413,10 +445,12 @@ check_address_records(dns_view_t *view, dns_db_t *hints, dns_db_t *db,
|
||||
result = dns_rdataset_next(&rootrrset);
|
||||
}
|
||||
}
|
||||
if (dns_rdataset_isassociated(&rootrrset))
|
||||
if (dns_rdataset_isassociated(&rootrrset)) {
|
||||
dns_rdataset_disassociate(&rootrrset);
|
||||
if (dns_rdataset_isassociated(&hintrrset))
|
||||
}
|
||||
if (dns_rdataset_isassociated(&hintrrset)) {
|
||||
dns_rdataset_disassociate(&hintrrset);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -487,8 +521,9 @@ dns_root_checkhints(dns_view_t *view, dns_db_t *hints, dns_db_t *db)
|
||||
"checkhints%s%s: unable to find root "
|
||||
"NS '%s' in hints",
|
||||
sep, viewname, namebuf);
|
||||
} else
|
||||
} else {
|
||||
check_address_records(view, hints, db, &ns.name, now);
|
||||
}
|
||||
dns_rdata_reset(&rdata);
|
||||
result = dns_rdataset_next(&rootns);
|
||||
}
|
||||
@@ -522,8 +557,10 @@ dns_root_checkhints(dns_view_t *view, dns_db_t *hints, dns_db_t *db)
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (dns_rdataset_isassociated(&rootns))
|
||||
if (dns_rdataset_isassociated(&rootns)) {
|
||||
dns_rdataset_disassociate(&rootns);
|
||||
if (dns_rdataset_isassociated(&hintns))
|
||||
}
|
||||
if (dns_rdataset_isassociated(&hintns)) {
|
||||
dns_rdataset_disassociate(&hintns);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user