From: Chuck Lever <chuck.lever@oracle.com>
Date: Thu, 15 Apr 2010 12:57:29 +0000 (-0400)
Subject: libexport.a: Reduce code duplication in client_init()
X-Git-Tag: nfs-utils-1-2-3-rc2~10
X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=e1c93f691348392ee36b763bf57946540891ff16;p=nfs-utils.git

libexport.a: Reduce code duplication in client_init()

Clean up:  Most cases in client_init() set clp->m_naddr to zero.  Move
it to the common part of the function, and simplify the logic.  This
will make adding IPv6 support here more straightforward.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
---

diff --git a/support/export/client.c b/support/export/client.c
index aa28fcf..e06c874 100644
--- a/support/export/client.c
+++ b/support/export/client.c
@@ -137,6 +137,7 @@ client_init(nfs_client *clp, const char *hname, struct hostent *hp)
 
 	clp->m_exported = 0;
 	clp->m_count = 0;
+	clp->m_naddr = 0;
 
 	if (clp->m_type == MCL_SUBNETWORK) {
 		char	*cp = strchr(clp->m_hostname, '/');
@@ -160,10 +161,10 @@ client_init(nfs_client *clp, const char *hname, struct hostent *hp)
 			}
 		}
 		*cp = '/';
-		clp->m_naddr = 0;
-	} else if (!hp) {
-		clp->m_naddr = 0;
-	} else {
+		return;
+	}
+
+	if (hp) {
 		char	**ap = hp->h_addr_list;
 		int	i;