Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/rpc add __RPC_GETXID macro



details:   https://anonhg.NetBSD.org/src/rev/87cf1d8e8dbd
branches:  trunk
changeset: 494403:87cf1d8e8dbd
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jul 06 03:10:34 2000 +0000

description:
add __RPC_GETXID macro
don't const castway __rpc_getconf and __rpc_getconfig. It might try to
write const strings
fix non-portable casts
remove duplicated prototypes
cast things to proper types
remove extraneous casts to NULL
fix variable cast mismatches
remove register var declarations

diffstat:

 lib/libc/rpc/clnt_generic.c |   41 ++++----
 lib/libc/rpc/clnt_raw.c     |    6 +-
 lib/libc/rpc/clnt_simple.c  |   21 ++--
 lib/libc/rpc/clnt_vc.c      |   56 ++++++-----
 lib/libc/rpc/getnetconfig.c |   13 +-
 lib/libc/rpc/getnetpath.c   |    8 +-
 lib/libc/rpc/pmap_clnt.c    |   19 ++-
 lib/libc/rpc/pmap_getmaps.c |   11 +-
 lib/libc/rpc/pmap_getport.c |    9 +-
 lib/libc/rpc/pmap_prot2.c   |    6 +-
 lib/libc/rpc/pmap_rmt.c     |    8 +-
 lib/libc/rpc/rpc_com.h      |   12 +-
 lib/libc/rpc/rpc_generic.c  |   63 +++++++-----
 lib/libc/rpc/rpc_soc.c      |   63 +++++++------
 lib/libc/rpc/rpcb_clnt.c    |  204 +++++++++++++++++++++++--------------------
 lib/libc/rpc/rpcb_prot.c    |   45 ++++----
 lib/libc/rpc/rpcb_st_xdr.c  |   32 +++---
 lib/libc/rpc/svc.c          |   65 +++++++------
 lib/libc/rpc/svc_auth.c     |   18 +-
 lib/libc/rpc/svc_dg.c       |   70 +++++++-------
 lib/libc/rpc/svc_generic.c  |   51 +++++-----
 lib/libc/rpc/svc_raw.c      |   16 ++-
 lib/libc/rpc/svc_run.c      |    7 +-
 lib/libc/rpc/svc_simple.c   |   22 ++--
 lib/libc/rpc/svc_vc.c       |   59 +++++++-----
 lib/libc/rpc/xdr.c          |    8 +-
 lib/libc/rpc/xdr_rec.c      |    7 +-
 27 files changed, 501 insertions(+), 439 deletions(-)

diffs (truncated from 3061 to 300 lines):

diff -r c83701aec823 -r 87cf1d8e8dbd lib/libc/rpc/clnt_generic.c
--- a/lib/libc/rpc/clnt_generic.c       Thu Jul 06 03:06:45 2000 +0000
+++ b/lib/libc/rpc/clnt_generic.c       Thu Jul 06 03:10:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clnt_generic.c,v 1.17 2000/06/07 18:27:39 fvdl Exp $   */
+/*     $NetBSD: clnt_generic.c,v 1.18 2000/07/06 03:10:34 christos Exp $       */
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -49,6 +49,7 @@
 #include <stdio.h>
 #include <errno.h>
 #include <rpc/rpc.h>
+#include <rpc/nettype.h>
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -100,13 +101,13 @@
                minvers = rpcerr.re_vers.low;
                maxvers = rpcerr.re_vers.high;
                if (maxvers < vers_high)
-                       vers_high = maxvers;
+                       vers_high = (rpcvers_t)maxvers;
                if (minvers > vers_low)
-                       vers_low = minvers;
+                       vers_low = (rpcvers_t)minvers;
                if (vers_low > vers_high) {
                        goto error;
                }
-               CLNT_CONTROL(clnt, CLSET_VERS, (char *)&vers_high);
+               CLNT_CONTROL(clnt, CLSET_VERS, (char *)(void *)&vers_high);
                rpc_stat = clnt_call(clnt, NULLPROC, (xdrproc_t) xdr_void,
                                (char *) NULL, (xdrproc_t) xdr_void,
                                (char *) NULL, to);
@@ -151,12 +152,12 @@
        struct rpc_err  save_cf_error;
 
 
-       if ((handle = __rpc_setconf((char *) nettype)) == NULL) {
+       if ((handle = __rpc_setconf(nettype)) == NULL) {
                rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
-               return ((CLIENT *)NULL);
+               return (NULL);
        }
        rpc_createerr.cf_stat = RPC_SUCCESS;
-       while (clnt == (CLIENT *)NULL) {
+       while (clnt == NULL) {
                if ((nconf = __rpc_getconf(handle)) == NULL) {
                        if (rpc_createerr.cf_stat == RPC_SUCCESS)
                                rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
@@ -210,17 +211,17 @@
  */
 CLIENT *
 clnt_tp_create(hostname, prog, vers, nconf)
-       const char *hostname;                           /* server name */
+       const char *hostname;                   /* server name */
        rpcprog_t prog;                         /* program number */
        rpcvers_t vers;                         /* version number */
-       const register struct netconfig *nconf; /* net config struct */
+       const struct netconfig *nconf;          /* net config struct */
 {
        struct netbuf *svcaddr;                 /* servers address */
        CLIENT *cl = NULL;                      /* client handle */
 
-       if (nconf == (struct netconfig *)NULL) {
+       if (nconf == NULL) {
                rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
-               return ((CLIENT *)NULL);
+               return (NULL);
        }
 
        /*
@@ -229,9 +230,9 @@
        if ((svcaddr = __rpcb_findaddr(prog, vers, nconf, hostname,
                &cl)) == NULL) {
                /* appropriate error number is set by rpcbind libraries */
-               return ((CLIENT *)NULL);
+               return (NULL);
        }
-       if (cl == (CLIENT *)NULL) {
+       if (cl == NULL) {
                cl = clnt_tli_create(RPC_ANYFD, nconf, svcaddr,
                                        prog, vers, 0, 0);
        } else {
@@ -264,9 +265,9 @@
  */
 CLIENT *
 clnt_tli_create(fd, nconf, svcaddr, prog, vers, sendsz, recvsz)
-       register int fd;                /* fd */
+       int fd;                         /* fd */
        const struct netconfig *nconf;  /* netconfig structure */
-       const struct netbuf *svcaddr;           /* servers address */
+       const struct netbuf *svcaddr;   /* servers address */
        rpcprog_t prog;                 /* program number */
        rpcvers_t vers;                 /* version number */
        u_int sendsz;                   /* send size */
@@ -279,9 +280,9 @@
        struct __rpc_sockinfo si;
 
        if (fd == RPC_ANYFD) {
-               if (nconf == (struct netconfig *)NULL) {
+               if (nconf == NULL) {
                        rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
-                       return ((CLIENT *)NULL);
+                       return (NULL);
                }
 
                fd = __rpc_nconf2fd(nconf);
@@ -328,7 +329,7 @@
                goto err;
        }
 
-       if (cl == (CLIENT *)NULL)
+       if (cl == NULL)
                goto err1; /* borrow errors from clnt_dg/vc creates */
        if (nconf) {
                cl->cl_netid = strdup(nconf->nc_netid);
@@ -338,7 +339,7 @@
                cl->cl_tp = "";
        }
        if (madefd) {
-               (void) CLNT_CONTROL(cl, CLSET_FD_CLOSE, (char *)NULL);
+               (void) CLNT_CONTROL(cl, CLSET_FD_CLOSE, NULL);
 /*             (void) CLNT_CONTROL(cl, CLSET_POP_TIMOD, (char *) NULL);  */
        };
 
@@ -349,5 +350,5 @@
        rpc_createerr.cf_error.re_errno = errno;
 err1:  if (madefd)
                (void) close(fd);
-       return ((CLIENT *)NULL);
+       return (NULL);
 }
diff -r c83701aec823 -r 87cf1d8e8dbd lib/libc/rpc/clnt_raw.c
--- a/lib/libc/rpc/clnt_raw.c   Thu Jul 06 03:06:45 2000 +0000
+++ b/lib/libc/rpc/clnt_raw.c   Thu Jul 06 03:10:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clnt_raw.c,v 1.17 2000/06/02 23:11:08 fvdl Exp $       */
+/*     $NetBSD: clnt_raw.c,v 1.18 2000/07/06 03:10:34 christos Exp $   */
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -35,7 +35,7 @@
 static char *sccsid = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)clnt_raw.c  2.2 88/08/01 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: clnt_raw.c,v 1.17 2000/06/02 23:11:08 fvdl Exp $");
+__RCSID("$NetBSD: clnt_raw.c,v 1.18 2000/07/06 03:10:34 christos Exp $");
 #endif
 #endif
 
@@ -185,7 +185,7 @@
        XDR_SETPOS(xdrs, 0);
        clp->u.mashl_rpcmsg.rm_xid ++ ;
        if ((! XDR_PUTBYTES(xdrs, clp->u.mashl_callmsg, clp->mcnt)) ||
-           (! XDR_PUTLONG(xdrs, (long *)&proc)) ||
+           (! XDR_PUTLONG(xdrs, (long *)(void *)&proc)) ||
            (! AUTH_MARSHALL(h->cl_auth, xdrs)) ||
            (! (*xargs)(xdrs, argsp))) {
                return (RPC_CANTENCODEARGS);
diff -r c83701aec823 -r 87cf1d8e8dbd lib/libc/rpc/clnt_simple.c
--- a/lib/libc/rpc/clnt_simple.c        Thu Jul 06 03:06:45 2000 +0000
+++ b/lib/libc/rpc/clnt_simple.c        Thu Jul 06 03:10:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clnt_simple.c,v 1.20 2000/06/02 23:11:08 fvdl Exp $    */
+/*     $NetBSD: clnt_simple.c,v 1.21 2000/07/06 03:10:34 christos Exp $        */
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -86,7 +86,7 @@
 static void
 rpc_call_destroy(void *vp)
 {
-       register struct rpc_call_private *rcp = (struct rpc_call_private *)vp;
+       struct rpc_call_private *rcp = (struct rpc_call_private *)vp;
 
        if (rcp) {
                if (rcp->client)
@@ -138,9 +138,9 @@
 #else
        rcp = rpc_call_private_main;
 #endif
-       if (rcp == (struct rpc_call_private *)NULL) {
-               rcp = (struct rpc_call_private *)malloc(sizeof (*rcp));
-               if (rcp == (struct rpc_call_private *)NULL) {
+       if (rcp == NULL) {
+               rcp = malloc(sizeof (*rcp));
+               if (rcp == NULL) {
                        rpc_createerr.cf_stat = RPC_SYSTEMERROR;
                        rpc_createerr.cf_error.re_errno = errno;
                        return (rpc_createerr.cf_stat);
@@ -169,7 +169,7 @@
                 */
                rcp->client = clnt_create(host, prognum, versnum, nettype);
                rcp->pid = getpid();
-               if (rcp->client == (CLIENT *)NULL) {
+               if (rcp->client == NULL) {
                        return (rpc_createerr.cf_stat);
                }
                /*
@@ -180,8 +180,8 @@
                timeout.tv_usec = 0;
                timeout.tv_sec = 5;
                (void) CLNT_CONTROL(rcp->client,
-                               CLSET_RETRY_TIMEOUT, (char *) &timeout);
-               if (CLNT_CONTROL(rcp->client, CLGET_FD, (char *)&fd))
+                               CLSET_RETRY_TIMEOUT, (char *)(void *)&timeout);
+               if (CLNT_CONTROL(rcp->client, CLGET_FD, (char *)(void *)&fd))
                        fcntl(fd, F_SETFD, 1);  /* make it "close on exec" */
                rcp->prognum = prognum;
                rcp->versnum = versnum;
@@ -196,8 +196,9 @@
        } /* else reuse old client */
        tottimeout.tv_sec = 25;
        tottimeout.tv_usec = 0;
-       clnt_stat = CLNT_CALL(rcp->client, procnum, inproc, (char *) in, outproc,
-                               out, tottimeout);
+       /*LINTED const castaway*/
+       clnt_stat = CLNT_CALL(rcp->client, procnum, inproc, (char *) in,
+           outproc, out, tottimeout);
        /*
         * if call failed, empty cache
         */
diff -r c83701aec823 -r 87cf1d8e8dbd lib/libc/rpc/clnt_vc.c
--- a/lib/libc/rpc/clnt_vc.c    Thu Jul 06 03:06:45 2000 +0000
+++ b/lib/libc/rpc/clnt_vc.c    Thu Jul 06 03:10:34 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clnt_vc.c,v 1.2 2000/06/04 03:55:20 thorpej Exp $      */
+/*     $NetBSD: clnt_vc.c,v 1.3 2000/07/06 03:10:34 christos Exp $     */
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -36,7 +36,7 @@
 static char *sccsid = "@(#)clnt_tcp.c  2.2 88/08/01 4.0 RPCSRC";
 static char sccsid[] = "@(#)clnt_vc.c 1.19 89/03/16 Copyr 1988 Sun Micro";
 #else
-__RCSID("$NetBSD: clnt_vc.c,v 1.2 2000/06/04 03:55:20 thorpej Exp $");
+__RCSID("$NetBSD: clnt_vc.c,v 1.3 2000/07/06 03:10:34 christos Exp $");
 #endif
 #endif
  
@@ -178,14 +178,14 @@
        if (disrupt == 0)
                disrupt = (u_int32_t)(long)raddr;
 
-       h  = (CLIENT *)mem_alloc(sizeof(*h));
+       h  = mem_alloc(sizeof(*h));
        if (h == NULL) {
                warnx("clnt_vc_create: out of memory");
                rpc_createerr.cf_stat = RPC_SYSTEMERROR;
                rpc_createerr.cf_error.re_errno = errno;
                goto fooy;
        }
-       ct = (struct ct_data *)mem_alloc(sizeof(*ct));
+       ct = mem_alloc(sizeof(*ct));
        if (ct == NULL) {
                warnx("clnt_vc_create: out of memory");
                rpc_createerr.cf_stat = RPC_SYSTEMERROR;
@@ -233,7 +233,7 @@
         * XXX - fvdl connecting while holding a mutex?
         */
        slen = sizeof ss;
-       if (getpeername(fd, (struct sockaddr *)&ss, &slen) < 0) {
+       if (getpeername(fd, (struct sockaddr *)(void *)&ss, &slen) < 0) {
                if (errno != ENOTCONN) {
                        rpc_createerr.cf_stat = RPC_SYSTEMERROR;
                        rpc_createerr.cf_error.re_errno = errno;
@@ -270,9 +270,8 @@
        /*
         * Initialize call message
         */
-       (void)gettimeofday(&now, (struct timezone *)0);
-       call_msg.rm_xid =
-           (u_int32_t)((++disrupt) ^ getpid() ^ now.tv_sec ^ now.tv_usec);
+       (void)gettimeofday(&now, NULL);
+       call_msg.rm_xid = ((u_int32_t)++disrupt) ^ __RPC_GETXID(&now);
        call_msg.rm_direction = CALL;
        call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
        call_msg.rm_call.cb_prog = (u_int32_t)prog;
@@ -313,7 +312,7 @@
                mem_free(ct, sizeof(struct ct_data));
        if (h)
                mem_free(h, sizeof(CLIENT));
-       return ((CLIENT *)NULL);
+       return (NULL);
 }
 
 static enum clnt_stat
@@ -359,7 +358,7 @@
        }
 
        shipnow =
-           (xdr_results == (xdrproc_t)0 && timeout.tv_sec == 0
+           (xdr_results == NULL && timeout.tv_sec == 0
            && timeout.tv_usec == 0) ? FALSE : TRUE;
 
 call_again:
@@ -367,7 +366,7 @@
        ct->ct_error.re_status = RPC_SUCCESS;
        x_id = ntohl(--(*msg_x_id));



Home | Main Index | Thread Index | Old Index