From: Tomas Krizek Date: Wed, 24 Mar 2021 16:44:47 +0000 (+0100) Subject: lib/utils.h: replace asserts X-Git-Tag: v5.4.0~18^2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7edf43c9d4ba7d31c6e78481c137b79e6b2a937;p=thirdparty%2Fknot-resolver.git lib/utils.h: replace asserts --- diff --git a/lib/utils.h b/lib/utils.h index 5660186a7..8316a5bcd 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -1,10 +1,9 @@ -/* Copyright (C) 2014-2017 CZ.NIC, z.s.p.o. +/* Copyright (C) 2014-2021 CZ.NIC, z.s.p.o. * SPDX-License-Identifier: GPL-3.0-or-later */ #pragma once -#include #include #include #include @@ -338,7 +337,7 @@ int kr_ntop_str(int family, const void *src, uint16_t port, char *buf, size_t *b */ static inline char *kr_straddr(const struct sockaddr *addr) { - assert(addr != NULL); + if (!kr_assume(addr)) return NULL; /* We are the sinle-threaded application */ static char str[INET6_ADDRSTRLEN + 1 + 5 + 1]; size_t len = sizeof(str); @@ -481,7 +480,7 @@ char *kr_module_call(struct kr_context *ctx, const char *module, const char *pro /** Return the (covered) type of an nonempty RRset. */ static inline uint16_t kr_rrset_type_maysig(const knot_rrset_t *rr) { - assert(rr && rr->rrs.count && rr->rrs.rdata); + kr_require(rr && rr->rrs.count && rr->rrs.rdata); uint16_t type = rr->type; if (type == KNOT_RRTYPE_RRSIG) type = knot_rrsig_type_covered(rr->rrs.rdata); @@ -519,7 +518,8 @@ static inline int kr_dname_lf(uint8_t *dst, const knot_dname_t *src, bool add_wi return kr_error(EINVAL); } int len = right_aligned_dname_start[0]; - assert(right_aligned_dname_start + 1 + len - KNOT_DNAME_MAXLEN == right_aligned_dst); + if (!kr_assume(right_aligned_dname_start + 1 + len - KNOT_DNAME_MAXLEN == right_aligned_dst)) + return kr_error(EINVAL); memcpy(dst + 1, right_aligned_dname_start + 1, len); if (add_wildcard) { if (len + 2 > KNOT_DNAME_MAXLEN)