The timevals in clnt_tcp.c and clnt_udp.c are assigned and never used.

The timevals in auth_unix.c are only used for the .tv_sec field, so
we can just initialize .aup_time with time(3).

ok?

--
Scott Cheloha

Index: lib/libc/rpc/auth_unix.c
===================================================================
RCS file: /cvs/src/lib/libc/rpc/auth_unix.c,v
retrieving revision 1.26
diff -u -p -r1.26 auth_unix.c
--- lib/libc/rpc/auth_unix.c    1 Nov 2015 03:45:29 -0000       1.26
+++ lib/libc/rpc/auth_unix.c    27 Dec 2017 14:47:50 -0000
@@ -45,6 +45,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#include <time.h>
 
 #include <rpc/types.h>
 #include <rpc/xdr.h>
@@ -93,7 +94,6 @@ authunix_create(char *machname, int uid,
 {
        struct authunix_parms aup;
        char mymem[MAX_AUTH_BYTES];
-       struct timeval now;
        XDR xdrs;
        AUTH *auth;
        struct audata *au;
@@ -121,8 +121,7 @@ authunix_create(char *machname, int uid,
        /*
         * fill in param struct from the given params
         */
-       (void)gettimeofday(&now,  NULL);
-       aup.aup_time = now.tv_sec;
+       aup.aup_time = time(NULL);
        aup.aup_machname = machname;
        aup.aup_uid = uid;
        aup.aup_gid = gid;
@@ -254,7 +253,6 @@ authunix_refresh(AUTH *auth)
 {
        struct audata *au = AUTH_PRIVATE(auth);
        struct authunix_parms aup;
-       struct timeval now;
        XDR xdrs;
        int stat;
 
@@ -274,8 +272,7 @@ authunix_refresh(AUTH *auth)
                goto done;
 
        /* update the time and serialize in place */
-       (void)gettimeofday(&now, NULL);
-       aup.aup_time = now.tv_sec;
+       aup.aup_time = time(NULL);
        xdrs.x_op = XDR_ENCODE;
        XDR_SETPOS(&xdrs, 0);
        stat = xdr_authunix_parms(&xdrs, &aup);
Index: lib/libc/rpc/clnt_tcp.c
===================================================================
RCS file: /cvs/src/lib/libc/rpc/clnt_tcp.c,v
retrieving revision 1.31
diff -u -p -r1.31 clnt_tcp.c
--- lib/libc/rpc/clnt_tcp.c     14 Dec 2017 18:56:22 -0000      1.31
+++ lib/libc/rpc/clnt_tcp.c     27 Dec 2017 14:47:50 -0000
@@ -114,7 +114,6 @@ clnttcp_create(struct sockaddr_in *raddr
 {
        CLIENT *h;
        struct ct_data *ct = NULL;
-       struct timeval now;
        struct rpc_msg call_msg;
 
        h  = (CLIENT *)mem_alloc(sizeof(*h));
@@ -174,7 +173,6 @@ clnttcp_create(struct sockaddr_in *raddr
        /*
         * Initialize call message
         */
-       (void)gettimeofday(&now, NULL);
        call_msg.rm_xid = arc4random();
        call_msg.rm_direction = CALL;
        call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
Index: lib/libc/rpc/clnt_udp.c
===================================================================
RCS file: /cvs/src/lib/libc/rpc/clnt_udp.c,v
retrieving revision 1.34
diff -u -p -r1.34 clnt_udp.c
--- lib/libc/rpc/clnt_udp.c     14 Dec 2017 18:56:22 -0000      1.34
+++ lib/libc/rpc/clnt_udp.c     27 Dec 2017 14:47:50 -0000
@@ -109,7 +109,6 @@ clntudp_bufcreate(struct sockaddr_in *ra
 {
        CLIENT *cl;
        struct cu_data *cu = NULL;
-       struct timeval now;
        struct rpc_msg call_msg;
 
        cl = (CLIENT *)mem_alloc(sizeof(CLIENT));
@@ -128,7 +127,6 @@ clntudp_bufcreate(struct sockaddr_in *ra
        }
        cu->cu_outbuf = &cu->cu_inbuf[recvsz];
 
-       (void)gettimeofday(&now, NULL);
        if (raddr->sin_port == 0) {
                u_short port;
                if ((port =

Reply via email to