Skip to content
Snippets Groups Projects
Commit 635e64b0 authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

clang-analyzer: mute possible null-dereference reports in tests

parent 7caf93e9
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@
int main(int argc, char *argv[])
{
plan(23);
plan_lazy();
// Test with NULL changeset
ok(changeset_size(NULL) == 0, "changeset: NULL size");
......@@ -35,6 +35,9 @@ int main(int argc, char *argv[])
changeset_t *ch = changeset_new(d);
knot_dname_free(&d, NULL);
ok(ch != NULL, "changeset: new");
if (!ch) {
return 1;
}
ok(changeset_empty(ch), "changeset: empty");
ch->soa_to = (knot_rrset_t *)0xdeadbeef;
ok(!changeset_empty(ch), "changseset: empty SOA");
......
......@@ -383,7 +383,9 @@ int main(int argc, char *argv[])
journal = journal_open(jfilename, fsize);
ok(journal != NULL, "journal: reopen after flush #%u", i);
/* Journal fillup. */
test_fillup(journal, fsize, i, sizes[i % num_sizes]);
if (journal) {
test_fillup(journal, fsize, i, sizes[i % num_sizes]);
}
}
/* Close journal. */
......
......@@ -45,6 +45,9 @@ const char *g_rdata[DATACOUNT] = {
/* @note Packet equivalence test, 5 checks. */
static void packet_match(knot_pkt_t *in, knot_pkt_t *out)
{
assert(in);
assert(out);
/* Check counts */
is_int(knot_wire_get_qdcount(out->wire),
knot_wire_get_qdcount(in->wire), "pkt: QD match");
......@@ -67,7 +70,7 @@ static void packet_match(knot_pkt_t *in, knot_pkt_t *out)
int main(int argc, char *argv[])
{
plan(25);
plan_lazy();
/* Create memory pool context. */
int ret = 0;
......@@ -83,20 +86,14 @@ int main(int argc, char *argv[])
uint8_t *edns_str = (uint8_t *)"ab";
/* Create OPT RR. */
knot_rrset_t opt_rr;
knot_rrset_t opt_rr = { 0 };
ret = knot_edns_init(&opt_rr, 1024, 0, 0, &mm);
if (ret != KNOT_EOK) {
skip_block(25, "Failed to initialize OPT RR.");
return 0;
}
ok(ret == KNOT_EOK, "initialize OPT RR");
/* Add NSID */
ret = knot_edns_add_option(&opt_rr, KNOT_EDNS_OPTION_NSID,
strlen((char *)edns_str), edns_str, &mm);
if (ret != KNOT_EOK) {
knot_rrset_clear(&opt_rr, &mm);
skip_block(25, "Failed to add NSID to OPT RR.");
return 0;
}
ok(ret == KNOT_EOK, "initialize NSID in OPT RR");
/*
* Packet writer tests.
......@@ -105,6 +102,7 @@ int main(int argc, char *argv[])
/* Create packet. */
knot_pkt_t *out = knot_pkt_new(NULL, MM_DEFAULT_BLKSIZE, &mm);
ok(out != NULL, "pkt: new");
assert(out);
/* Mark as response (not part of the test). */
knot_wire_set_qr(out->wire);
......
......@@ -28,7 +28,11 @@ static bool check_rrset(const knot_rrset_t *rrset,
const knot_dname_t *owner,
uint16_t type, uint16_t rclass)
{
const bool dname_cmp = owner == NULL ? owner == rrset->owner :
if (!rrset) {
return false;
}
const bool dname_cmp = owner == NULL ? rrset->owner == NULL:
knot_dname_is_equal(rrset->owner, owner);
return rrset->type == type && rrset->rclass == rclass && dname_cmp
&& rrset->rrs.rr_count == 0; // We do not test rdataset here
......@@ -66,6 +70,7 @@ int main(int argc, char *argv[])
ok(check_rrset(copy, rrset->owner, rrset->type, rrset->rclass),
"rrset: set fields during copy.");
ok(knot_rrset_copy(NULL, NULL) == NULL, "rrset: copy NULL.");
assert(copy);
// Test equal - pointers
ok(knot_rrset_equal((knot_rrset_t *)0xdeadbeef, (knot_rrset_t *)0xdeadbeef,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment