From 3ff729e6c8a371e7a52914772816c39ca73c50a9 Mon Sep 17 00:00:00 2001 From: Jan Zeleny Date: Tue, 21 Feb 2012 07:18:12 -0500 Subject: Modifications to simplify list_missing_attrs --- src/providers/ldap/ldap_common.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/providers/ldap/ldap_common.c') diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c index 3b6a1b2ba..ee2b56b6f 100644 --- a/src/providers/ldap/ldap_common.c +++ b/src/providers/ldap/ldap_common.c @@ -1511,7 +1511,6 @@ errno_t get_sysdb_attr_name(TALLOC_CTX *mem_ctx, errno_t list_missing_attrs(TALLOC_CTX *mem_ctx, struct sdap_attr_map *map, size_t map_size, - const char **expected_attrs, struct sysdb_attrs *recvd_attrs, char ***missing_attrs) { @@ -1519,10 +1518,11 @@ errno_t list_missing_attrs(TALLOC_CTX *mem_ctx, size_t attr_count = 0; size_t i, j, k; char **missing = NULL; + const char **expected_attrs; char *sysdb_name; TALLOC_CTX *tmp_ctx; - if (!expected_attrs || !recvd_attrs || !missing_attrs) { + if (!recvd_attrs || !missing_attrs) { return EINVAL; } @@ -1531,6 +1531,11 @@ errno_t list_missing_attrs(TALLOC_CTX *mem_ctx, return ENOMEM; } + ret = build_attrs_from_map(tmp_ctx, map, map_size, &expected_attrs); + if (ret != EOK) { + goto done; + } + /* Count the expected attrs */ while(expected_attrs[attr_count]) attr_count++; @@ -1591,11 +1596,14 @@ errno_t list_missing_attrs(TALLOC_CTX *mem_ctx, } } - /* Terminate the list */ - missing[k] = NULL; - + if (k == 0) { + *missing = NULL; + } else { + /* Terminate the list */ + missing[k] = NULL; + *missing_attrs = talloc_steal(mem_ctx, missing); + } ret = EOK; - *missing_attrs = talloc_steal(mem_ctx, missing); done: talloc_free(tmp_ctx); -- cgit