>From be62d0a093abe679d455e737fb6232c74abb160a Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 7 Jul 2014 21:29:05 +0200 Subject: [PATCH 5/7] LDAP: Remove unused output parameter _dn from sdap_parse_entry No caller directly accessed this parameter. Moreover, it seemed useless since the same data is available as SYSDB_ORIGINAL_DN in the attributes. --- src/providers/ldap/sdap.c | 14 ++------------ src/providers/ldap/sdap.h | 2 +- src/providers/ldap/sdap_async.c | 6 +++--- src/tests/cmocka/test_sdap.c | 15 +++++++-------- 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c index 4c364df73ff16c6d4975fc075a09aaf163576daa..4bb701187c385933a167f4f85d77f523808ce994 100644 --- a/src/providers/ldap/sdap.c +++ b/src/providers/ldap/sdap.c @@ -293,7 +293,7 @@ int sdap_get_map(TALLOC_CTX *memctx, int sdap_parse_entry(TALLOC_CTX *memctx, struct sdap_handle *sh, struct sdap_msg *sm, struct sdap_attr_map *map, int attrs_num, - struct sysdb_attrs **_attrs, char **_dn, + struct sysdb_attrs **_attrs, bool disable_range_retrieval) { struct sysdb_attrs *attrs; @@ -307,7 +307,6 @@ int sdap_parse_entry(TALLOC_CTX *memctx, bool store; bool base64; char *base_attr; - char *dn = NULL; uint32_t range_offset; TALLOC_CTX *tmp_ctx = talloc_new(NULL); if (!tmp_ctx) return ENOMEM; @@ -336,16 +335,8 @@ int sdap_parse_entry(TALLOC_CTX *memctx, DEBUG(SSSDBG_TRACE_LIBS, "OriginalDN: [%s].\n", str); ret = sysdb_attrs_add_string(attrs, SYSDB_ORIG_DN, str); + ldap_memfree(str); if (ret) goto done; - if (_dn) { - dn = talloc_strdup(tmp_ctx, str); - if (!dn) { - ret = ENOMEM; - ldap_memfree(str); - goto done; - } - } - ldap_memfree(str); if (map) { vals = ldap_get_values_len(sh->ldap, sm->msg, "objectClass"); @@ -523,7 +514,6 @@ int sdap_parse_entry(TALLOC_CTX *memctx, } *_attrs = talloc_steal(memctx, attrs); - if (_dn) *_dn = talloc_steal(memctx, dn); ret = EOK; done: diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h index 960054f3621ac3dfb42c6928c8b4870348883eb7..d5366ad8948619c33e0a5fa3878ef1e1900823ef 100644 --- a/src/providers/ldap/sdap.h +++ b/src/providers/ldap/sdap.h @@ -495,7 +495,7 @@ int sdap_get_map(TALLOC_CTX *memctx, int sdap_parse_entry(TALLOC_CTX *memctx, struct sdap_handle *sh, struct sdap_msg *sm, struct sdap_attr_map *map, int attrs_num, - struct sysdb_attrs **_attrs, char **_dn, + struct sysdb_attrs **_attrs, bool disable_range_retrieval); errno_t sdap_parse_deref(TALLOC_CTX *mem_ctx, diff --git a/src/providers/ldap/sdap_async.c b/src/providers/ldap/sdap_async.c index b4645738b78b7471d3e095fba490f077429432a1..590cbe100bdf5f3d6df8d9d7b356fd1d560cd729 100644 --- a/src/providers/ldap/sdap_async.c +++ b/src/providers/ldap/sdap_async.c @@ -1543,7 +1543,7 @@ static errno_t sdap_get_generic_parse_entry(struct sdap_handle *sh, ret = sdap_parse_entry(state, sh, msg, state->map, state->map_num_attrs, - &attrs, NULL, disable_range_rtrvl); + &attrs, disable_range_rtrvl); if (ret != EOK) { DEBUG(SSSDBG_MINOR_FAILURE, "sdap_parse_entry failed [%d]: %s\n", ret, strerror(ret)); @@ -1948,7 +1948,7 @@ static errno_t sdap_sd_search_parse_entry(struct sdap_handle *sh, ret = sdap_parse_entry(state, sh, msg, NULL, 0, - &attrs, NULL, disable_range_rtrvl); + &attrs, disable_range_rtrvl); if (ret != EOK) { DEBUG(SSSDBG_MINOR_FAILURE, "sdap_parse_entry failed [%d]: %s\n", ret, strerror(ret)); @@ -2201,7 +2201,7 @@ static errno_t sdap_asq_search_parse_entry(struct sdap_handle *sh, ret = sdap_parse_entry(res[mi], sh, msg, map, num_attrs, - &res[mi]->attrs, NULL, disable_range_rtrvl); + &res[mi]->attrs, disable_range_rtrvl); if (ret != EOK) { DEBUG(SSSDBG_MINOR_FAILURE, "sdap_parse_entry failed [%d]: %s\n", ret, strerror(ret)); diff --git a/src/tests/cmocka/test_sdap.c b/src/tests/cmocka/test_sdap.c index 8fdf1a4a21f7f3f436662d6ef2aee94d85be7d91..33cefcc88b3a1c662751c463cc44c19526d77169 100644 --- a/src/tests/cmocka/test_sdap.c +++ b/src/tests/cmocka/test_sdap.c @@ -255,7 +255,7 @@ void test_parse_with_map(void **state) ret = sdap_parse_entry(test_ctx, &test_ctx->sh, &test_ctx->sm, map, SDAP_OPTS_USER, - &attrs, NULL, false); + &attrs, false); assert_int_equal(ret, ERR_OK); assert_int_equal(attrs->num, 4); @@ -315,8 +315,7 @@ void test_parse_no_map(void **state) set_entry_parse(&test_nomap_entry); ret = sdap_parse_entry(test_ctx, &test_ctx->sh, &test_ctx->sm, - NULL, 0, - &attrs, NULL, false); + NULL, 0, &attrs, false); assert_int_equal(ret, ERR_OK); assert_int_equal(attrs->num, 3); @@ -361,7 +360,7 @@ void test_parse_no_attrs(void **state) ret = sdap_parse_entry(test_ctx, &test_ctx->sh, &test_ctx->sm, map, SDAP_OPTS_USER, - &attrs, NULL, false); + &attrs, false); assert_int_equal(ret, ERR_OK); assert_int_equal(attrs->num, 1); @@ -408,7 +407,7 @@ void test_parse_dups(void **state) ret = sdap_parse_entry(test_ctx, &test_ctx->sh, &test_ctx->sm, map, SDAP_OPTS_USER, - &attrs, NULL, false); + &attrs, false); assert_int_equal(ret, ERR_OK); assert_int_equal(attrs->num, 3); @@ -451,7 +450,7 @@ void test_parse_bad_oc(void **state) ret = sdap_parse_entry(test_ctx, &test_ctx->sh, &test_ctx->sm, map, SDAP_OPTS_USER, - &attrs, NULL, false); + &attrs, false); assert_int_not_equal(ret, ERR_OK); talloc_free(map); @@ -484,7 +483,7 @@ void test_parse_no_oc(void **state) ret = sdap_parse_entry(test_ctx, &test_ctx->sh, &test_ctx->sm, map, SDAP_OPTS_USER, - &attrs, NULL, false); + &attrs, false); assert_int_not_equal(ret, ERR_OK); talloc_free(map); @@ -519,7 +518,7 @@ void test_parse_no_dn(void **state) ret = sdap_parse_entry(test_ctx, &test_ctx->sh, &test_ctx->sm, map, SDAP_OPTS_USER, - &attrs, NULL, false); + &attrs, false); assert_int_not_equal(ret, ERR_OK); talloc_free(map); -- 1.9.3