From owner-svn-src-head@FreeBSD.ORG Fri May 29 22:19:45 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B9DD6106566B; Fri, 29 May 2009 22:19:45 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A69FC8FC1F; Fri, 29 May 2009 22:19:45 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4TMJj6Y088498; Fri, 29 May 2009 22:19:45 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4TMJjZR088493; Fri, 29 May 2009 22:19:45 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <200905292219.n4TMJjZR088493@svn.freebsd.org> From: Xin LI Date: Fri, 29 May 2009 22:19:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r193070 - in head/usr.sbin: nfscbd nfsdumpstate nfsrevoke nfsuserd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 May 2009 22:19:46 -0000 Author: delphij Date: Fri May 29 22:19:45 2009 New Revision: 193070 URL: http://svn.freebsd.org/changeset/base/193070 Log: Code cleanup for nfs4 utilities: - Mark internal routines as static; - Eliminate unused parameters where possible, mark __unused for others; - Remove unused variables; - Use %jd for int64_t values in printf(); - Add appropriate %d for printf to match its parameter; - Rename a variable to resolve conflict with revoke(2); Reviewed by: rmacklem Tested with: make universe (bugs are mine) Modified: head/usr.sbin/nfscbd/nfscbd.c head/usr.sbin/nfsdumpstate/nfsdumpstate.c head/usr.sbin/nfsrevoke/nfsrevoke.c head/usr.sbin/nfsuserd/Makefile head/usr.sbin/nfsuserd/nfsuserd.c Modified: head/usr.sbin/nfscbd/nfscbd.c ============================================================================== --- head/usr.sbin/nfscbd/nfscbd.c Fri May 29 22:18:20 2009 (r193069) +++ head/usr.sbin/nfscbd/nfscbd.c Fri May 29 22:19:45 2009 (r193070) @@ -73,13 +73,13 @@ int debug = 0; pid_t children; -void nonfs(int); -void reapchild(int); -void usage(void); -void cleanup(int); -void child_cleanup(int); -void nfscbd_exit(int); -void killchildren(void); +static void nonfs(int); +static void reapchild(int); +static void usage(void); +static void cleanup(int); +static void child_cleanup(int); +static void nfscbd_exit(int); +static void killchildren(void); /* * Nfs callback server daemon. @@ -95,23 +95,18 @@ void killchildren(void); * socket from accept, pass the msgsock into the kernel via. nfssvc(). */ int -main(int argc, char *argv[], char **envp) +main(int argc, char *argv[]) { - struct group *grp; struct nfscbd_args nfscbdargs; struct nfsd_nfscbd_args nfscbdargs2; - struct passwd *pwd; - struct ucred *cr; struct sockaddr_in inetaddr, inetpeer; - struct timeval ktv; fd_set ready, sockbits; - int ch, connect_type_cnt, i, len, maxsock, msgsock, error; + int ch, connect_type_cnt, len, maxsock, msgsock, error; int nfssvc_flag, on, sock, tcpsock, ret, mustfreeai = 0; - char *cp, **cpp, princname[128]; + char *cp, princname[128]; char myname[MAXHOSTNAMELEN], *myfqdnname = NULL; struct addrinfo *aip, hints; pid_t pid; - sigset_t signew; short myport = NFSV4_CBPORT; if (modfind("nfscl") < 0) { @@ -320,24 +315,23 @@ main(int argc, char *argv[], char **envp } } -void +static void usage(void) { errx(1, "usage: nfscbd %s", USAGE); } -void -nonfs(int signo) +static void +nonfs(int signo __unused) { syslog(LOG_ERR, "missing system call: NFS not available"); } -void -reapchild(int signo) +static void +reapchild(int signo __unused) { pid_t pid; - int i; while ((pid = wait3(NULL, WNOHANG, NULL)) > 0) { if (pid == children) @@ -345,10 +339,9 @@ reapchild(int signo) } } -void +static void killchildren(void) { - int i; if (children > 0) kill(children, SIGKILL); @@ -357,8 +350,8 @@ killchildren(void) /* * Cleanup master after SIGUSR1. */ -void -cleanup(int signo) +static void +cleanup(int signo __unused) { nfscbd_exit(0); } @@ -366,14 +359,14 @@ cleanup(int signo) /* * Cleanup child after SIGUSR1. */ -void -child_cleanup(int signo) +static void +child_cleanup(int signo __unused) { exit(0); } -void -nfscbd_exit(int status) +static void +nfscbd_exit(int status __unused) { killchildren(); exit(status); Modified: head/usr.sbin/nfsdumpstate/nfsdumpstate.c ============================================================================== --- head/usr.sbin/nfsdumpstate/nfsdumpstate.c Fri May 29 22:18:20 2009 (r193069) +++ head/usr.sbin/nfsdumpstate/nfsdumpstate.c Fri May 29 22:19:45 2009 (r193070) @@ -194,7 +194,7 @@ dump_lockstate(char *fname) lp[cnt].ndlck_stateid.other[1], lp[cnt].ndlck_stateid.other[2]); else - printf("%-11s %17lld %17lld ", + printf("%-11s %17jd %17jd ", lock_flags(lp[cnt].ndlck_flags), lp[cnt].ndlck_first, lp[cnt].ndlck_end); Modified: head/usr.sbin/nfsrevoke/nfsrevoke.c ============================================================================== --- head/usr.sbin/nfsrevoke/nfsrevoke.c Fri May 29 22:18:20 2009 (r193069) +++ head/usr.sbin/nfsrevoke/nfsrevoke.c Fri May 29 22:19:45 2009 (r193070) @@ -57,8 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include -void usage(void); -extern int errno; +static void usage(void); int main(int argc, char **argv) @@ -66,7 +65,7 @@ main(int argc, char **argv) char *cp; u_char val; int cnt, even; - struct nfsd_clid revoke; + struct nfsd_clid revoke_handle; if (modfind("nfsd") < 0) errx(1, "nfsd not loaded - self terminating"); @@ -80,7 +79,7 @@ main(int argc, char **argv) even = 1; val = 0; while (*cp) { - if (*cp >= '0' & *cp <= '9') + if (*cp >= '0' && *cp <= '9') val += (u_char)(*cp - '0'); else if (*cp >= 'A' && *cp <= 'F') val += ((u_char)(*cp - 'A')) + 0xa; @@ -92,7 +91,7 @@ main(int argc, char **argv) val <<= 4; even = 0; } else { - revoke.nclid_id[cnt++] = val; + revoke_handle.nclid_id[cnt++] = val; if (cnt > NFSV4_OPAQUELIMIT) errx(1, "Clientid %s, loo long", argv[1]); val = 0; @@ -104,19 +103,19 @@ main(int argc, char **argv) /* * Do the revocation system call. */ - revoke.nclid_idlen = cnt; + revoke_handle.nclid_idlen = cnt; #ifdef DEBUG - printf("Idlen=%d\n", revoke.nclid_idlen); - for (cnt = 0; cnt < revoke.nclid_idlen; cnt++) - printf("%02x", revoke.nclid_id[cnt]); + printf("Idlen=%d\n", revoke_handle.nclid_idlen); + for (cnt = 0; cnt < revoke_handle.nclid_idlen; cnt++) + printf("%02x", revoke_handle.nclid_id[cnt]); printf("\n"); #else - if (nfssvc(NFSSVC_ADMINREVOKE, &revoke) < 0) + if (nfssvc(NFSSVC_ADMINREVOKE, &revoke_handle) < 0) err(1, "Admin revoke failed"); #endif } -void +static void usage(void) { Modified: head/usr.sbin/nfsuserd/Makefile ============================================================================== --- head/usr.sbin/nfsuserd/Makefile Fri May 29 22:18:20 2009 (r193069) +++ head/usr.sbin/nfsuserd/Makefile Fri May 29 22:19:45 2009 (r193070) @@ -2,5 +2,6 @@ PROG= nfsuserd MAN= nfsuserd.8 +WARNS?= 3 .include Modified: head/usr.sbin/nfsuserd/nfsuserd.c ============================================================================== --- head/usr.sbin/nfsuserd/nfsuserd.c Fri May 29 22:18:20 2009 (r193069) +++ head/usr.sbin/nfsuserd/nfsuserd.c Fri May 29 22:19:45 2009 (r193070) @@ -66,12 +66,12 @@ __FBSDID("$FreeBSD$"); * for NFS V4. */ -void cleanup_term(int); -void usage(void); -void nfsuserdsrv(struct svc_req *, SVCXPRT *); -bool_t xdr_getid(XDR *, caddr_t); -bool_t xdr_getname(XDR *, caddr_t); -bool_t xdr_retval(XDR *, caddr_t); +static void cleanup_term(int); +static void usage(void); +static void nfsuserdsrv(struct svc_req *, SVCXPRT *); +static bool_t xdr_getid(XDR *, caddr_t); +static bool_t xdr_getname(XDR *, caddr_t); +static bool_t xdr_retval(XDR *, caddr_t); #define MAXNAME 1024 #define MAXNFSUSERD 20 @@ -94,7 +94,7 @@ int defusertimeout = DEFUSERTIMEOUT; pid_t slaves[MAXNFSUSERD]; int -main(int argc, char *argv[], char *envp[]) +main(int argc, char *argv[]) { int i; int error, len, mustfreeai = 0; @@ -102,11 +102,10 @@ main(int argc, char *argv[], char *envp[ struct passwd *pwd; struct group *grp; int sock, one = 1; - SVCXPRT *udptransp, *tcptransp; - struct passwd *pw; + SVCXPRT *udptransp; u_short portnum; sigset_t signew; - char hostname[MAXHOSTNAMELEN + 1], *cp, **aliases; + char hostname[MAXHOSTNAMELEN + 1], *cp; struct addrinfo *aip, hints; if (modfind("nfscommon") < 0) { @@ -166,7 +165,7 @@ main(int argc, char *argv[], char *envp[ i = atoi(*argv); if (i < 10 || i > 100000) { fprintf(stderr, - "usermax out of range 10<->100000\n", i); + "usermax %d out of range 10<->100000\n", i); usage(); } nid.nid_usermax = i; @@ -178,7 +177,7 @@ main(int argc, char *argv[], char *envp[ i = atoi(*argv); if (i < 0 || i > 100000) { fprintf(stderr, - "usertimeout out of range 0<->100000\n", + "usertimeout %d out of range 0<->100000\n", i); usage(); } @@ -409,11 +408,9 @@ main(int argc, char *argv[], char *envp[ /* * The nfsuserd rpc service */ -void +static void nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp) { - int i; - char *cp; struct passwd *pwd; struct group *grp; int error; @@ -577,7 +574,7 @@ nfsuserdsrv(struct svc_req *rqstp, SVCXP /* * Xdr routine to get an id number */ -bool_t +static bool_t xdr_getid(XDR *xdrsp, caddr_t cp) { struct info *ifp = (struct info *)cp; @@ -588,7 +585,7 @@ xdr_getid(XDR *xdrsp, caddr_t cp) /* * Xdr routine to get a user name */ -bool_t +static bool_t xdr_getname(XDR *xdrsp, caddr_t cp) { struct info *ifp = (struct info *)cp; @@ -607,7 +604,7 @@ xdr_getname(XDR *xdrsp, caddr_t cp) /* * Xdr routine to return the value. */ -bool_t +static bool_t xdr_retval(XDR *xdrsp, caddr_t cp) { struct info *ifp = (struct info *)cp; @@ -620,8 +617,8 @@ xdr_retval(XDR *xdrsp, caddr_t cp) /* * cleanup_term() called via SIGUSR1. */ -void -cleanup_term(int signo) +static void +cleanup_term(int signo __unused) { int i, cnt; @@ -656,7 +653,7 @@ cleanup_term(int signo) exit(0); } -void +static void usage(void) {