From f6f67fcf1024f340122ff47cba536cf3e3ad1d77 Mon Sep 17 00:00:00 2001
From: Jan Kadlec <jan.kadlec@nic.cz>
Date: Thu, 3 Apr 2014 12:57:30 +0200
Subject: [PATCH] new_node: Fixed debug build + unittests build.

---
 src/knot/updates/xfr-in.c | 12 ------------
 src/knot/zone/zone-diff.c |  3 ---
 tests/conf.c              |  2 +-
 tests/dname.c             | 36 ++++++++++++++++++------------------
 tests/dnssec_nsec3.c      |  2 +-
 tests/dnssec_zone_nsec.c  |  8 ++++----
 tests/pkt.c               | 11 +++--------
 tests/process_query.c     |  2 +-
 tests/rrl.c               |  2 +-
 tests/zonedb.c            |  6 +++---
 tests/ztree.c             |  4 ++--
 11 files changed, 34 insertions(+), 54 deletions(-)

diff --git a/src/knot/updates/xfr-in.c b/src/knot/updates/xfr-in.c
index 562ded32ba..283cd663d2 100644
--- a/src/knot/updates/xfr-in.c
+++ b/src/knot/updates/xfr-in.c
@@ -85,11 +85,6 @@ int xfrin_transfer_needed(const knot_zone_contents_t *zone,
 
 	int64_t local_serial = knot_rrs_soa_serial(soa_rrs);
 	if (local_serial < 0) {
-dbg_xfrin_exec(
-		char *name = knot_dname_to_str(knot_rrset_owner(soa_rrset));
-		dbg_xfrin("Malformed data in SOA of zone %s\n", name);
-		free(name);
-);
 		return KNOT_EMALF;  // maybe some other error
 	}
 
@@ -448,13 +443,6 @@ int xfrin_process_ixfr_packet(knot_pkt_t *pkt, knot_ns_xfr_t *xfr)
 	/*! \todo This may be implemented with much less IFs! */
 
 	while (ret == KNOT_EOK && rr != NULL) {
-dbg_xfrin_exec_verb(
-		dbg_xfrin_detail("Next loop, state: %d\n", state);
-		char *name = knot_dname_to_str(knot_rrset_owner(rr));
-		dbg_xfrin_detail("Actual RR: %s, type %u.\n", name,
-				 knot_rrset_type(rr));
-		free(name);
-);
 		if (!knot_dname_is_sub(rr->owner, xfr->zone->name) &&
 		    !knot_dname_is_equal(rr->owner, xfr->zone->name)) {
 			// out-of-zone domain
diff --git a/src/knot/zone/zone-diff.c b/src/knot/zone/zone-diff.c
index c1b554ec2a..e4adec9421 100644
--- a/src/knot/zone/zone-diff.c
+++ b/src/knot/zone/zone-diff.c
@@ -414,9 +414,6 @@ static int knot_zone_diff_node(knot_node_t **node_ptr, void *data)
 
 		knot_rrset_t rrset_from_second_node = NODE_RR_INIT(node_in_second_tree, rrset.type);
 		if (knot_rrset_empty(&rrset_from_second_node)) {
-			dbg_zonediff("zone_diff: diff_node: There is no counterpart "
-			       "for RRSet of type %u in second tree.\n",
-			       rrset->type);
 			/* RRSet has been removed. Make a copy and remove. */
 			int ret = knot_zone_diff_changeset_remove_rrset(
 				param->changeset,
diff --git a/tests/conf.c b/tests/conf.c
index 506e096311..0e237c1869 100644
--- a/tests/conf.c
+++ b/tests/conf.c
@@ -123,7 +123,7 @@ int main(int argc, char *argv[])
 	} else {
 		ok(0, "TSIG key dname check - NO KEY FOUND");
 	}
-	knot_dname_free(&sample);
+	knot_dname_free(&sample, NULL);
 
 skip_all:
 
diff --git a/tests/dname.c b/tests/dname.c
index 338f8faf11..399e52b898 100644
--- a/tests/dname.c
+++ b/tests/dname.c
@@ -77,14 +77,14 @@ int main(int argc, char *argv[])
 	d = knot_dname_from_str(t);
 	ok(d && knot_dname_size(d) == len && memcmp(d, w, len) == 0,
 	   "dname_fromstr: parsed correct non-FQDN name");
-	knot_dname_free(&d);
+	knot_dname_free(&d, NULL);
 
 	/* 12. parse FQDN from string (correct) .*/
 	t = "abcd.efg.";
 	d = knot_dname_from_str(t);
 	ok(d && knot_dname_size(d) == len && memcmp(d, w, len) == 0,
 	   "dname_fromstr: parsed correct FQDN name");
-	knot_dname_free(&d);
+	knot_dname_free(&d, NULL);
 
 	/* 13. parse name from string (incorrect) .*/
 	t = "..";
@@ -97,30 +97,30 @@ int main(int argc, char *argv[])
 	t = "ab.cd.ef";
 	d = knot_dname_from_str(t);
 	ok(!knot_dname_is_sub(d, d2), "dname_subdomain: equal name");
-	knot_dname_free(&d);
+	knot_dname_free(&d, NULL);
 
 	/* 15. true subdomain */
 	t = "0.ab.cd.ef";
 	d = knot_dname_from_str(t);
 	ok(knot_dname_is_sub(d, d2), "dname_subdomain: true subdomain");
-	knot_dname_free(&d);
+	knot_dname_free(&d, NULL);
 
 	/* 16. not subdomain */
 	t = "cd.ef";
 	d = knot_dname_from_str(t);
 	ok(!knot_dname_is_sub(d, d2), "dname_subdomain: not subdomain");
-	knot_dname_free(&d);
+	knot_dname_free(&d, NULL);
 
 	/* 17. root subdomain */
 	t = ".";
 	d = knot_dname_from_str(t);
 	ok(knot_dname_is_sub(d2, d), "dname_subdomain: root subdomain");
-	knot_dname_free(&d);
-	knot_dname_free(&d2);
+	knot_dname_free(&d, NULL);
+	knot_dname_free(&d2, NULL);
 
 	/* 18-19. dname cat (valid) */
 	w = "\x03""cat";
-	d = knot_dname_copy((const uint8_t *)w);
+	d = knot_dname_copy((const uint8_t *)w, NULL);
 	t = "*";
 	d2 = knot_dname_from_str(t);
 	d2 = knot_dname_cat(d2, d);
@@ -128,23 +128,23 @@ int main(int argc, char *argv[])
 	len = 2 + 4 + 1;
 	ok (d2 && len == knot_dname_size(d2), "dname_cat: valid concatenation size");
 	ok(memcmp(d2, t, len) == 0, "dname_cat: valid concatenation");
-	knot_dname_free(&d);
-	knot_dname_free(&d2);
+	knot_dname_free(&d, NULL);
+	knot_dname_free(&d2, NULL);
 
 	/* 20-21. parse from wire (valid) */
 	t = "\x04""abcd""\x03""efg";
 	len = 10;
 	pos = 0;
-	d = knot_dname_parse((const uint8_t *)t, &pos, len);
+	d = knot_dname_parse((const uint8_t *)t, &pos, len, NULL);
 	ok(d != NULL, "dname_parse: valid name");
 	ok(pos == len, "dname_parse: valid name (parsed length)");
-	knot_dname_free(&d);
+	knot_dname_free(&d, NULL);
 
 	/* 22-23. parse from wire (invalid) */
 	t = "\x08""dddd";
 	len = 5;
 	pos = 0;
-	d = knot_dname_parse((const uint8_t *)t, &pos, len);
+	d = knot_dname_parse((const uint8_t *)t, &pos, len, NULL);
 	ok(d == NULL, "dname_parse: bad name");
 	ok(pos == 0, "dname_parse: bad name (parsed length)");
 
@@ -155,23 +155,23 @@ int main(int argc, char *argv[])
 	t = "ab.cd.fe";
 	d2 = knot_dname_from_str(t);
 	ok(!knot_dname_is_equal(d, d2), "dname_is_equal: same label count");
-	knot_dname_free(&d2);
+	knot_dname_free(&d2, NULL);
 	t = "ab.cd";
 	d2 = knot_dname_from_str(t);
 	ok(!knot_dname_is_equal(d, d2), "dname_is_equal: len(d1) < len(d2)");
-	knot_dname_free(&d2);
+	knot_dname_free(&d2, NULL);
 	t = "ab.cd.ef.gh";
 	d2 = knot_dname_from_str(t);
 	ok(!knot_dname_is_equal(d, d2), "dname_is_equal: len(d1) > len(d2)");
-	knot_dname_free(&d2);
+	knot_dname_free(&d2, NULL);
 	t = "ab.cd.efe";
 	d2 = knot_dname_from_str(t);
 	ok(!knot_dname_is_equal(d, d2), "dname_is_equal: last label longer");
-	knot_dname_free(&d2);
+	knot_dname_free(&d2, NULL);
 	t = "ab.cd.e";
 	d2 = knot_dname_from_str(t);
 	ok(!knot_dname_is_equal(d, d2), "dname_is_equal: last label shorter");
-	knot_dname_free(&d2);
+	knot_dname_free(&d2, NULL);
 
 	return 0;
 }
diff --git a/tests/dnssec_nsec3.c b/tests/dnssec_nsec3.c
index ba57c6c3d0..80cd1c72f2 100644
--- a/tests/dnssec_nsec3.c
+++ b/tests/dnssec_nsec3.c
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
 
 	free(digest);
 	free(params.salt);
-	knot_dname_free(&dname);
+	knot_dname_free(&dname, NULL);
 
 	return 0;
 }
diff --git a/tests/dnssec_zone_nsec.c b/tests/dnssec_zone_nsec.c
index b0361bd7aa..30d3e2370b 100644
--- a/tests/dnssec_zone_nsec.c
+++ b/tests/dnssec_zone_nsec.c
@@ -36,10 +36,10 @@ int main(int argc, char *argv[])
 	knot_dname_t *result = knot_create_nsec3_owner(owner, apex, &params);
 	is_int(0, knot_dname_cmp(result, expect), "create_nsec3_owner()");
 
-	knot_dname_free(&result);
-	knot_dname_free(&owner);
-	knot_dname_free(&apex);
-	knot_dname_free(&expect);
+	knot_dname_free(&result, NULL);
+	knot_dname_free(&owner, NULL);
+	knot_dname_free(&apex, NULL);
+	knot_dname_free(&expect, NULL);
 
 	return 0;
 }
diff --git a/tests/pkt.c b/tests/pkt.c
index df563b18a6..62f4f5b76d 100644
--- a/tests/pkt.c
+++ b/tests/pkt.c
@@ -20,7 +20,6 @@ LE
 
 #include "common/errcode.h"
 #include "common/mempool.h"
-#include "libknot/rrset.h"
 #include "libknot/rdata.h"
 #include "libknot/packet/pkt.h"
 #include "libknot/tsig.h"
@@ -29,12 +28,8 @@ LE
 #define NAMECOUNT 3
 #define DATACOUNT 3
 const char *g_names[NAMECOUNT] = {
-         remove the copy
-knot_rrset_t *copy;
-         remove
-        t_rrset_free(&copy, NULL)
-knot_rrset_copy(cname_rr, &copy, NULL)e_rr = copy;
-
+        "example.com",
+        "ns1.example.com",
         "ns2.example.com"
 };
 
@@ -167,7 +162,7 @@ int main(int argc, char *argv[])
 	/* Check RRs */
 	int rr_matched = 0;
 	for (unsigned i = 0; i < NAMECOUNT; ++i) {
-		if (knot_rrset_equal(out->rr[i], in->rr[i], KNOT_RRSET_COMPARE_WHOLE) > 0) {
+		if (knot_rrset_equal(&out->rr[i], &in->rr[i], KNOT_RRSET_COMPARE_WHOLE) > 0) {
 			++rr_matched;
 		}
 	}
diff --git a/tests/process_query.c b/tests/process_query.c
index 464e973450..112a275a8a 100644
--- a/tests/process_query.c
+++ b/tests/process_query.c
@@ -48,7 +48,7 @@ void create_root_zone(server_t *server, mm_ctx_t *mm)
 	zone_t *root = zone_new(conf);
 	root->contents = knot_zone_contents_new(root->name);
 
-	knot_dname_t *root_name = knot_dname_copy(root->name);
+	knot_dname_t *root_name = knot_dname_copy(root->name, NULL);
 	knot_rrset_t *soa_rrset = knot_rrset_new(root_name,
 	                                         KNOT_RRTYPE_SOA, KNOT_CLASS_IN,
 	                                         NULL);
diff --git a/tests/rrl.c b/tests/rrl.c
index dd412ea364..e7e3b66481 100644
--- a/tests/rrl.c
+++ b/tests/rrl.c
@@ -101,7 +101,7 @@ int main(int argc, char *argv[])
 
 	knot_dname_t *qname = knot_dname_from_str("beef.");
 	int ret = knot_pkt_put_question(query, qname, KNOT_CLASS_IN, KNOT_RRTYPE_A);
-	knot_dname_free(&qname);
+	knot_dname_free(&qname, NULL);
 	if (ret != KNOT_EOK) {
 		knot_pkt_free(&query);
 		return KNOT_ERROR; /* Fatal */
diff --git a/tests/zonedb.c b/tests/zonedb.c
index 0edb94cddc..e89e6836a8 100644
--- a/tests/zonedb.c
+++ b/tests/zonedb.c
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
 		} else {
 			diag("knot_zonedb_find(%s) failed", zone_list[i]);
 		}
-		knot_dname_free(&dname);
+		knot_dname_free(&dname, NULL);
 	}
 	ok(nr_passed == ZONE_COUNT, "zonedb: find exact zones");
 
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
 		} else {
 			diag("knot_zonedb_find_suffix(%s) failed", buf);
 		}
-		knot_dname_free(&dname);
+		knot_dname_free(&dname, NULL);
 	}
 	ok(nr_passed == ZONE_COUNT, "zonedb: find zones for subnames");
 
@@ -108,7 +108,7 @@ int main(int argc, char *argv[])
 		} else {
 			diag("knot_zonedb_remove_zone(%s) failed", zone_list[i]);
 		}
-		knot_dname_free(&dname);
+		knot_dname_free(&dname, NULL);
 	}
 	ok(nr_passed == ZONE_COUNT, "zonedb: removed all zones");
 
diff --git a/tests/ztree.c b/tests/ztree.c
index f646a26827..56caa74019 100644
--- a/tests/ztree.c
+++ b/tests/ztree.c
@@ -46,7 +46,7 @@ static void ztree_init_data()
 static void ztree_free_data()
 {
 	for (unsigned i = 0; i < NCOUNT; ++i)
-		knot_dname_free(NAME + i);
+		knot_dname_free(NAME + i, NULL);
 }
 
 static int ztree_iter_data(knot_node_t **node, void *data)
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
 	const knot_node_t *prev = NULL;
 	knot_dname_t *tmp_dn = knot_dname_from_str("z.ac.");
 	knot_zone_tree_find_less_or_equal(t, tmp_dn, &node, &prev);
-	knot_dname_free(&tmp_dn);
+	knot_dname_free(&tmp_dn, NULL);
 	ok(prev == NODE + 1, "ztree: ordered lookup");
 
 	/* 5. ordered traversal */
-- 
GitLab