From: Grigorii Demidov Date: Fri, 13 Jan 2017 12:46:22 +0000 (+0100) Subject: layer/iterate: coverity fix + log improvement X-Git-Tag: v1.2.0-rc1~25^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67e934f9ff0ca4a75e6ec9d4d615063e4fbc28a3;p=thirdparty%2Fknot-resolver.git layer/iterate: coverity fix + log improvement --- diff --git a/lib/layer.h b/lib/layer.h index fbfe6802d..0d844b611 100644 --- a/lib/layer.h +++ b/lib/layer.h @@ -23,8 +23,10 @@ /** @internal Print a debug message related to resolution. */ #define QRVERBOSE(query, cls, fmt, ...) WITH_VERBOSE { \ unsigned _ind = 0; \ - for (struct kr_query *q = (query); q; q = q->parent, _ind += 2); \ - kr_log_verbose("[%s] %*s" fmt, cls, _ind, "", ## __VA_ARGS__); \ + struct kr_query *q = (struct kr_query *)(query); \ + uint16_t _id = q ? q->id : 0; \ + for (; q; q = q->parent, _ind += 2); \ + kr_log_verbose("[%5hu][%s] %*s" fmt, _id, cls, _ind, "", ## __VA_ARGS__); \ } #else #define QRVERBOSE(query, cls, fmt, ...) diff --git a/lib/layer/iterate.c b/lib/layer/iterate.c index 2ed1831e0..5ad9c8ece 100644 --- a/lib/layer/iterate.c +++ b/lib/layer/iterate.c @@ -31,6 +31,7 @@ #include "lib/dnssec/ta.h" #define VERBOSE_MSG(fmt...) QRVERBOSE(req->current_query, "iter", fmt) +#define QVERBOSE_MSG(qry, fmt...) QRVERBOSE(qry, "iter", fmt) /* Iterator often walks through packet section, this is an abstraction. */ typedef int (*rr_callback_t)(const knot_rrset_t *, unsigned, struct kr_request *); @@ -393,10 +394,6 @@ static int unroll_cname(knot_pkt_t *pkt, struct kr_request *req, bool referral, continue; } /* Process records matching current SNAME */ - unsigned hint = 0; - if(knot_dname_is_equal(cname, knot_pkt_qname(req->answer))) { - hint = KNOT_COMPR_HINT_QNAME; - } int state = KR_STATE_FAIL; bool to_wire = false; if (is_final) { @@ -654,6 +651,13 @@ int kr_make_query(struct kr_query *query, knot_pkt_t *pkt) query->id = kr_rand_uint(UINT16_MAX); knot_wire_set_id(pkt->wire, query->id); pkt->parsed = pkt->size; + WITH_VERBOSE { + char name_str[KNOT_DNAME_MAXLEN], type_str[16]; + knot_dname_to_str(name_str, query->sname, sizeof(name_str)); + knot_rrtype_to_string(query->stype, type_str, sizeof(type_str)); + QVERBOSE_MSG(query, "'%s' type '%s' id was assigned, parent id %hu\n", + name_str, type_str, query->parent ? query->parent->id : 0); + } return kr_ok(); }