aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Ellcey <sellcey@mips.com>2015-05-19 13:09:01 -0700
committerSteve Ellcey <sellcey@mips.com>2015-05-19 13:09:01 -0700
commiteb286115b170893563f502b9e3d28e169abd8dcc (patch)
tree8a92195c9ab2e306d0a2cb46bd4efd0e7628bc3d
parent265cbed8e73b23e3b38ada6cc42482c53a216224 (diff)
downloadglibc-eb286115b170893563f502b9e3d28e169abd8dcc.tar
glibc-eb286115b170893563f502b9e3d28e169abd8dcc.tar.gz
glibc-eb286115b170893563f502b9e3d28e169abd8dcc.tar.bz2
glibc-eb286115b170893563f502b9e3d28e169abd8dcc.zip
* inet/rcmd.c (rresvport_af): Change ss to anonymous union
in order to avoid strict alias warnings. (iruserok_af): Ditto for ra.
-rw-r--r--ChangeLog7
-rw-r--r--inet/rcmd.c42
2 files changed, 31 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 4268eb75ad..50803702b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-05-19 Paul Eggert <eggert@cs.ucla.edu>
+ Steve Ellcey <sellcey@imgtec.com>
+
+ * inet/rcmd.c (rresvport_af): Change ss to anonymous union
+ in order to avoid strict alias warnings.
+ (iruserok_af): Ditto for ra.
+
2015-05-19 James Lemke <jwlemke@codesourcery.com>
[BZ #17581]
diff --git a/inet/rcmd.c b/inet/rcmd.c
index acacaa0d8a..98b3735d1f 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -114,10 +114,10 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
struct addrinfo hints, *res, *ai;
union
{
- struct sockaddr sa;
- struct sockaddr_storage ss;
- struct sockaddr_in sin;
- struct sockaddr_in6 sin6;
+ struct sockaddr sa;
+ struct sockaddr_storage ss;
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
} from;
struct pollfd pfd[2];
int32_t oldmask;
@@ -374,7 +374,11 @@ rresvport_af(alport, family)
int *alport;
sa_family_t family;
{
- struct sockaddr_storage ss;
+ union {
+ struct sockaddr generic;
+ struct sockaddr_in in;
+ struct sockaddr_in6 in6;
+ } ss;
int s;
size_t len;
uint16_t *sport;
@@ -382,11 +386,11 @@ rresvport_af(alport, family)
switch(family){
case AF_INET:
len = sizeof(struct sockaddr_in);
- sport = &((struct sockaddr_in *)&ss)->sin_port;
+ sport = &ss.in.sin_port;
break;
case AF_INET6:
len = sizeof(struct sockaddr_in6);
- sport = &((struct sockaddr_in6 *)&ss)->sin6_port;
+ sport = &ss.in6.sin6_port;
break;
default:
__set_errno (EAFNOSUPPORT);
@@ -398,9 +402,9 @@ rresvport_af(alport, family)
memset (&ss, '\0', sizeof(ss));
#ifdef SALEN
- ss.__ss_len = len;
+ ss.generic.__ss_len = len;
#endif
- ss.ss_family = family;
+ ss.generic.sa_family = family;
/* Ignore invalid values. */
if (*alport < IPPORT_RESERVED / 2)
@@ -411,7 +415,7 @@ rresvport_af(alport, family)
int start = *alport;
do {
*sport = htons((uint16_t) *alport);
- if (__bind(s, (struct sockaddr *)&ss, len) >= 0)
+ if (__bind(s, &ss.generic, len) >= 0)
return s;
if (errno != EADDRINUSE) {
(void)__close(s);
@@ -604,27 +608,29 @@ iruserok_af (raddr, superuser, ruser, luser, af)
const char *ruser, *luser;
sa_family_t af;
{
- struct sockaddr_storage ra;
+ union {
+ struct sockaddr generic;
+ struct sockaddr_in in;
+ struct sockaddr_in6 in6;
+ } ra;
size_t ralen;
memset (&ra, '\0', sizeof(ra));
switch (af){
case AF_INET:
- ra.ss_family = AF_INET;
- memcpy (&(((struct sockaddr_in *)&ra)->sin_addr), raddr,
- sizeof(struct in_addr));
+ ra.in.sin_family = AF_INET;
+ memcpy (&ra.in.sin_addr, raddr, sizeof(struct in_addr));
ralen = sizeof(struct sockaddr_in);
break;
case AF_INET6:
- ra.ss_family = AF_INET6;
- memcpy (&(((struct sockaddr_in6 *)&ra)->sin6_addr), raddr,
- sizeof(struct in6_addr));
+ ra.in6.sin6_family = AF_INET6;
+ memcpy (&ra.in6.sin6_addr, raddr, sizeof(struct in6_addr));
ralen = sizeof(struct sockaddr_in6);
break;
default:
return 0;
}
- return ruserok_sa ((struct sockaddr *)&ra, ralen, superuser, ruser, luser);
+ return ruserok_sa (&ra.generic, ralen, superuser, ruser, luser);
}
libc_hidden_def (iruserok_af)