From 6d7e5df98f35d75e0d514d5c5944aeecfc43f194 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Thu, 3 May 2018 14:29:15 +0000 Subject: [PATCH] fix to please gcc 8 and lint. git-svn-id: file:///svn/unbound/trunk@4678 be551aaa-1e26-0410-a405-d3ace91eadb9 --- libunbound/context.c | 5 +++-- libunbound/context.h | 12 ++++++++---- libunbound/libunbound.c | 8 ++++---- libunbound/libworker.c | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/libunbound/context.c b/libunbound/context.c index 9dddb9d3c..95e6a8e7f 100644 --- a/libunbound/context.c +++ b/libunbound/context.c @@ -130,7 +130,7 @@ find_id(struct ub_ctx* ctx, int* id) struct ctx_query* context_new(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass, - void* cb, void* cbarg) + ub_callback_type cb, ub_event_callback_type cb_event, void* cbarg) { struct ctx_query* q = (struct ctx_query*)calloc(1, sizeof(*q)); if(!q) return NULL; @@ -142,8 +142,9 @@ context_new(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass, } lock_basic_unlock(&ctx->cfglock); q->node.key = &q->querynum; - q->async = (cb != NULL); + q->async = (cb != NULL && cb_event != NULL); q->cb = cb; + q->cb_event = cb_event; q->cb_arg = cbarg; q->res = (struct ub_result*)calloc(1, sizeof(*q->res)); if(!q->res) { diff --git a/libunbound/context.h b/libunbound/context.h index 5375f0423..11147226a 100644 --- a/libunbound/context.h +++ b/libunbound/context.h @@ -45,6 +45,7 @@ #include "util/rbtree.h" #include "services/modstack.h" #include "libunbound/unbound.h" +#include "libunbound/unbound-event.h" #include "util/data/packed_rrset.h" struct libworker; struct tube; @@ -148,9 +149,10 @@ struct ctx_query { /** was this query cancelled (for bg worker) */ int cancelled; - /** for async query, the callback function of type ub_callback_type - * for event callbacks the type is ub_event_callback_type */ - void* cb; + /** for async query, the callback function of type ub_callback_type */ + ub_callback_type cb; + /** for event callbacks the type is ub_event_callback_type */ + ub_event_callback_type cb_event; /** for async query, the callback user arg */ void* cb_arg; @@ -239,11 +241,13 @@ void context_query_delete(struct ctx_query* q); * @param rrtype: type * @param rrclass: class * @param cb: callback for async, or NULL for sync. + * @param cb_event: event callback for async, or NULL for sync. * @param cbarg: user arg for async queries. * @return new ctx_query or NULL for malloc failure. */ struct ctx_query* context_new(struct ub_ctx* ctx, const char* name, int rrtype, - int rrclass, void* cb, void* cbarg); + int rrclass, ub_callback_type cb, ub_event_callback_type cb_event, + void* cbarg); /** * Get a new alloc. Creates a new one or uses a cached one. diff --git a/libunbound/libunbound.c b/libunbound/libunbound.c index 729b32e33..275e8d25a 100644 --- a/libunbound/libunbound.c +++ b/libunbound/libunbound.c @@ -537,7 +537,7 @@ process_answer_detail(struct ub_ctx* ctx, uint8_t* msg, uint32_t len, *cb = NULL; *cbarg = NULL; } else { - *cb = (ub_callback_type)q->cb; + *cb = q->cb; *cbarg = q->cb_arg; } if(*err) { @@ -690,7 +690,7 @@ ub_resolve(struct ub_ctx* ctx, const char* name, int rrtype, } /* create new ctx_query and attempt to add to the list */ lock_basic_unlock(&ctx->cfglock); - q = context_new(ctx, name, rrtype, rrclass, NULL, NULL); + q = context_new(ctx, name, rrtype, rrclass, NULL, NULL, NULL); if(!q) return UB_NOMEM; /* become a resolver thread for a bit */ @@ -747,7 +747,7 @@ ub_resolve_event(struct ub_ctx* ctx, const char* name, int rrtype, ub_comm_base_now(ctx->event_worker->base); /* create new ctx_query and attempt to add to the list */ - q = context_new(ctx, name, rrtype, rrclass, callback, mydata); + q = context_new(ctx, name, rrtype, rrclass, NULL, callback, mydata); if(!q) return UB_NOMEM; @@ -792,7 +792,7 @@ ub_resolve_async(struct ub_ctx* ctx, const char* name, int rrtype, } /* create new ctx_query and attempt to add to the list */ - q = context_new(ctx, name, rrtype, rrclass, callback, mydata); + q = context_new(ctx, name, rrtype, rrclass, callback, NULL, mydata); if(!q) return UB_NOMEM; diff --git a/libunbound/libworker.c b/libunbound/libworker.c index 4380d69ca..aef117869 100644 --- a/libunbound/libworker.c +++ b/libunbound/libworker.c @@ -637,7 +637,7 @@ libworker_event_done_cb(void* arg, int rcode, sldns_buffer* buf, enum sec_status s, char* why_bogus) { struct ctx_query* q = (struct ctx_query*)arg; - ub_event_callback_type cb = (ub_event_callback_type)q->cb; + ub_event_callback_type cb = q->cb_event; void* cb_arg = q->cb_arg; int cancelled = q->cancelled;