All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] mountd cleanup
@ 2010-03-22  0:37 Chuck Lever
       [not found] ` <20100322003317.30360.18289.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Chuck Lever @ 2010-03-22  0:37 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Hi Steve-

These four patches clean up some spots in libexport.a.  They are
pre-requisites for mountd/exportfs IPv6 support.

---

Chuck Lever (4):
      libexport.a: e_fslocdata should be freed with free(3)
      libexport.a: Fix whitespace damage in support/export/export.c
      libexport.a: Clean up client_compose() and client_member()
      libexport.a: Remove dead code


 support/export/client.c    |   65 ++++++++++++++++++--------------------------
 support/export/export.c    |   13 +++++----
 support/include/exportfs.h |    5 +--
 3 files changed, 36 insertions(+), 47 deletions(-)

-- 
Chuck Lever

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] libexport.a: Remove dead code
       [not found] ` <20100322003317.30360.18289.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2010-03-22  0:38   ` Chuck Lever
  2010-03-22  0:38   ` [PATCH 2/4] libexport.a: Clean up client_compose() and client_member() Chuck Lever
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Chuck Lever @ 2010-03-22  0:38 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Clean up:  I can't find any call sites for client_find() or
client_match().

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

 support/export/client.c    |   22 ----------------------
 support/include/exportfs.h |    2 --
 2 files changed, 0 insertions(+), 24 deletions(-)

diff --git a/support/export/client.c b/support/export/client.c
index 6236561..f8c84de 100644
--- a/support/export/client.c
+++ b/support/export/client.c
@@ -211,28 +211,6 @@ client_freeall(void)
 	}
 }
 
-nfs_client *
-client_find(struct hostent *hp)
-{
-	nfs_client	*clp;
-	int		i;
-
-	for (i = 0; i < MCL_MAXTYPES; i++) {
-		for (clp = clientlist[i]; clp; clp = clp->m_next) {
-			if (!client_check(clp, hp))
-				continue;
-#ifdef notdef
-			if (clp->m_type == MCL_FQDN)
-				return clp;
-			return client_dup(clp, hp);
-#else
-			return clp;
-#endif
-		}
-	}
-	return NULL;
-}
-
 struct hostent *
 client_resolve(struct in_addr addr)
 {
diff --git a/support/include/exportfs.h b/support/include/exportfs.h
index 470b2ec..3eb03d9 100644
--- a/support/include/exportfs.h
+++ b/support/include/exportfs.h
@@ -69,12 +69,10 @@ extern exp_hash_table exportlist[MCL_MAXTYPES];
 extern nfs_client *		clientlist[MCL_MAXTYPES];
 
 nfs_client *			client_lookup(char *hname, int canonical);
-nfs_client *			client_find(struct hostent *);
 void				client_add(nfs_client *);
 nfs_client *			client_dup(nfs_client *, struct hostent *);
 int				client_gettype(char *hname);
 int				client_check(nfs_client *, struct hostent *);
-int				client_match(nfs_client *, char *hname);
 void				client_release(nfs_client *);
 void				client_freeall(void);
 char *				client_compose(struct hostent *he);


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] libexport.a: Clean up client_compose() and client_member()
       [not found] ` <20100322003317.30360.18289.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  2010-03-22  0:38   ` [PATCH 1/4] libexport.a: Remove dead code Chuck Lever
@ 2010-03-22  0:38   ` Chuck Lever
  2010-03-22  0:38   ` [PATCH 3/4] libexport.a: Fix whitespace damage in support/export/export.c Chuck Lever
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Chuck Lever @ 2010-03-22  0:38 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Clean up:  Replace outdated comments, and fix some function
declarations.  Use proper type for a couple of automatic variables.

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

 support/export/client.c    |   43 +++++++++++++++++++++++++++----------------
 support/include/exportfs.h |    3 ++-
 2 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/support/export/client.c b/support/export/client.c
index f8c84de..5e937b0 100644
--- a/support/export/client.c
+++ b/support/export/client.c
@@ -28,6 +28,8 @@
 #if !defined(__GLIBC__) || __GLIBC__ < 2
 extern int	innetgr(char *netgr, char *host, char *, char *);
 #endif
+
+static char	*add_name(char *old, const char *add);
 static void	client_init(nfs_client *clp, const char *hname,
 					struct hostent *hp);
 static int	client_checkaddr(nfs_client *clp, struct in_addr addr);
@@ -224,14 +226,18 @@ client_resolve(struct in_addr addr)
 	return he;
 }
 
-/*
- * Find client name given an IP address
- * This is found by gathering all known names that match that IP address,
- * sorting them and joining them with '+'
+/**
+ * client_compose - Make a list of cached hostnames that match an IP address
+ * @he: pointer to hostent containing IP address information to match
+ *
+ * Gather all known client hostnames that match the IP address, and sort
+ * the result into a comma-separated list.
  *
+ * Returns a '\0'-terminated ASCII string containing a comma-separated
+ * sorted list of client hostnames, or NULL if no client records matched
+ * the IP address or memory could not be allocated.  Caller must free the
+ * returned string with free(3).
  */
-static char *add_name(char *old, char *add);
-
 char *
 client_compose(struct hostent *he)
 {
@@ -249,13 +255,19 @@ client_compose(struct hostent *he)
 	return name;
 }
 
+/**
+ * client_member - check if @name is contained in the list @client
+ * @client: '\0'-terminated ASCII string containing
+ *		comma-separated list of hostnames
+ * @name: '\0'-terminated ASCII string containing hostname to look for
+ *
+ * Returns 1 if @name was found in @client, otherwise zero is returned.
+ */
 int
-client_member(char *client, char *name)
+client_member(const char *client, const char *name)
 {
-	/* check if "client" (a ',' separated list of names)
-	 * contains 'name' as a member
-	 */
-	int l = strlen(name);
+	size_t l = strlen(name);
+
 	while (*client) {
 		if (strncmp(client, name, l) == 0 &&
 		    (client[l] == ',' || client[l] == '\0'))
@@ -268,9 +280,8 @@ client_member(char *client, char *name)
 	return 0;
 }
 
-
-int
-name_cmp(char *a, char *b)
+static int
+name_cmp(const char *a, const char *b)
 {
 	/* compare strings a and b, but only upto ',' in a */
 	while (*a && *b && *a != ',' && *a == *b)
@@ -283,9 +294,9 @@ name_cmp(char *a, char *b)
 }
 
 static char *
-add_name(char *old, char *add)
+add_name(char *old, const char *add)
 {
-	int len = strlen(add)+2;
+	size_t len = strlen(add) + 2;
 	char *new;
 	char *cp;
 	if (old) len += strlen(old);
diff --git a/support/include/exportfs.h b/support/include/exportfs.h
index 3eb03d9..9a19cbb 100644
--- a/support/include/exportfs.h
+++ b/support/include/exportfs.h
@@ -77,7 +77,8 @@ void				client_release(nfs_client *);
 void				client_freeall(void);
 char *				client_compose(struct hostent *he);
 struct hostent *		client_resolve(struct in_addr addr);
-int 				client_member(char *client, char *name);
+int 				client_member(const char *client,
+						const char *name);
 
 int				export_read(char *fname);
 void			export_add(nfs_export *);


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] libexport.a: Fix whitespace damage in support/export/export.c
       [not found] ` <20100322003317.30360.18289.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  2010-03-22  0:38   ` [PATCH 1/4] libexport.a: Remove dead code Chuck Lever
  2010-03-22  0:38   ` [PATCH 2/4] libexport.a: Clean up client_compose() and client_member() Chuck Lever
@ 2010-03-22  0:38   ` Chuck Lever
  2010-03-22  0:38   ` [PATCH 4/4] libexport.a: e_fslocdata should be freed with free(3) Chuck Lever
  2010-03-22 14:19   ` [PATCH 0/4] mountd cleanup Steve Dickson
  4 siblings, 0 replies; 6+ messages in thread
From: Chuck Lever @ 2010-03-22  0:38 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Clean up whitespace damage introduced by commit 4cacc965.

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

 support/export/export.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/support/export/export.c b/support/export/export.c
index 2943466..ba643b2 100644
--- a/support/export/export.c
+++ b/support/export/export.c
@@ -128,6 +128,7 @@ export_dup(nfs_export *exp, struct hostent *hp)
 
 	return new;
 }
+
 /*
  * Add export entry to hash table
  */
@@ -280,11 +281,11 @@ export_freeall(void)
 			xfree(exp->m_export.e_hostname);
 			xfree(exp);
 		}
-      for(j = 0; j < HASH_TABLE_SIZE; j++) {
-        exportlist[i].entries[j].p_first = NULL;
-        exportlist[i].entries[j].p_last = NULL;
-      }
-      exportlist[i].p_head = NULL;
+		for (j = 0; j < HASH_TABLE_SIZE; j++) {
+			exportlist[i].entries[j].p_first = NULL;
+			exportlist[i].entries[j].p_last = NULL;
+		}
+		exportlist[i].p_head = NULL;
 	}
 	client_freeall();
 }


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] libexport.a: e_fslocdata should be freed with free(3)
       [not found] ` <20100322003317.30360.18289.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
                     ` (2 preceding siblings ...)
  2010-03-22  0:38   ` [PATCH 3/4] libexport.a: Fix whitespace damage in support/export/export.c Chuck Lever
@ 2010-03-22  0:38   ` Chuck Lever
  2010-03-22 14:19   ` [PATCH 0/4] mountd cleanup Steve Dickson
  4 siblings, 0 replies; 6+ messages in thread
From: Chuck Lever @ 2010-03-22  0:38 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Clean up: Since e_fslocdata is allocated with strdup(3), and not
xstrdup(), it should be freed with free(3), and not xfree().

It looks like we could get rid of the "if (thing I'm freeing isn't
NULL)" checks too, but that's for another day.

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

 support/export/export.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/support/export/export.c b/support/export/export.c
index ba643b2..42e78f6 100644
--- a/support/export/export.c
+++ b/support/export/export.c
@@ -277,7 +277,7 @@ export_freeall(void)
 			if (exp->m_export.e_mountpoint)
 				free(exp->m_export.e_mountpoint);
 			if (exp->m_export.e_fslocdata)
-				xfree(exp->m_export.e_fslocdata);
+				free(exp->m_export.e_fslocdata);
 			xfree(exp->m_export.e_hostname);
 			xfree(exp);
 		}


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] mountd cleanup
       [not found] ` <20100322003317.30360.18289.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
                     ` (3 preceding siblings ...)
  2010-03-22  0:38   ` [PATCH 4/4] libexport.a: e_fslocdata should be freed with free(3) Chuck Lever
@ 2010-03-22 14:19   ` Steve Dickson
  4 siblings, 0 replies; 6+ messages in thread
From: Steve Dickson @ 2010-03-22 14:19 UTC (permalink / raw)
  To: Chuck Lever; +Cc: linux-nfs



On 03/21/2010 08:37 PM, Chuck Lever wrote:
> Hi Steve-
> 
> These four patches clean up some spots in libexport.a.  They are
> pre-requisites for mountd/exportfs IPv6 support.
> 
> ---
> 
> Chuck Lever (4):
>       libexport.a: e_fslocdata should be freed with free(3)
>       libexport.a: Fix whitespace damage in support/export/export.c
>       libexport.a: Clean up client_compose() and client_member()
>       libexport.a: Remove dead code
> 
> 
>  support/export/client.c    |   65 ++++++++++++++++++--------------------------
>  support/export/export.c    |   13 +++++----
>  support/include/exportfs.h |    5 +--
>  3 files changed, 36 insertions(+), 47 deletions(-)
> 
Committed... 

steved.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-03-22 14:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-22  0:37 [PATCH 0/4] mountd cleanup Chuck Lever
     [not found] ` <20100322003317.30360.18289.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-03-22  0:38   ` [PATCH 1/4] libexport.a: Remove dead code Chuck Lever
2010-03-22  0:38   ` [PATCH 2/4] libexport.a: Clean up client_compose() and client_member() Chuck Lever
2010-03-22  0:38   ` [PATCH 3/4] libexport.a: Fix whitespace damage in support/export/export.c Chuck Lever
2010-03-22  0:38   ` [PATCH 4/4] libexport.a: e_fslocdata should be freed with free(3) Chuck Lever
2010-03-22 14:19   ` [PATCH 0/4] mountd cleanup Steve Dickson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.