Commit f0706399 authored by Dominik Taborsky's avatar Dominik Taborsky

changeset/apply: minor fixes

parent 327b23a2
......@@ -377,7 +377,7 @@ static int ixfrin_finalize(struct answer_data *adata)
struct ixfr_proc *ixfr = adata->ext;
assert(ixfr->state == IXFR_DONE);
apply_ctx_t a_ctx;
apply_ctx_t a_ctx = {0};
apply_init_ctx(&a_ctx);
zone_contents_t *new_contents;
......
......@@ -427,6 +427,8 @@ static int finalize_updated_zone(zone_contents_t *contents_copy,
void apply_init_ctx(apply_ctx_t *ctx)
{
assert(ctx);
init_list(&ctx->old_data);
init_list(&ctx->new_data);
}
......
......@@ -26,7 +26,7 @@
/* -------------------- Changeset iterator helpers -------------------------- */
/*! \brief Adds RRSet to given zone. */
static int add_rr_to_zone(zone_contents_t *z, knot_rrset_t **soa, const knot_rrset_t *rrset)
static int add_rr_to_contents(zone_contents_t *z, knot_rrset_t **soa, const knot_rrset_t *rrset)
{
if (rrset->type == KNOT_RRTYPE_SOA) {
if (*soa == NULL) {
......@@ -35,7 +35,7 @@ static int add_rr_to_zone(zone_contents_t *z, knot_rrset_t **soa, const knot_rrs
return KNOT_ENOMEM;
}
}
// Do not add SOAs into actual contents.
/* Do not add SOAs into actual contents. */
return KNOT_EOK;
}
......@@ -272,17 +272,17 @@ int changeset_add_rrset(changeset_t *ch, const knot_rrset_t *rrset, bool check_r
{
/* Check if there's any removal and remove that, then add this
* addition anyway. Required to change TTLs. */
if(check_redundancy) {
if (check_redundancy) {
need_to_insert(ch->remove, rrset);
}
return add_rr_to_zone(ch->add, &ch->soa_to, rrset);
return add_rr_to_contents(ch->add, &ch->soa_to, rrset);
}
int changeset_rem_rrset(changeset_t *ch, const knot_rrset_t *rrset, bool check_redundancy)
{
if ((check_redundancy && need_to_insert(ch->add, rrset)) || !check_redundancy) {
return add_rr_to_zone(ch->remove, &ch->soa_from, rrset);
if (!check_redundancy || need_to_insert(ch->add, rrset)) {
return add_rr_to_contents(ch->remove, &ch->soa_from, rrset);
} else {
return KNOT_EOK;
}
......
......@@ -87,8 +87,9 @@ size_t changeset_size(const changeset_t *ch);
/*!
* \brief Add RRSet to 'add' part of changeset.
*
* \param ch Changeset to add RRSet into.
* \param rrset RRSet to be added.
* \param ch Changeset to add RRSet into.
* \param rrset RRSet to be added.
* \param check_redundancy Check the added RR for redundancy already in the changeset.
*
* \return KNOT_E*
*/
......@@ -97,8 +98,9 @@ int changeset_add_rrset(changeset_t *ch, const knot_rrset_t *rrset, bool check_r
/*!
* \brief Add RRSet to 'remove' part of changeset.
*
* \param ch Changeset to add RRSet into.
* \param rrset RRSet to be added.
* \param ch Changeset to add RRSet into.
* \param rrset RRSet to be added.
* \param check_redundancy Check the added RR for redundancy already in the changeset.
*
* \return KNOT_E*
*/
......
......@@ -660,7 +660,7 @@ int event_dnssec(conf_t *conf, zone_t *zone)
bool zone_changed = !changeset_empty(&ch);
if (zone_changed) {
/* Apply change. */
apply_ctx_t a_ctx;
apply_ctx_t a_ctx = {0};
apply_init_ctx(&a_ctx);
zone_contents_t *new_contents = NULL;
......
......@@ -126,7 +126,7 @@ int zone_load_journal(conf_t *conf, zone_t *zone, zone_contents_t *contents)
}
/* Apply changesets. */
apply_ctx_t a_ctx;
apply_ctx_t a_ctx = {0};
apply_init_ctx(&a_ctx);
ret = apply_changesets_directly(&a_ctx, contents, &chgs);
......@@ -166,7 +166,7 @@ int zone_load_post(conf_t *conf, zone_t *zone, zone_contents_t *contents,
/* Apply DNSSEC changes. */
if (!changeset_empty(&change)) {
apply_ctx_t a_ctx;
apply_ctx_t a_ctx = {0};
apply_init_ctx(&a_ctx);
ret = apply_changeset_directly(&a_ctx, contents, &change);
......
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