diff options
author | Varun Shastry <vshastry@redhat.com> | 2012-09-17 15:44:16 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-09-17 21:19:37 -0700 |
commit | f7342ad3a91ac5140e9c24e20007519847f4f4ec (patch) | |
tree | b611dbab90e234c95bd525743e6fc4fa6ed0a64e /xlators | |
parent | 4d0895c966f38355950d22ce378579fd35b7c9b2 (diff) |
Clean up of typepunning errors ( Strict aliasing warnings )
Change-Id: I48733967facc526fb523a8dc9bd068f8c5cc5971
BUG: 764282
Signed-off-by: Varun Shastry <vshastry@redhat.com>
Reviewed-on: http://review.gluster.org/3950
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/cluster/afr/src/afr-common.c | 4 | ||||
-rw-r--r-- | xlators/nfs/server/src/nlm4.c | 35 |
2 files changed, 18 insertions, 21 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index ddcd0bca37a..4130adc6f17 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -570,6 +570,7 @@ afr_hash_child (int32_t *success_children, int32_t child_count, unsigned int hmode, uuid_t gfid) { uuid_t gfid_copy = {0,}; + pid_t pid; if (!hmode) { return -1; @@ -588,7 +589,8 @@ afr_hash_child (int32_t *success_children, int32_t child_count, * perfection here. All we need is a low probability that * multiple clients won't converge on the same subvolume. */ - *((pid_t *)gfid_copy) = getpid(); + pid = getpid(); + memcpy (gfid_copy, &pid, sizeof(pid)); } return SuperFastHash((char *)gfid_copy, diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c index 99541fd4bde..05de66d5633 100644 --- a/xlators/nfs/server/src/nlm4.c +++ b/xlators/nfs/server/src/nlm4.c @@ -909,8 +909,7 @@ void * nlm4_establish_callback (void *csarg) { nfs3_call_state_t *cs = NULL; - struct sockaddr_storage sa; - struct sockaddr *sockaddr = NULL; + union gf_sock_union sock_union; dict_t *options = NULL; char peerip[INET6_ADDRSTRLEN+1], *portstr = NULL; rpc_clnt_t *rpc_clnt = NULL; @@ -923,9 +922,9 @@ nlm4_establish_callback (void *csarg) caller_name = cs->args.nlm4_lockargs.alock.caller_name; - rpc_transport_get_peeraddr (cs->trans, NULL, 0, &sa, sizeof (sa)); - sockaddr = (struct sockaddr*) &sa; - switch (sockaddr->sa_family) { + rpc_transport_get_peeraddr (cs->trans, NULL, 0, &sock_union.storage, + sizeof (sock_union.storage)); + switch (sock_union.sa.sa_family) { case AF_INET6: /* can not come here as NLM listens on IPv4 */ gf_log (GF_NLM, GF_LOG_ERROR, "NLM is not supported on IPv6 in" @@ -938,9 +937,8 @@ nlm4_establish_callback (void *csarg) break; */ case AF_INET: - inet_ntop (AF_INET, - &((struct sockaddr_in *)sockaddr)->sin_addr, - peerip, INET6_ADDRSTRLEN+1); + inet_ntop (AF_INET, &sock_union.sin.sin_addr, peerip, + INET6_ADDRSTRLEN+1); break; default: break; @@ -948,7 +946,7 @@ nlm4_establish_callback (void *csarg) } /* looks like libc rpc supports only ipv4 */ - port = pmap_getport ((struct sockaddr_in*)sockaddr, NLM_PROGRAM, + port = pmap_getport (&sock_union.sin, NLM_PROGRAM, NLM_V4, IPPROTO_TCP); if (port == 0) { @@ -1031,22 +1029,19 @@ nlm4svc_send_granted (nfs3_call_state_t *cs) struct iobref *iobref = NULL; char peerip[INET6_ADDRSTRLEN+1]; pthread_t thr; - struct sockaddr_storage sa; - struct sockaddr *sockaddr = NULL; + union gf_sock_union sock_union; - rpc_transport_get_peeraddr (cs->trans, NULL, 0, &sa, sizeof (sa)); - sockaddr = (struct sockaddr*) &sa; - switch (sockaddr->sa_family) { + rpc_transport_get_peeraddr (cs->trans, NULL, 0, &sock_union.storage, + sizeof (sock_union.storage)); + switch (sock_union.sa.sa_family) { case AF_INET6: - inet_ntop (AF_INET6, - &((struct sockaddr_in6 *)sockaddr)->sin6_addr, - peerip, INET6_ADDRSTRLEN+1); + inet_ntop (AF_INET6, &sock_union.sin6.sin6_addr, peerip, + INET6_ADDRSTRLEN+1); break; case AF_INET: - inet_ntop (AF_INET, - &((struct sockaddr_in *)sockaddr)->sin_addr, - peerip, INET6_ADDRSTRLEN+1); + inet_ntop (AF_INET, &sock_union.sin.sin_addr, peerip, + INET6_ADDRSTRLEN+1); default: break; /* FIXME: handle the error */ |