Commit 94fba158 authored by Jan Včelák's avatar Jan Včelák 🚀
Browse files

review: fix coding style

parent 14638980
......@@ -144,7 +144,7 @@ const struct check_function check_functions[] = {
{check_nsec_bitmap, SEM_CHECK_NSEC | SEM_CHECK_NSEC3},
};
const int check_functions_len = sizeof(check_functions)/sizeof(struct check_function);
const int check_functions_len = sizeof(check_functions) / sizeof(struct check_function);
void err_handler_init(err_handler_t *h)
{
......@@ -164,9 +164,9 @@ void err_handler_deinit(err_handler_t *h)
}
int err_handler_node_error(err_handler_t *handler, const zone_contents_t *zone,
const zone_node_t *node, int error, const char *data)
const zone_node_t *node, int error, const char *data)
{
err_node_t * log = malloc(sizeof(err_node_t));
err_node_t *log = malloc(sizeof(err_node_t));
if (log == NULL) {
return KNOT_ENOMEM;
}
......@@ -179,7 +179,7 @@ int err_handler_node_error(err_handler_t *handler, const zone_contents_t *zone,
log->name = knot_dname_to_str_alloc(node->owner);
log->zone_name = knot_dname_to_str_alloc(zone->apex->owner);
add_tail(&handler->error_list, (node_t*)log);
add_tail(&handler->error_list, (node_t *)log);
handler->errors[-error]++;
handler->error_count++;
......@@ -189,7 +189,7 @@ int err_handler_node_error(err_handler_t *handler, const zone_contents_t *zone,
int err_handler_zone_error(err_handler_t *handler, const knot_dname_t *zname,
int error)
{
err_node_t * log = malloc(sizeof(err_node_t));
err_node_t *log = malloc(sizeof(err_node_t));
if (log == NULL) {
return KNOT_ENOMEM;
}
......@@ -199,7 +199,7 @@ int err_handler_zone_error(err_handler_t *handler, const knot_dname_t *zname,
log->zone_name = knot_dname_to_str_alloc(zname);
add_tail(&handler->error_list, (node_t*)log);
add_tail(&handler->error_list, (node_t *)log);
handler->errors[-error]++;
handler->error_count++;
......@@ -280,8 +280,8 @@ static int check_rrsig_rdata(err_handler_t *handler,
if (knot_rrsig_type_covered(rrsig, 0) != rrset->type) {
err_handler_node_error(handler, zone, node,
ZC_ERR_RRSIG_RDATA_TYPE_COVERED,
info_str);
ZC_ERR_RRSIG_RDATA_TYPE_COVERED,
info_str);
}
/* label number at the 2nd index should be same as owner's */
......@@ -293,13 +293,13 @@ static int check_rrsig_rdata(err_handler_t *handler,
/* if name has wildcard, label must not be included */
if (!knot_dname_is_wildcard(rrset->owner)) {
err_handler_node_error(handler, zone, node,
ZC_ERR_RRSIG_RDATA_LABELS,
info_str);
ZC_ERR_RRSIG_RDATA_LABELS,
info_str);
} else {
if (abs(tmp) != 1) {
err_handler_node_error(handler, zone, node,
ZC_ERR_RRSIG_RDATA_LABELS,
info_str);
ZC_ERR_RRSIG_RDATA_LABELS,
info_str);
}
}
}
......@@ -311,22 +311,22 @@ static int check_rrsig_rdata(err_handler_t *handler,
for (uint16_t i = 0; i < rr_count; ++i) {
if (original_ttl != knot_rdata_ttl(knot_rdataset_at(&rrset->rrs, i))) {
err_handler_node_error(handler, zone, node,
ZC_ERR_RRSIG_RDATA_TTL,
info_str);
ZC_ERR_RRSIG_RDATA_TTL,
info_str);
}
}
/* Check for expired signature. */
if (knot_rrsig_sig_expiration(rrsig, rr_pos) < time(NULL)) {
err_handler_node_error(handler, zone, node,
ZC_ERR_RRSIG_RDATA_EXPIRATION,
info_str);
ZC_ERR_RRSIG_RDATA_EXPIRATION,
info_str);
}
/* Check if DNSKEY exists. */
if (knot_rrset_empty(dnskey_rrset)) {
err_handler_node_error(handler, zone, node,
ZC_ERR_RRSIG_NO_DNSKEY, info_str);
ZC_ERR_RRSIG_NO_DNSKEY, info_str);
}
/* signer's name is same as in the zone apex */
......@@ -336,8 +336,8 @@ static int check_rrsig_rdata(err_handler_t *handler,
if (!knot_rrset_empty(dnskey_rrset) &&
!knot_dname_is_equal(signer, dnskey_rrset->owner)) {
err_handler_node_error(handler, zone, node,
ZC_ERR_RRSIG_RDATA_DNSKEY_OWNER,
info_str);
ZC_ERR_RRSIG_RDATA_DNSKEY_OWNER,
info_str);
}
knot_dname_free(&signer, NULL);
......@@ -374,14 +374,14 @@ static int check_rrsig_rdata(err_handler_t *handler,
match = 1;
} else {
err_handler_node_error(handler, zone, node,
ZC_ERR_RRSIG_RDATA_SIGNED_WRONG,
"DNSKEY RDATA not matching");
ZC_ERR_RRSIG_RDATA_SIGNED_WRONG,
"DNSKEY RDATA not matching");
}
}
if (!match) {
err_handler_node_error(handler, zone, node,
ZC_ERR_RRSIG_NO_DNSKEY, info_str);
ZC_ERR_RRSIG_NO_DNSKEY, info_str);
}
return KNOT_EOK;
......@@ -392,7 +392,7 @@ static void check_signed_rrsig(const zone_node_t *node, semchecks_data_t *data)
/* signed rrsig - nonsense */
if (node_rrtype_is_signed(node, KNOT_RRTYPE_RRSIG)) {
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_RRSIG_SIGNED, NULL);
ZC_ERR_RRSIG_SIGNED, NULL);
}
}
/*!
......@@ -435,16 +435,16 @@ static int check_rrsig_in_rrset(err_handler_t *handler,
if (ret == KNOT_ENOENT) {
err_handler_node_error(handler, zone, node,
ZC_ERR_RRSIG_NO_RRSIG,
info_str);
ZC_ERR_RRSIG_NO_RRSIG,
info_str);
return KNOT_EOK;
}
const knot_rdata_t *sig_rr = knot_rdataset_at(&rrsigs, 0);
if (knot_rdata_ttl(knot_rdataset_at(&rrset->rrs, 0)) != knot_rdata_ttl(sig_rr)) {
err_handler_node_error(handler, zone, node,
ZC_ERR_RRSIG_TTL,
info_str);
ZC_ERR_RRSIG_TTL,
info_str);
}
for (uint16_t i = 0; i < (&rrsigs)->rr_count; ++i) {
......@@ -460,7 +460,7 @@ static int check_rrsig_in_rrset(err_handler_t *handler,
}
/*!
* \brief Check if glue record for delegation are presenr.
* \brief Check if glue record for delegation is present.
*
* Also check if there is NS record in the zone.
* \param node Node to check
......@@ -474,8 +474,7 @@ static void check_delegation(const zone_node_t *node, semchecks_data_t *data)
const knot_rdataset_t *ns_rrs = node_rdataset(node, KNOT_RRTYPE_NS);
if (ns_rrs == NULL) {
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_MISSING_NS_DEL_POINT,
NULL);
ZC_ERR_MISSING_NS_DEL_POINT, NULL);
return;
}
......@@ -500,9 +499,8 @@ static void check_delegation(const zone_node_t *node, semchecks_data_t *data)
const zone_node_t *wildcard_node =
zone_contents_find_node(data->zone, wildcard);
if (wildcard_node == NULL) {
err_handler_node_error(
data->handler, data->zone, node,
ZC_ERR_GLUE_NODE, NULL);
err_handler_node_error(data->handler, data->zone,
node, ZC_ERR_GLUE_NODE, NULL);
// Cannot continue
return;
}
......@@ -511,7 +509,7 @@ static void check_delegation(const zone_node_t *node, semchecks_data_t *data)
if (!node_rrtype_exists(glue_node, KNOT_RRTYPE_A) &&
!node_rrtype_exists(glue_node, KNOT_RRTYPE_AAAA)) {
err_handler_node_error(data->handler, data->zone,
node, ZC_ERR_GLUE_RECORD, NULL);
node, ZC_ERR_GLUE_RECORD, NULL);
}
}
}
......@@ -551,7 +549,7 @@ static void check_rrsig(const zone_node_t *node, semchecks_data_t *data)
* \brief Add all RR types from a node into the bitmap.
*/
inline static void bitmap_add_all_node_rrsets(dnssec_nsec_bitmap_t *bitmap,
const zone_node_t *node)
const zone_node_t *node)
{
bool deleg = node->flags && NODE_FLAGS_DELEG;
for (int i = 0; i < node->rrset_count; i++) {
......@@ -596,7 +594,7 @@ static void check_nsec_bitmap(const zone_node_t *node, semchecks_data_t *data)
// create NSEC bitmap from node
dnssec_nsec_bitmap_t *node_bitmap = dnssec_nsec_bitmap_new();
if (node_bitmap == NULL) {
return ;
return;
}
bitmap_add_all_node_rrsets(node_bitmap, node);
......@@ -620,9 +618,9 @@ static void check_nsec_bitmap(const zone_node_t *node, semchecks_data_t *data)
if (node_wire_size != nsec_wire_size ||
memcmp(node_wire, nsec_wire, node_wire_size) != 0) {
err_handler_node_error(data->handler,
data->zone, node,
ZC_ERR_NSEC_RDATA_BITMAP,
NULL);
data->zone, node,
ZC_ERR_NSEC_RDATA_BITMAP,
NULL);
}
free(node_wire);
......@@ -643,26 +641,25 @@ static void check_nsec(const zone_node_t *node, semchecks_data_t *data)
}
/* check for NSEC record */
const knot_rdataset_t *nsec_rrs =
node_rdataset(node, KNOT_RRTYPE_NSEC);
const knot_rdataset_t *nsec_rrs = node_rdataset(node, KNOT_RRTYPE_NSEC);
if (nsec_rrs == NULL) {
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_NO_NSEC, NULL);
ZC_ERR_NO_NSEC, NULL);
return;
}
/* Test that only one record is in the NSEC RRSet */
if (nsec_rrs->rr_count != 1) {
err_handler_node_error(data->handler,
data->zone, node,
ZC_ERR_NSEC_RDATA_MULTIPLE,
NULL);
data->zone, node,
ZC_ERR_NSEC_RDATA_MULTIPLE,
NULL);
}
if (data->next_nsec != node ) {
if (data->next_nsec != node) {
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_NSEC_RDATA_CHAIN,
NULL);
ZC_ERR_NSEC_RDATA_CHAIN,
NULL);
}
/*
......@@ -678,8 +675,8 @@ static void check_nsec(const zone_node_t *node, semchecks_data_t *data)
if (data->next_nsec == NULL) {
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_NSEC_RDATA_CHAIN,
NULL);
ZC_ERR_NSEC_RDATA_CHAIN,
NULL);
}
}
......@@ -699,9 +696,8 @@ static void check_nsec3_opt_out(const zone_node_t *node, semchecks_data_t *data)
/* I know it's probably not what RFCs say, but it will have to
* do for now. */
if (node_rrtype_exists(node, KNOT_RRTYPE_DS)) {
err_handler_node_error(
data->handler, data->zone, node,
ZC_ERR_NSEC3_UNSECURED_DELEGATION, NULL);
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_NSEC3_UNSECURED_DELEGATION, NULL);
return;
} else {
/* Unsecured delegation, check whether it is part of
......@@ -713,9 +709,9 @@ static void check_nsec3_opt_out(const zone_node_t *node, semchecks_data_t *data)
&nsec3_node,
&nsec3_previous) != ZONE_NAME_NOT_FOUND) {
err_handler_node_error(data->handler,
data->zone, node,
ZC_ERR_NSEC3_NOT_FOUND,
NULL);
data->zone, node,
ZC_ERR_NSEC3_NOT_FOUND,
NULL);
return;
}
assert(nsec3_previous);
......@@ -733,10 +729,9 @@ static void check_nsec3_opt_out(const zone_node_t *node, semchecks_data_t *data)
// opt-out no need to check more
return;
} else {
err_handler_node_error(data->handler,
data->zone, node,
ZC_ERR_NSEC3_UNSECURED_DELEGATION_OPT,
NULL);
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_NSEC3_UNSECURED_DELEGATION_OPT,
NULL);
/* We cannot continue from here. */
return;
}
......@@ -754,10 +749,10 @@ static void check_nsec3_opt_out(const zone_node_t *node, semchecks_data_t *data)
static void check_nsec3(const zone_node_t *node, semchecks_data_t *data)
{
assert(node);
bool auth = !(node->flags & NODE_FLAGS_NONAUTH);
bool deleg = (node->flags & NODE_FLAGS_DELEG);
bool auth = (node->flags & NODE_FLAGS_NONAUTH) == 0;
bool deleg = (node->flags & NODE_FLAGS_DELEG) != 0;
if (!(auth || deleg)) {
if (!auth && !deleg) {
return;
}
......@@ -770,7 +765,7 @@ static void check_nsec3(const zone_node_t *node, semchecks_data_t *data)
KNOT_RRTYPE_NSEC3);
if (nsec3_rrs == NULL) {
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_NSEC3_RDATA_CHAIN, NULL);
ZC_ERR_NSEC3_RDATA_CHAIN, NULL);
return;
}
......@@ -780,7 +775,7 @@ static void check_nsec3(const zone_node_t *node, semchecks_data_t *data)
uint32_t minimum_ttl = knot_soa_minimum(soa_rrs);
if (knot_rdata_ttl(nsec3_rr) != minimum_ttl) {
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_NSEC3_RDATA_TTL, NULL);
ZC_ERR_NSEC3_RDATA_TTL, NULL);
}
/* Get next nsec3 node */
......@@ -803,10 +798,10 @@ static void check_nsec3(const zone_node_t *node, semchecks_data_t *data)
if (next_nsec3 == NULL) {
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_NSEC3_RDATA_CHAIN, NULL);
ZC_ERR_NSEC3_RDATA_CHAIN, NULL);
} else if (next_nsec3->prev != nsec3_node) {
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_NSEC3_RDATA_CHAIN, NULL);
ZC_ERR_NSEC3_RDATA_CHAIN, NULL);
}
/* Check that the node only contains NSEC3 and RRSIG. */
......@@ -816,8 +811,7 @@ static void check_nsec3(const zone_node_t *node, semchecks_data_t *data)
if (!(type == KNOT_RRTYPE_NSEC3 ||
type == KNOT_RRTYPE_RRSIG)) {
err_handler_node_error(data->handler, data->zone, nsec3_node,
ZC_ERR_NSEC3_EXTRA_RECORD,
NULL);
ZC_ERR_NSEC3_EXTRA_RECORD, NULL);
}
}
}
......@@ -854,7 +848,7 @@ static void check_cname_multiple(const zone_node_t *node, semchecks_data_t *data
if (cname_rrs->rr_count != 1) {
data->fatal_error = true;
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_CNAME_MULTIPLE, NULL);
ZC_ERR_CNAME_MULTIPLE, NULL);
}
}
......@@ -871,15 +865,15 @@ static void check_dname(const zone_node_t *node, semchecks_data_t *data)
if (dname_rrs != NULL && node->children != 0) {
data->fatal_error = true;
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_DNAME_CHILDREN,
"error triggered by parent node");
ZC_ERR_DNAME_CHILDREN,
"error triggered by parent node");
}
if (node->parent != NULL && node_rrtype_exists(node->parent, KNOT_RRTYPE_DNAME)) {
data->fatal_error = true;
err_handler_node_error(data->handler, data->zone, node,
ZC_ERR_DNAME_CHILDREN,
"error triggered by child node");
ZC_ERR_DNAME_CHILDREN,
"error triggered by child node");
}
}
......@@ -893,14 +887,14 @@ static void check_nsec_cyclic(semchecks_data_t *data)
{
if (data->next_nsec == NULL) {
err_handler_node_error(data->handler, data->zone,
data->zone->apex,
ZC_ERR_NSEC_RDATA_CHAIN_NOT_CYCLIC, NULL);
data->zone->apex,
ZC_ERR_NSEC_RDATA_CHAIN_NOT_CYCLIC, NULL);
return;
}
if (!knot_dname_is_equal(data->next_nsec->owner, data->zone->apex->owner)) {
err_handler_node_error(data->handler, data->zone, data->next_nsec,
ZC_ERR_NSEC_RDATA_CHAIN_NOT_CYCLIC, NULL);
ZC_ERR_NSEC_RDATA_CHAIN_NOT_CYCLIC, NULL);
return;
}
}
......
......@@ -29,7 +29,6 @@
#include "contrib/ucw/lists.h"
#include "libknot/mm_ctx.h"
enum check_levels {
SEM_CHECK_MANDATORY = 1 << 0,
SEM_CHECK_OPTIONAL = 1 << 1,
......
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