diff mbox

[08/17] libnsdb: Remove *ldaperr argument from nsdb_find_naming_context_s()

Message ID 20140102202802.2964.4300.stgit@seurat.1015granger.net
State Accepted
Headers show

Commit Message

Chuck Lever Jan. 2, 2014, 8:28 p.m. UTC
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(-)
diff mbox

Patch

diff --git a/src/include/nsdb.h b/src/include/nsdb.h
index ae58397..c5c87dd 100644
--- a/src/include/nsdb.h
+++ b/src/include/nsdb.h
@@ -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)
diff --git a/src/libnsdb/administrator.c b/src/libnsdb/administrator.c
index d22e8c0..8092cce 100644
--- a/src/libnsdb/administrator.c
+++ b/src/libnsdb/administrator.c
@@ -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)
diff --git a/src/libnsdb/fileserver.c b/src/libnsdb/fileserver.c
index 8c451ee..d97b5d6 100644
--- a/src/libnsdb/fileserver.c
+++ b/src/libnsdb/fileserver.c
@@ -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;