From 7efae028b0da7f094f324d8916def7452f6c71c8 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Tue, 11 Feb 2014 10:18:41 +0100 Subject: [PATCH] Eliminate use of uninitialized variable warning --- src/test/tests_dnssec.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/test/tests_dnssec.c b/src/test/tests_dnssec.c index 85195810..17aa0082 100644 --- a/src/test/tests_dnssec.c +++ b/src/test/tests_dnssec.c @@ -222,8 +222,14 @@ callbackfn(struct getdns_context *context, int main(int argc, char** argv) { - struct getdns_context *context = NULL; - getdns_return_t r = getdns_context_create(&context, 1); + const char *name = argc > 1 ? argv[1] : "www.example.com"; + struct getdns_context *context; + struct getdns_dict *extensions; + struct event_base *event_base = NULL; + getdns_transaction_t transaction_id = 0; + getdns_return_t r; + + r = getdns_context_create(&context, 1); if (r != GETDNS_RETURN_GOOD) { fprintf(stderr, "Create context failed: %d", r); return r; @@ -233,7 +239,7 @@ main(int argc, char** argv) fprintf(stderr, "Set timeout failed: %d", r); goto done_destroy_context; } - struct getdns_dict *extensions = getdns_dict_create(); + extensions = getdns_dict_create(); if (! extensions) { fprintf(stderr, "Could not create extensions dict\n"); r = GETDNS_RETURN_MEMORY_ERROR; @@ -248,7 +254,6 @@ main(int argc, char** argv) } /* Create an event base and put it in the context */ - struct event_base *event_base = NULL; event_base = event_base_new(); if (event_base == NULL) { fprintf(stderr, "Trying to create the event base failed."); @@ -257,10 +262,6 @@ main(int argc, char** argv) } (void) getdns_extension_set_libevent_base(context, event_base); - /* Set up the getdns call */ - const char *name = argc > 1 ? argv[1] : "www.example.com"; - getdns_transaction_t transaction_id = 0; - /* Make the call */ r = getdns_address(context, name, extensions, event_base, &transaction_id, callbackfn);