From: Tomas Krizek Date: Wed, 24 Mar 2021 16:44:43 +0000 (+0100) Subject: daemon/zimport.c: replace asserts X-Git-Tag: v5.4.0~18^2~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=539748e13802567b5102402665f74400f907d9bb;p=thirdparty%2Fknot-resolver.git daemon/zimport.c: replace asserts --- diff --git a/daemon/zimport.c b/daemon/zimport.c index a63445401..69f13cdb6 100644 --- a/daemon/zimport.c +++ b/daemon/zimport.c @@ -236,8 +236,8 @@ static int zi_rrset_find_put(struct zone_import_ctx *z_import, static int zi_rrset_put(struct zone_import_ctx *z_import, knot_pkt_t *pkt, knot_rrset_t *rr) { - assert(rr); - assert(rr->type != KNOT_RRTYPE_RRSIG); + if (!kr_assume(rr && rr->type != KNOT_RRTYPE_RRSIG)) + return -1; int err = knot_pkt_put(pkt, 0, rr, 0); if (err != KNOT_EOK) { return -1; @@ -450,12 +450,15 @@ static void zi_zone_process(uv_timer_t* handle) { zone_import_ctx_t *z_import = (zone_import_ctx_t *)handle->data; - assert(z_import->worker); - size_t failed = 0; size_t ns_imported = 0; size_t other_imported = 0; + if (!kr_assume(z_import->worker)) { + failed = 1; + goto finish; + } + /* At the moment import of root zone only is supported. * Check the name of the parsed zone. * TODO - implement importing of arbitrary zone. */ @@ -725,9 +728,8 @@ int zi_zone_import(struct zone_import_ctx *z_import, const char *zone_file, const char *origin, uint16_t rclass, uint32_t ttl) { - assert (z_import != NULL && "[zimport] empty parameter"); - assert (z_import->worker != NULL && "[zimport] invalid parameter\n"); - assert (zone_file != NULL && "[zimport] empty parameter\n"); + if (!kr_assume(z_import && z_import->worker && zone_file)) + return -1; zs_scanner_t *s = malloc(sizeof(zs_scanner_t)); if (s == NULL) {