On Wed, Dec 27 2017, Mark Kettenis <mark.kette...@xs4all.nl> wrote: >> Date: Wed, 27 Dec 2017 08:52:28 -0600 >> From: Scott Cheloha <scottchel...@gmail.com> >> >> 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? > > I really don't get the cruscade agains gettimeofday(). Despite what > POSIX may say, it is not going away. And what you're proposing isn't > really an optimization. As far as I'm concerned this is just > (unwanted) churn.
I don't think there's a crusade here; time(3) gives us shorter code in auth_unix.c, and still uses gettimeofday(2) under the hood. The two other diffs are dead code removal. I think it's worth it, ok jca@ >> 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 = >> >> > -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE