]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
replace some occurrences of abort() by kr_require()
authorVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 3 Jun 2022 15:29:41 +0000 (17:29 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 3 Jun 2022 15:30:20 +0000 (17:30 +0200)
It provides more information and the condition is typically
easier to read, too.

daemon/worker.c
lib/cache/peek.c
lib/rplan.c
lib/zonecut.c

index 31feb7f779309d1d9451670404c08bf834fd7c14..816c3747e9118d4588fe79fd7fbb10adc53fd1a0 100644 (file)
@@ -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);
index f2ff0b8bc37ac6532f53c90466a90dd32bbd69ff..860ba86b1b039071680a45e4d4388e3da6eba9a9 100644 (file)
@@ -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;
index 3df5e1bd9ee0d2148ccdc960787d89a388f54e25..bd68f950d8d28a7602a792800e824e96ccd1c4d3 100644 (file)
@@ -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 */
index 774789fca6a0965b8d536f2f46595cd270b7a0a1..e9f8b3a4f26b104a30588af16d4d4b14caa4414c 100644 (file)
@@ -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;