diff mbox

[10/13] fedfsc: Display LDAP errors consistently

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

Commit Message

Chuck Lever Feb. 1, 2013, 5:21 p.m. UTC
Clean up: code in fedfs-lookup-junction and fedfs-lookup-replication
to display LDAP errors should be consistent.  Both should display the
error on stderr.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 src/fedfsc/fedfs-lookup-junction.c    |   15 ++++++++++-----
 src/fedfsc/fedfs-lookup-replication.c |    7 ++++---
 2 files changed, 14 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/src/fedfsc/fedfs-lookup-junction.c b/src/fedfsc/fedfs-lookup-junction.c
index 09fd6ad..659665b 100644
--- a/src/fedfsc/fedfs-lookup-junction.c
+++ b/src/fedfsc/fedfs-lookup-junction.c
@@ -201,19 +201,24 @@  fedfs_lookup_junction_print_resok(FedFsLookupResOk result)
 }
 
 static void
-fedfs_lookup_junction_print_result(FedFsLookupRes result)
+fedfs_lookup_junction_print_ldapresultcode(FedFsLookupRes result)
 {
-	int ldap_err;
+	int ldap_err = result.FedFsLookupRes_u.ldapResultCode;
+
+	fprintf(stderr, "LDAP result code (%d): %s\n",
+		ldap_err, ldap_err2string(ldap_err));
+}
 
+static void
+fedfs_lookup_junction_print_result(FedFsLookupRes result)
+{
 	nsdb_print_fedfsstatus(result.status);
 	switch (result.status) {
 	case FEDFS_OK:
 		fedfs_lookup_junction_print_resok(result.FedFsLookupRes_u.resok);
 		break;
 	case FEDFS_ERR_NSDB_LDAP_VAL:
-		ldap_err = result.FedFsLookupRes_u.ldapResultCode;
-		fprintf(stderr, "LDAP result code (%d): %s\n",
-			ldap_err, ldap_err2string(ldap_err));
+		fedfs_lookup_junction_print_ldapresultcode(result);
 		break;
 	default:
 		break;
diff --git a/src/fedfsc/fedfs-lookup-replication.c b/src/fedfsc/fedfs-lookup-replication.c
index 993882a..2e2332c 100644
--- a/src/fedfsc/fedfs-lookup-replication.c
+++ b/src/fedfsc/fedfs-lookup-replication.c
@@ -204,9 +204,10 @@  fedfs_lookup_replication_print_resok(FedFsLookupResOk result)
 static void
 fedfs_lookup_replication_print_ldapresultcode(FedFsLookupRes result)
 {
-	int ldap_result = result.FedFsLookupRes_u.ldapResultCode;
-	printf("LDAP result code (%d): %s\n",
-				ldap_result, ldap_err2string(ldap_result));
+	int ldap_err = result.FedFsLookupRes_u.ldapResultCode;
+
+	fprintf(stderr, "LDAP result code (%d): %s\n",
+		ldap_err, ldap_err2string(ldap_err));
 }
 
 static void