Commit ea67ee2b authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(cast_to_sockaddr_in): New static inline function.

(isc_getipnum): Use it, to get rid of a warning.
(isc_gethostname): Ditto.
(isc_getportnum): Ditto.
(isc_getservice): Ditto.
parent c9db92fd
......@@ -89,6 +89,20 @@ char *inet_ntoa(ad)
#endif
/* cast a struct sockaddr to a struct sockaddr_in. On some systems,
this cast produces a warning:
isc_socket.c:225: warning: cast increases required alignment of target type
The cast should be safe, tough. This function removes the warning
in a safe manner. */
static inline struct sockaddr_in *
cast_to_sockaddr_in(struct sockaddr *in)
{
return (void*)in;
}
IscAddress *
isc_mkipaddress(struct sockaddr *addr)
......@@ -176,7 +190,7 @@ char *isc_getipnum(IscAddress *ia, char *buf, int len)
len = sizeof(hostname);
}
addr = (struct sockaddr_in *) &ia->ip.saddr;
addr = cast_to_sockaddr_in(&ia->ip.saddr);
strncpy(buf, inet_ntoa(addr->sin_addr), len-1);
buf[len-1] = '\0';
......@@ -203,7 +217,7 @@ char *isc_gethostname(IscAddress *ia, char *buf, int len)
len = sizeof(hostname)-1;
}
addr = (struct sockaddr_in *) &ia->ip.saddr;
addr = cast_to_sockaddr_in(&ia->ip.saddr);
hp = gethostbyaddr((char*)&addr->sin_addr, sizeof(struct in_addr), AF_INET);
if (!hp)
......@@ -222,7 +236,7 @@ int isc_getportnum(IscAddress *ia)
struct sockaddr_in *addr;
addr = (struct sockaddr_in *) &ia->ip.saddr;
addr = cast_to_sockaddr_in(&ia->ip.saddr);
return ntohs(addr->sin_port);
}
......@@ -243,7 +257,7 @@ char *isc_getservice(IscAddress *ia,
len = sizeof(servbuf)-1;
}
addr = (struct sockaddr_in *) &ia->ip.saddr;
addr = cast_to_sockaddr_in(&ia->ip.saddr);
switch (type)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment