From: Vladimír Čunát Date: Fri, 3 Jun 2022 15:29:41 +0000 (+0200) Subject: replace some occurrences of abort() by kr_require() X-Git-Tag: v5.5.1~7^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=246a7ae14c62569ce5508753a2510aed16c3f219;p=thirdparty%2Fknot-resolver.git replace some occurrences of abort() by kr_require() It provides more information and the condition is typically easier to read, too. --- diff --git a/daemon/worker.c b/daemon/worker.c index 31feb7f77..816c3747e 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -724,7 +724,7 @@ static int qr_task_send(struct qr_task *task, struct session *session, if (kr_fails_assert(handle && handle->data == session)) return qr_task_on_send(task, NULL, kr_error(EINVAL)); const bool is_stream = handle->type == UV_TCP; - if (!is_stream && handle->type != UV_UDP) abort(); + kr_require(is_stream || handle->type == UV_UDP); if (addr == NULL) addr = session_get_peer(session); diff --git a/lib/cache/peek.c b/lib/cache/peek.c index f2ff0b8bc..860ba86b1 100644 --- a/lib/cache/peek.c +++ b/lib/cache/peek.c @@ -75,7 +75,7 @@ static int nsec_p_ttl(knot_db_val_t entry, const uint32_t timestamp, int32_t *ne static uint8_t get_lowest_rank(const struct kr_query *qry, const knot_dname_t *name, const uint16_t type) { /* Shut up linters. */ - if (unlikely(!qry || !qry->request)) abort(); + kr_require(qry && qry->request); /* TODO: move rank handling into the iterator (DNSSEC_* flags)? */ const bool allow_unverified = knot_wire_get_cd(qry->request->qsource.packet->wire) || qry->flags.STUB; diff --git a/lib/rplan.c b/lib/rplan.c index 3df5e1bd9..bd68f950d 100644 --- a/lib/rplan.c +++ b/lib/rplan.c @@ -28,7 +28,7 @@ inline static unsigned char chars_mask(const unsigned char a, const unsigned cha inline static void kr_qflags_mod(struct kr_qflags *fl1, struct kr_qflags fl2, unsigned char mod(const unsigned char a, const unsigned char b)) { - if (!fl1) abort(); + kr_require(fl1); union { struct kr_qflags flags; /* C99 section 6.5.3.4: sizeof(char) == 1 */ diff --git a/lib/zonecut.c b/lib/zonecut.c index 774789fca..e9f8b3a4f 100644 --- a/lib/zonecut.c +++ b/lib/zonecut.c @@ -87,7 +87,7 @@ void kr_zonecut_deinit(struct kr_zonecut *cut) void kr_zonecut_move(struct kr_zonecut *to, const struct kr_zonecut *from) { - if (!to || !from) abort(); + kr_require(to && from); kr_zonecut_deinit(to); memcpy(to, from, sizeof(*to)); } @@ -322,7 +322,7 @@ static addrset_info_t fetch_addr(pack_t *addrs, const knot_dname_t *ns, uint16_t - cached_rr.rrs.count * offsetof(knot_rdata_t, len); int ret = pack_reserve_mm(*addrs, cached_rr.rrs.count, pack_extra_size, kr_memreserve, mm_pool); - if (ret) abort(); /* ENOMEM "probably" */ + kr_require(ret == 0); /* ENOMEM "probably" */ int usable_cnt = 0; addrset_info_t result = AI_EMPTY;