summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimír Čunát <vladimir.cunat@nic.cz>2024-12-30 17:25:20 +0100
committerVladimír Čunát <vladimir.cunat@nic.cz>2024-12-30 17:25:20 +0100
commit2e2fbe1720f2e1bfbd5f72631d51241a541aa985 (patch)
tree94d3990363db753ad3a179c37e295b5b09162aee
parentdaemon/defer: add subpriorities by prefix length (diff)
downloadknot-resolver-2e2fbe1720f2e1bfbd5f72631d51241a541aa985.tar.xz
knot-resolver-2e2fbe1720f2e1bfbd5f72631d51241a541aa985.zip
daemon/defer: avoid warnings from gcc and coverity
-rw-r--r--daemon/defer.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/daemon/defer.c b/daemon/defer.c
index 2718a6c6..3c491731 100644
--- a/daemon/defer.c
+++ b/daemon/defer.c
@@ -302,6 +302,9 @@ static inline int classify(const union kr_sockaddr *addr, bool stream)
} else if (addr->ip.sa_family == AF_INET) {
memcpy(key, &addr->ip4.sin_addr, 4);
kru_conf = &V4_CONF;
+ } else {
+ kr_assert(false);
+ return PRIORITY_UDP; // shouldn't happen anyway
}
uint16_t load;
@@ -371,7 +374,8 @@ static inline struct protolayer_iter_ctx *pop_query(void)
int i;
if (phase == PHASE_NON_UDP) {
for (; queue_ix < QUEUES_CNT && queue_len(queues[queue_ix]) == 0; queue_ix++);
- if (queue_ix >= PRIORITY_UDP) kr_assert(false);
+ if (kr_fails_assert(queue_ix < PRIORITY_UDP))
+ return NULL;
i = queue_ix;
} else {
i = PRIORITY_UDP;
@@ -461,6 +465,7 @@ static inline void process_single_deferred(void)
int priority = classify((const union kr_sockaddr *)ctx->comm->src_addr, ctx->session->stream);
if (priority > queue_ix) { // priority dropped (got higher value)
VERBOSE_LOG(" PUSH to %d\n", priority);
+ kr_require(priority >= 0); // placate static analyzers; queue_ix can't be negative
push_query(ctx, priority, false);
return;
}