]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
nfs-utils: make makesock() static
authorChuck Lever <chuck.lever@oracle.com>
Wed, 8 Oct 2008 14:45:12 +0000 (10:45 -0400)
committerSteve Dickson <steved@redhat.com>
Wed, 8 Oct 2008 14:45:12 +0000 (10:45 -0400)
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>
Signed-off-by: Steve Dickson <steved@redhat.com>
support/nfs/rpcmisc.c

index dab2be8693e58c641e31232e6e1458508c1e348f..a0854e7ef3f720a158b36f8aa6c8cf249e5dac01 100644 (file)
@@ -37,8 +37,6 @@
 #define socklen_t int
 #endif
 
 #define socklen_t int
 #endif
 
-static int     makesock(int port, int proto);
-
 #define _RPCSVC_CLOSEDOWN      120
 int    _rpcpmstart = 0;
 int    _rpcfdtype = 0;
 #define _RPCSVC_CLOSEDOWN      120
 int    _rpcpmstart = 0;
 int    _rpcfdtype = 0;
@@ -69,6 +67,46 @@ closedown(int sig)
        (void) alarm(_RPCSVC_CLOSEDOWN);
 }
 
        (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 *),
 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);
        }
 }
                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;
-}