All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Two missing clean ups for nfs-utils
@ 2008-10-02 15:54 Chuck Lever
       [not found] ` <20081002154752.25618.18842.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Chuck Lever @ 2008-10-02 15:54 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Hi Steve-

The following two clean-up patches are not included in your nfs-utils
git repo, but were sent in my September 5 patch set for nfs-utils.

For reference, these were patches 13/19 and 14/19 in that series.

---

Chuck Lever (2):
      nfs-utils: make makesock() static
      nfs-utils: Clean up support/nfs/rpcmisc.c:closedown()


 support/nfs/rpcmisc.c |  130 +++++++++++++++++++++++++------------------------
 1 files changed, 65 insertions(+), 65 deletions(-)

-- 
Chuck Lever

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

* [PATCH 1/2] nfs-utils: Clean up support/nfs/rpcmisc.c:closedown()
       [not found] ` <20081002154752.25618.18842.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
@ 2008-10-02 15:54   ` Chuck Lever
       [not found]     ` <20081002155412.25618.89699.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
  2008-10-02 15:54   ` [PATCH 2/2] nfs-utils: make makesock() static Chuck Lever
  1 sibling, 1 reply; 4+ messages in thread
From: Chuck Lever @ 2008-10-02 15:54 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Clean up: update closedown()'s synopsis to modern C style, and move the
function so we can remove the forward declaration.

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

 support/nfs/rpcmisc.c |   48 +++++++++++++++++++++++++-----------------------
 1 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/support/nfs/rpcmisc.c b/support/nfs/rpcmisc.c
index aa23601..dab2be8 100644
--- a/support/nfs/rpcmisc.c
+++ b/support/nfs/rpcmisc.c
@@ -37,7 +37,6 @@
 #define socklen_t int
 #endif
 
-static void	closedown(int sig);
 static int	makesock(int port, int proto);
 
 #define _RPCSVC_CLOSEDOWN	120
@@ -45,6 +44,31 @@ int	_rpcpmstart = 0;
 int	_rpcfdtype = 0;
 int	_rpcsvcdirty = 0;
 
+static void
+closedown(int sig)
+{
+	(void) signal(sig, closedown);
+
+	if (_rpcsvcdirty == 0) {
+		static int size;
+		int i, openfd;
+
+		if (_rpcfdtype == SOCK_DGRAM)
+			exit(0);
+
+		if (size == 0)
+			size = getdtablesize();
+
+		for (i = 0, openfd = 0; i < size && openfd < 2; i++)
+			if (FD_ISSET(i, &svc_fdset))
+				openfd++;
+		if (openfd <= 1)
+			exit(0);
+	}
+
+	(void) alarm(_RPCSVC_CLOSEDOWN);
+}
+
 void
 rpc_init(char *name, int prog, int vers,
 	 void (*dispatch)(struct svc_req *, register SVCXPRT *),
@@ -139,28 +163,6 @@ rpc_init(char *name, int prog, int vers,
 	}
 }
 
-static void closedown(sig)
-int sig;
-{
-	(void) signal(sig, closedown);
-	if (_rpcsvcdirty == 0) {
-		static int size;
-		int i, openfd;
-
-		if (_rpcfdtype == SOCK_DGRAM)
-			exit(0);
-		if (size == 0) {
-			size = getdtablesize();
-		}
-		for (i = 0, openfd = 0; i < size && openfd < 2; i++)
-			if (FD_ISSET(i, &svc_fdset))
-				openfd++;
-		if (openfd <= 1)
-			exit(0);
-	}
-	(void) alarm(_RPCSVC_CLOSEDOWN);
-}
-
 /*
  * Create listener socket for a given port
  *


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

* [PATCH 2/2] nfs-utils: make makesock() static
       [not found] ` <20081002154752.25618.18842.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
  2008-10-02 15:54   ` [PATCH 1/2] nfs-utils: Clean up support/nfs/rpcmisc.c:closedown() Chuck Lever
@ 2008-10-02 15:54   ` Chuck Lever
  1 sibling, 0 replies; 4+ messages in thread
From: Chuck Lever @ 2008-10-02 15:54 UTC (permalink / raw)
  To: steved; +Cc: linux-nfs

Clean up:  The makesock() function can become static since it is only used in
rpcmisc.c, where it is defined.  Fix some minor nits while we're in the area:

 o  Move it so we can remove it's forward declaration.

 o  Get rid of unneeded newlines in the xlog() format strings.

 o  Use htonl(INADDR_ANY) instead of INADDR_ANY to initialize sin_addr.
    Should make no run-time difference, but is slightly more proper,
    as the standard definition of INADDR_ANY is in host byte-order.

 o  Remove the parentheses in the "return" statements.

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

 support/nfs/rpcmisc.c |   82 ++++++++++++++++++++++++-------------------------
 1 files changed, 40 insertions(+), 42 deletions(-)

diff --git a/support/nfs/rpcmisc.c b/support/nfs/rpcmisc.c
index dab2be8..a0854e7 100644
--- a/support/nfs/rpcmisc.c
+++ b/support/nfs/rpcmisc.c
@@ -37,8 +37,6 @@
 #define socklen_t int
 #endif
 
-static int	makesock(int port, int proto);
-
 #define _RPCSVC_CLOSEDOWN	120
 int	_rpcpmstart = 0;
 int	_rpcfdtype = 0;
@@ -69,6 +67,46 @@ closedown(int sig)
 	(void) alarm(_RPCSVC_CLOSEDOWN);
 }
 
+/*
+ * Create listener socket for a given port
+ *
+ * Return an open network socket on success; otherwise return -1
+ * if some error occurs.
+ */
+static int
+makesock(int port, int proto)
+{
+	struct sockaddr_in sin;
+	int	sock, sock_type, val;
+
+	sock_type = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
+	sock = socket(AF_INET, sock_type, proto);
+	if (sock < 0) {
+		xlog(L_FATAL, "Could not make a socket: %s",
+					strerror(errno));
+		return -1;
+	}
+	memset((char *) &sin, 0, sizeof(sin));
+	sin.sin_family = AF_INET;
+	sin.sin_addr.s_addr = htonl(INADDR_ANY);
+	sin.sin_port = htons(port);
+
+	val = 1;
+	if (proto == IPPROTO_TCP)
+		if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
+			       &val, sizeof(val)) < 0)
+			xlog(L_ERROR, "setsockopt failed: %s",
+			     strerror(errno));
+
+	if (bind(sock, (struct sockaddr *) &sin, sizeof(sin)) == -1) {
+		xlog(L_FATAL, "Could not bind name to socket: %s",
+					strerror(errno));
+		return -1;
+	}
+
+	return sock;
+}
+
 void
 rpc_init(char *name, int prog, int vers,
 	 void (*dispatch)(struct svc_req *, register SVCXPRT *),
@@ -162,43 +200,3 @@ rpc_init(char *name, int prog, int vers,
 		alarm(_RPCSVC_CLOSEDOWN);
 	}
 }
-
-/*
- * Create listener socket for a given port
- *
- * Return an open network socket on success; otherwise return -1
- * if some error occurs.
- */
-static int
-makesock(int port, int proto)
-{
-	struct sockaddr_in sin;
-	int	sock, sock_type, val;
-
-	sock_type = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
-	sock = socket(AF_INET, sock_type, proto);
-	if (sock < 0) {
-		xlog(L_FATAL, "Could not make a socket: %s",
-					strerror(errno));
-		return -1;
-	}
-	memset((char *) &sin, 0, sizeof(sin));
-	sin.sin_family = AF_INET;
-	sin.sin_addr.s_addr = htonl(INADDR_ANY);
-	sin.sin_port = htons(port);
-
-	val = 1;
-	if (proto == IPPROTO_TCP)
-		if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
-			       &val, sizeof(val)) < 0)
-			xlog(L_ERROR, "setsockopt failed: %s",
-			     strerror(errno));
-
-	if (bind(sock, (struct sockaddr *) &sin, sizeof(sin)) == -1) {
-		xlog(L_FATAL, "Could not bind name to socket: %s",
-					strerror(errno));
-		return -1;
-	}
-
- 	return sock;
-}


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

* Re: [PATCH 1/2] nfs-utils: Clean up support/nfs/rpcmisc.c:closedown()
       [not found]     ` <20081002155412.25618.89699.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
@ 2008-10-08 14:45       ` Steve Dickson
  0 siblings, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2008-10-08 14:45 UTC (permalink / raw)
  To: Chuck Lever; +Cc: linux-nfs



Chuck Lever wrote:
> Clean up: update closedown()'s synopsis to modern C style, and move the
> function so we can remove the forward declaration.
> 
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
Committed.

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

end of thread, other threads:[~2008-10-08 14:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-02 15:54 [PATCH 0/2] Two missing clean ups for nfs-utils Chuck Lever
     [not found] ` <20081002154752.25618.18842.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-10-02 15:54   ` [PATCH 1/2] nfs-utils: Clean up support/nfs/rpcmisc.c:closedown() Chuck Lever
     [not found]     ` <20081002155412.25618.89699.stgit-meopP2rzCrTwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-10-08 14:45       ` Steve Dickson
2008-10-02 15:54   ` [PATCH 2/2] nfs-utils: make makesock() static Chuck Lever

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.