fix to please gcc 8 and lint.

git-svn-id: file:///svn/unbound/trunk@4678 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2018-05-03 14:29:15 +00:00
parent 1d5d95c8cb
commit 6d7e5df98f
4 changed files with 16 additions and 11 deletions

View file

@ -130,7 +130,7 @@ find_id(struct ub_ctx* ctx, int* id)
struct ctx_query* struct ctx_query*
context_new(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass, 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)); struct ctx_query* q = (struct ctx_query*)calloc(1, sizeof(*q));
if(!q) return NULL; 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); lock_basic_unlock(&ctx->cfglock);
q->node.key = &q->querynum; q->node.key = &q->querynum;
q->async = (cb != NULL); q->async = (cb != NULL && cb_event != NULL);
q->cb = cb; q->cb = cb;
q->cb_event = cb_event;
q->cb_arg = cbarg; q->cb_arg = cbarg;
q->res = (struct ub_result*)calloc(1, sizeof(*q->res)); q->res = (struct ub_result*)calloc(1, sizeof(*q->res));
if(!q->res) { if(!q->res) {

View file

@ -45,6 +45,7 @@
#include "util/rbtree.h" #include "util/rbtree.h"
#include "services/modstack.h" #include "services/modstack.h"
#include "libunbound/unbound.h" #include "libunbound/unbound.h"
#include "libunbound/unbound-event.h"
#include "util/data/packed_rrset.h" #include "util/data/packed_rrset.h"
struct libworker; struct libworker;
struct tube; struct tube;
@ -148,9 +149,10 @@ struct ctx_query {
/** was this query cancelled (for bg worker) */ /** was this query cancelled (for bg worker) */
int cancelled; int cancelled;
/** for async query, the callback function of type ub_callback_type /** for async query, the callback function of type ub_callback_type */
* for event callbacks the type is ub_event_callback_type */ ub_callback_type cb;
void* cb; /** for event callbacks the type is ub_event_callback_type */
ub_event_callback_type cb_event;
/** for async query, the callback user arg */ /** for async query, the callback user arg */
void* cb_arg; void* cb_arg;
@ -239,11 +241,13 @@ void context_query_delete(struct ctx_query* q);
* @param rrtype: type * @param rrtype: type
* @param rrclass: class * @param rrclass: class
* @param cb: callback for async, or NULL for sync. * @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. * @param cbarg: user arg for async queries.
* @return new ctx_query or NULL for malloc failure. * @return new ctx_query or NULL for malloc failure.
*/ */
struct ctx_query* context_new(struct ub_ctx* ctx, const char* name, int rrtype, 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. * Get a new alloc. Creates a new one or uses a cached one.

View file

@ -537,7 +537,7 @@ process_answer_detail(struct ub_ctx* ctx, uint8_t* msg, uint32_t len,
*cb = NULL; *cb = NULL;
*cbarg = NULL; *cbarg = NULL;
} else { } else {
*cb = (ub_callback_type)q->cb; *cb = q->cb;
*cbarg = q->cb_arg; *cbarg = q->cb_arg;
} }
if(*err) { 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 */ /* create new ctx_query and attempt to add to the list */
lock_basic_unlock(&ctx->cfglock); 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) if(!q)
return UB_NOMEM; return UB_NOMEM;
/* become a resolver thread for a bit */ /* 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); ub_comm_base_now(ctx->event_worker->base);
/* create new ctx_query and attempt to add to the list */ /* 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) if(!q)
return UB_NOMEM; 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 */ /* 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) if(!q)
return UB_NOMEM; return UB_NOMEM;

View file

@ -637,7 +637,7 @@ libworker_event_done_cb(void* arg, int rcode, sldns_buffer* buf,
enum sec_status s, char* why_bogus) enum sec_status s, char* why_bogus)
{ {
struct ctx_query* q = (struct ctx_query*)arg; 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; void* cb_arg = q->cb_arg;
int cancelled = q->cancelled; int cancelled = q->cancelled;