diff options
author | Pavel Březina <pbrezina@redhat.com> | 2013-08-02 23:07:53 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-09-05 11:14:17 +0200 |
commit | 87158890d6e7239167d7c8089070f3d2cdf5e58d (patch) | |
tree | 585db325b694694570e13c799ccc87b688255780 | |
parent | 747f30f1665a4dfcfe61a850b2e333a8bd35259b (diff) | |
download | sssd-87158890d6e7239167d7c8089070f3d2cdf5e58d.tar.gz sssd-87158890d6e7239167d7c8089070f3d2cdf5e58d.tar.xz sssd-87158890d6e7239167d7c8089070f3d2cdf5e58d.zip |
resolv_sort_srv_reply: remove unnecessary mem_ctx
-rw-r--r-- | src/providers/fail_over_srv.c | 2 | ||||
-rw-r--r-- | src/resolv/async_resolv.c | 18 | ||||
-rw-r--r-- | src/resolv/async_resolv.h | 2 | ||||
-rw-r--r-- | src/tests/resolv-tests.c | 4 |
4 files changed, 15 insertions, 11 deletions
diff --git a/src/providers/fail_over_srv.c b/src/providers/fail_over_srv.c index 189abf14b..76f6d4689 100644 --- a/src/providers/fail_over_srv.c +++ b/src/providers/fail_over_srv.c @@ -98,7 +98,7 @@ static void fo_discover_srv_done(struct tevent_req *subreq) DEBUG(SSSDBG_TRACE_FUNC, ("Got answer. Processing...\n")); /* sort and store the answer */ - ret = resolv_sort_srv_reply(state, &reply_list); + ret = resolv_sort_srv_reply(&reply_list); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, ("Could not sort the answers from DNS " "[%d]: %s\n", ret, strerror(ret))); diff --git a/src/resolv/async_resolv.c b/src/resolv/async_resolv.c index 0a2c5189f..dda288575 100644 --- a/src/resolv/async_resolv.c +++ b/src/resolv/async_resolv.c @@ -2048,8 +2048,7 @@ static struct ares_srv_reply *reply_priority_sort(struct ares_srv_reply *list) return list; } -static int reply_weight_rearrange(TALLOC_CTX *mem_ctx, - int len, +static int reply_weight_rearrange(int len, struct ares_srv_reply **start, struct ares_srv_reply **end) { @@ -2059,12 +2058,13 @@ static int reply_weight_rearrange(TALLOC_CTX *mem_ctx, struct ares_srv_reply *r, *prev, *tmp; struct ares_srv_reply *new_start = NULL; struct ares_srv_reply *new_end = NULL; + int ret; if (len <= 1) { return EOK; } - totals = talloc_array(mem_ctx, int, len); + totals = talloc_array(NULL, int, len); if (!totals) { return ENOMEM; } @@ -2122,7 +2122,8 @@ static int reply_weight_rearrange(TALLOC_CTX *mem_ctx, if (r == NULL || totals[i] == -1) { DEBUG(1, ("Bug: did not select any server!\n")); - return EIO; + ret = EIO; + goto done; } /* remove r from the old list */ @@ -2146,12 +2147,15 @@ static int reply_weight_rearrange(TALLOC_CTX *mem_ctx, /* return the rearranged list */ *start = new_start; *end = new_end; + ret = EOK; + +done: talloc_free(totals); - return EOK; + return ret; } int -resolv_sort_srv_reply(TALLOC_CTX *mem_ctx, struct ares_srv_reply **reply) +resolv_sort_srv_reply(struct ares_srv_reply **reply) { int ret; struct ares_srv_reply *pri_start, *pri_end, *next, *prev_end; @@ -2184,7 +2188,7 @@ resolv_sort_srv_reply(TALLOC_CTX *mem_ctx, struct ares_srv_reply **reply) /* rearrange each priority level according to the weight field */ next = pri_end->next; pri_end->next = NULL; - ret = reply_weight_rearrange(mem_ctx, len, &pri_start, &pri_end); + ret = reply_weight_rearrange(len, &pri_start, &pri_end); if (ret) { DEBUG(1, ("Error rearranging priority level [%d]: %s\n", ret, strerror(ret))); diff --git a/src/resolv/async_resolv.h b/src/resolv/async_resolv.h index 2895753b4..919ba370b 100644 --- a/src/resolv/async_resolv.h +++ b/src/resolv/async_resolv.h @@ -148,7 +148,7 @@ int resolv_getsrv_recv(TALLOC_CTX *mem_ctx, /* This is an implementation of section "Usage rules" of RFC 2782 */ int -resolv_sort_srv_reply(TALLOC_CTX *mem_ctx, struct ares_srv_reply **reply); +resolv_sort_srv_reply(struct ares_srv_reply **reply); /** Get TXT record **/ struct tevent_req *resolv_gettxt_send(TALLOC_CTX *mem_ctx, diff --git a/src/tests/resolv-tests.c b/src/tests/resolv-tests.c index a8e4c4120..8fde675f4 100644 --- a/src/tests/resolv-tests.c +++ b/src/tests/resolv-tests.c @@ -722,7 +722,7 @@ START_TEST(test_resolv_sort_srv_reply) } /* do the sort */ - ret = resolv_sort_srv_reply(test_ctx, &replies); + ret = resolv_sort_srv_reply(&replies); fail_if(ret != EOK); /* check if the list is sorted */ @@ -757,7 +757,7 @@ START_TEST(test_resolv_sort_srv_reply) } /* do the sort */ - ret = resolv_sort_srv_reply(test_ctx, &replies); + ret = resolv_sort_srv_reply(&replies); fail_if(ret != EOK); /* clean up */ |