@@ -381,7 +381,7 @@ FedFsStatus nsdb_get_ncedn_s(nsdb_t host, const char *naming_context,
char **dn);
FedFsStatus nsdb_get_naming_contexts_s(nsdb_t host, char ***contexts);
FedFsStatus nsdb_find_naming_context_s(nsdb_t host, const char *entry,
- char **context, unsigned int *ldap_err);
+ char **context);
/**
* Resolve an FSN (5.2.2)
@@ -1520,9 +1520,11 @@ nsdb_update_nci_s(nsdb_t host, const char *nce, unsigned int *ldap_err)
return FEDFS_ERR_INVAL;
}
- retval = nsdb_find_naming_context_s(host, nce, &context, ldap_err);
- if (retval != FEDFS_OK)
+ retval = nsdb_find_naming_context_s(host, nce, &context);
+ if (retval != FEDFS_OK) {
+ *ldap_err = (unsigned int)nsdb_ldaperr(host);
return retval;
+ }
retval = nsdb_add_nci_attributes_s(host->fn_ldap, context, nce,
ldap_err);
@@ -1640,9 +1642,11 @@ nsdb_remove_nci_s(nsdb_t host, const char *nce, unsigned int *ldap_err)
return FEDFS_ERR_INVAL;
}
- retval = nsdb_find_naming_context_s(host, nce, &context, ldap_err);
- if (retval != FEDFS_OK)
+ retval = nsdb_find_naming_context_s(host, nce, &context);
+ if (retval != FEDFS_OK) {
+ *ldap_err = (unsigned int)nsdb_ldaperr(host);
return retval;
+ }
retval = nsdb_remove_nce_objectclass_s(host->fn_ldap, nce, ldap_err);
if (retval != FEDFS_OK)
@@ -2061,7 +2061,7 @@ out_free:
*/
static FedFsStatus
nsdb_match_root_suffix(const char *entry, char **contexts,
- char **context, unsigned int *ldap_err)
+ char **context, int *ldap_err)
{
unsigned int i;
@@ -2095,7 +2095,6 @@ found:
* @param host an initialized and bound nsdb_t object
* @param entry a NUL-terminated C string containing DN of some entry
* @param context OUT: a NUL-terminated C string containing a suffix DN
- * @param ldap_err OUT: possibly an LDAP error code
* @return a FedFsStatus code
*
* "entry" must already exist on "host". Caller must free
@@ -2106,8 +2105,7 @@ found:
* 2. For each root suffix, see if "entry" ends with that suffix
*/
FedFsStatus
-nsdb_find_naming_context_s(nsdb_t host, const char *entry, char **context,
- unsigned int *ldap_err)
+nsdb_find_naming_context_s(nsdb_t host, const char *entry, char **context)
{
char **contexts = NULL;
FedFsStatus retval;
@@ -2122,18 +2120,17 @@ nsdb_find_naming_context_s(nsdb_t host, const char *entry, char **context,
return FEDFS_ERR_INVAL;
}
- if (context == NULL || ldap_err == NULL) {
+ if (context == NULL) {
xlog(L_ERROR, "%s: Invalid parameter", __func__);
return FEDFS_ERR_INVAL;
}
retval = nsdb_get_naming_contexts_s(host, &contexts);
- if (retval != FEDFS_OK) {
- *ldap_err = (unsigned int)nsdb_ldaperr(host);
+ if (retval != FEDFS_OK)
return retval;
- }
- retval = nsdb_match_root_suffix(entry, contexts, context, ldap_err);
+ retval = nsdb_match_root_suffix(entry, contexts, context,
+ &host->fn_ldaperr);
nsdb_free_string_array(contexts);
return retval;
Simplify nsdb_find_naming_context_s() by removing the *ldaperr argument. Instead, the ldaperr value can be extracted with the new nsdb_ldaperr() function when it is needed. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> --- src/include/nsdb.h | 2 +- src/libnsdb/administrator.c | 12 ++++++++---- src/libnsdb/fileserver.c | 15 ++++++--------- 3 files changed, 15 insertions(+), 14 deletions(-)