]> granicus.if.org Git - libtirpc/commitdiff
Cleaned up some "break strict-aliasing rules" warnings
authorSteve Dickson <steved@redhat.com>
Thu, 9 Jul 2009 18:55:13 +0000 (14:55 -0400)
committerSteve Dickson <steved@redhat.com>
Thu, 9 Jul 2009 18:55:13 +0000 (14:55 -0400)
as well as some other warnings.

Signed-off-by: Steve Dickson <steved@redhat.com>
src/bindresvport.c
src/clnt_bcast.c
src/clnt_dg.c
src/mt_misc.c
src/rpc_generic.c

index 730dc6b6ae615a0c02d111255730ef98f1b43067..6ce3e8179f1f5b408856bd36162283c65676f2ec 100644 (file)
@@ -88,11 +88,10 @@ bindresvport_sa(sd, sa)
                 salen = sizeof(myaddr);
                 sa = (struct sockaddr *)&myaddr;
 
-                if (getsockname(sd, sa, &salen) == -1)
+                if (getsockname(sd, (struct sockaddr *)&myaddr, &salen) == -1)
                         return -1;      /* errno is correctly set */
 
-                af = sa->sa_family;
-                memset(sa, 0, salen);
+                af = myaddr.ss_family;
         } else
                 af = sa->sa_family;
 
index fef7a4b6167a4d963498d607afcefa60fdeb80db..140407b11145eb205fab4542ea96a996270f02f7 100644 (file)
@@ -586,13 +586,12 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
                                        struct netbuf *np;
 #ifdef PORTMAP
                                        struct netbuf taddr;
-                                       struct sockaddr_in *sin;
+                                       struct sockaddr_in sin;
 
                                        if (pmap_flag && pmap_reply_flag) {
-                                               sin = (struct sockaddr_in *)
-                                                   (void *)&fdlist[i].raddr;
-                                               sin->sin_port =
-                                                   htons((u_short)port);
+                                               memcpy(&sin, &fdlist[i].raddr, sizeof(sin)); 
+                                               sin.sin_port = htons((u_short)port);
+                                               memcpy(&fdlist[i].raddr, &sin, sizeof(sin)); 
                                                taddr.len = taddr.maxlen = 
                                                    sizeof(fdlist[i].raddr);
                                                taddr.buf = &fdlist[i].raddr;
index 2f870b1ce7c192d1df4e0cb64f154e24de6f8f66..79fed5d8caebecc3c2ebc26e33d1434564ff612f 100644 (file)
@@ -312,7 +312,7 @@ clnt_dg_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout)
        socklen_t inlen, salen;
        ssize_t recvlen = 0;
        int rpc_lock_value;
-       u_int32_t xid;
+       u_int32_t xid, inval, outval;
 
        outlen = 0;
        sigfillset(&newmask);
@@ -475,15 +475,23 @@ get_reply:
                cu->cu_error.re_status = RPC_CANTRECV;
                goto out;
        }
-       if (recvlen >= sizeof(u_int32_t) &&
-           (cu->cu_async == TRUE ||
-           *((u_int32_t *)(void *)(cu->cu_inbuf)) ==
-           *((u_int32_t *)(void *)(cu->cu_outbuf))))
-                inlen = (socklen_t)recvlen;
-        else {
-                total_time -= tv;
-                goto send_again;
-        }
+
+       if (recvlen < sizeof(u_int32_t)) {
+               total_time -= tv;
+               goto send_again;
+       }
+
+       if (cu->cu_async == TRUE)
+               inlen = (socklen_t)recvlen;
+       else {
+               memcpy(&inval, cu->cu_inbuf, sizeof(u_int32_t));
+               memcpy(&outval, cu->cu_outbuf, sizeof(u_int32_t));
+               if (inval != outval) {
+                       total_time -= tv;
+                       goto send_again;
+               }
+               inlen = (socklen_t)recvlen;
+       }
 
        /*
         * now decode and validate the response
index 94bb645feec1e40b4ea9943aedaee6b0507ad767..4cba143f38db275266e7c4aac4988e42c5fe033d 100644 (file)
@@ -120,7 +120,7 @@ __rpc_createerr()
        return (rce_addr);
 }
 
-void __attribute ((descructor)) tsd_key_delete(void)
+void tsd_key_delete(void)
 {
        if (clnt_broadcast_key != -1)
                thr_keydelete(clnt_broadcast_key);
index 8219483b81fa175e9242d8febbe6e22eecce39fe..541275cad501b0deb0d37249e49fb74bb6b52812 100644 (file)
@@ -812,6 +812,11 @@ int
 __rpc_sockisbound(int fd)
 {
        struct sockaddr_storage ss;
+       union {
+               struct sockaddr_in  sin;
+               struct sockaddr_in6 sin6;
+               struct sockaddr_un  usin;
+       } u_addr;
        socklen_t slen;
 
        slen = sizeof (struct sockaddr_storage);
@@ -820,17 +825,17 @@ __rpc_sockisbound(int fd)
 
        switch (ss.ss_family) {
                case AF_INET:
-                       return (((struct sockaddr_in *)
-                           (void *)&ss)->sin_port != 0);
+                       memcpy(&u_addr.sin, &ss, sizeof(u_addr.sin)); 
+                       return (u_addr.sin.sin_port != 0);
 #ifdef INET6
                case AF_INET6:
-                       return (((struct sockaddr_in6 *)
-                           (void *)&ss)->sin6_port != 0);
+                       memcpy(&u_addr.sin6, &ss, sizeof(u_addr.sin6)); 
+                       return (u_addr.sin6.sin6_port != 0);
 #endif
                case AF_LOCAL:
                        /* XXX check this */
-                       return (((struct sockaddr_un *)
-                           (void *)&ss)->sun_path[0] != '\0');
+                       memcpy(&u_addr.usin, &ss, sizeof(u_addr.usin)); 
+                       return (u_addr.usin.sun_path[0] != 0);
                default:
                        break;
        }