aboutsummaryrefslogtreecommitdiff
path: root/inet
diff options
context:
space:
mode:
Diffstat (limited to 'inet')
-rw-r--r--inet/getnameinfo.c18
-rw-r--r--inet/netinet/in.h54
-rw-r--r--inet/rcmd.c2
-rw-r--r--inet/ruserpass.c2
4 files changed, 46 insertions, 30 deletions
diff --git a/inet/getnameinfo.c b/inet/getnameinfo.c
index 25a8af7a6c..435ba76ee5 100644
--- a/inet/getnameinfo.c
+++ b/inet/getnameinfo.c
@@ -211,7 +211,7 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
{
if (sa->sa_family == AF_INET6)
{
- while (__gethostbyaddr_r ((void *) &(((struct sockaddr_in6 *) sa)->sin6_addr),
+ while (__gethostbyaddr_r ((const void *) &(((const struct sockaddr_in6 *) sa)->sin6_addr),
sizeof(struct in6_addr),
AF_INET6, &th, tmpbuf, tmpbuflen,
&h, &herrno))
@@ -238,7 +238,7 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
}
else
{
- while (__gethostbyaddr_r ((void *) &(((struct sockaddr_in *)sa)->sin_addr),
+ while (__gethostbyaddr_r ((const void *) &(((const struct sockaddr_in *)sa)->sin_addr),
sizeof(struct in_addr), AF_INET,
&th, tmpbuf, tmpbuflen,
&h, &herrno))
@@ -290,11 +290,13 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
const char *c;
if (sa->sa_family == AF_INET6)
{
- struct sockaddr_in6 *sin6p = (struct sockaddr_in6 *) sa;
+ const struct sockaddr_in6 *sin6p;
uint32_t scopeid;
+ sin6p = (const struct sockaddr_in6 *) sa;
+
c = inet_ntop (AF_INET6,
- (void *) &sin6p->sin6_addr, host, hostlen);
+ (const void *) &sin6p->sin6_addr, host, hostlen);
scopeid = sin6p->sin6_scope_id;
if (scopeid != 0)
{
@@ -336,7 +338,7 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
}
else
c = inet_ntop (AF_INET,
- (void *) &(((struct sockaddr_in *) sa)->sin_addr),
+ (const void *) &(((const struct sockaddr_in *) sa)->sin_addr),
host, hostlen);
if (c == NULL)
{
@@ -381,7 +383,7 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
if (!(flags & NI_NUMERICSERV))
{
struct servent *s, ts;
- while (__getservbyport_r (((struct sockaddr_in *) sa)->sin_port,
+ while (__getservbyport_r (((const struct sockaddr_in *) sa)->sin_port,
((flags & NI_DGRAM) ? "udp" : "tcp"),
&ts, tmpbuf, tmpbuflen, &s))
{
@@ -410,11 +412,11 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
}
}
__snprintf (serv, servlen, "%d",
- ntohs (((struct sockaddr_in *) sa)->sin_port));
+ ntohs (((const struct sockaddr_in *) sa)->sin_port));
break;
case AF_LOCAL:
- strncpy (serv, ((struct sockaddr_un *) sa)->sun_path, servlen);
+ strncpy (serv, ((const struct sockaddr_un *) sa)->sun_path, servlen);
break;
}
diff --git a/inet/netinet/in.h b/inet/netinet/in.h
index 1857c199cb..4bceaef869 100644
--- a/inet/netinet/in.h
+++ b/inet/netinet/in.h
@@ -268,34 +268,43 @@ extern uint16_t htons (uint16_t __hostshort)
#endif
#define IN6_IS_ADDR_UNSPECIFIED(a) \
- (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
- ((uint32_t *) (a))[2] == 0 && ((uint32_t *) (a))[3] == 0)
+ (((__const uint32_t *) (a))[0] == 0 \
+ && ((__const uint32_t *) (a))[1] == 0 \
+ && ((__const uint32_t *) (a))[2] == 0 \
+ && ((__const uint32_t *) (a))[3] == 0)
#define IN6_IS_ADDR_LOOPBACK(a) \
- (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
- ((uint32_t *) (a))[2] == 0 && ((uint32_t *) (a))[3] == htonl (1))
+ (((__const uint32_t *) (a))[0] == 0 \
+ && ((__const uint32_t *) (a))[1] == 0 \
+ && ((__const uint32_t *) (a))[2] == 0 \
+ && ((__const uint32_t *) (a))[3] == htonl (1))
-#define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff)
+#define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff)
#define IN6_IS_ADDR_LINKLOCAL(a) \
- ((((uint32_t *) (a))[0] & htonl (0xffc00000)) == htonl (0xfe800000))
+ ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \
+ == htonl (0xfe800000))
#define IN6_IS_ADDR_SITELOCAL(a) \
- ((((uint32_t *) (a))[0] & htonl (0xffc00000)) == htonl (0xfec00000))
+ ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \
+ == htonl (0xfec00000))
#define IN6_IS_ADDR_V4MAPPED(a) \
- ((((uint32_t *) (a))[0] == 0) && (((uint32_t *) (a))[1] == 0) && \
- (((uint32_t *) (a))[2] == htonl (0xffff)))
+ ((((__const uint32_t *) (a))[0] == 0) \
+ && (((__const uint32_t *) (a))[1] == 0) \
+ && (((__const uint32_t *) (a))[2] == htonl (0xffff)))
#define IN6_IS_ADDR_V4COMPAT(a) \
- ((((uint32_t *) (a))[0] == 0) && (((uint32_t *) (a))[1] == 0) && \
- (((uint32_t *) (a))[2] == 0) && (ntohl (((uint32_t *) (a))[3]) > 1))
+ ((((__const uint32_t *) (a))[0] == 0) \
+ && (((__const uint32_t *) (a))[1] == 0) \
+ && (((__const uint32_t *) (a))[2] == 0) \
+ && (ntohl (((__const uint32_t *) (a))[3]) > 1))
#define IN6_ARE_ADDR_EQUAL(a,b) \
- ((((uint32_t *) (a))[0] == ((uint32_t *) (b))[0]) && \
- (((uint32_t *) (a))[1] == ((uint32_t *) (b))[1]) && \
- (((uint32_t *) (a))[2] == ((uint32_t *) (b))[2]) && \
- (((uint32_t *) (a))[3] == ((uint32_t *) (b))[3]))
+ ((((__const uint32_t *) (a))[0] == ((__const uint32_t *) (b))[0]) \
+ && (((__const uint32_t *) (a))[1] == ((__const uint32_t *) (b))[1]) \
+ && (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2]) \
+ && (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3]))
/* Bind socket to a privileged IP port. */
extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __THROW;
@@ -306,19 +315,24 @@ extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
#define IN6_IS_ADDR_MC_NODELOCAL(a) \
- (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x1))
+ (IN6_IS_ADDR_MULTICAST(a) \
+ && ((((__const uint8_t *) (a))[1] & 0xf) == 0x1))
#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
- (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x2))
+ (IN6_IS_ADDR_MULTICAST(a) \
+ && ((((__const uint8_t *) (a))[1] & 0xf) == 0x2))
#define IN6_IS_ADDR_MC_SITELOCAL(a) \
- (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x5))
+ (IN6_IS_ADDR_MULTICAST(a) \
+ && ((((__const uint8_t *) (a))[1] & 0xf) == 0x5))
#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
- (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x8))
+ (IN6_IS_ADDR_MULTICAST(a) \
+ && ((((__const uint8_t *) (a))[1] & 0xf) == 0x8))
#define IN6_IS_ADDR_MC_GLOBAL(a) \
- (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0xe))
+ (IN6_IS_ADDR_MULTICAST(a) \
+ && ((((__const uint8_t *) (a))[1] & 0xf) == 0xe))
/* IPv6 packet information. */
struct in6_pktinfo
diff --git a/inet/rcmd.c b/inet/rcmd.c
index 1ddf4729da..a85cce6be0 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -215,7 +215,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
goto bad;
listen(s2, 1);
(void)__snprintf(num, sizeof(num), "%d", lport);
- if (__write(s, num, strlen(num)+1) != strlen(num)+1) {
+ if (__write(s, num, strlen(num)+1) != (ssize_t)strlen(num)+1) {
(void)fprintf(stderr,
_("rcmd: write (setting up stderr): %m\n"));
(void)__close(s2);
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index 3b66c3040e..d610f4240d 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -317,7 +317,7 @@ token()
*cp = 0;
if (tokval[0] == 0)
return (0);
- for (i = 0; i < sizeof (toktab) / sizeof (toktab[0]); ++i)
+ for (i = 0; i < (int) (sizeof (toktab) / sizeof (toktab[0])); ++i)
if (!strcmp(&tokstr[toktab[i].tokstr_off], tokval))
return toktab[i].tval;
return (ID);