summaryrefslogtreecommitdiffstats
path: root/Source/CTest/Curl/hostip4.c
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2004-10-11 15:44:08 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2004-10-11 15:44:08 (GMT)
commite0778d48bd98969f6610333e6ceac21c9a48791d (patch)
treebe9c6ea08d5622131b2d149b5593b5b907a55784 /Source/CTest/Curl/hostip4.c
parent766c093d69d24200e54d4c7eb22ebeae221ece06 (diff)
downloadCMake-e0778d48bd98969f6610333e6ceac21c9a48791d.zip
CMake-e0778d48bd98969f6610333e6ceac21c9a48791d.tar.gz
CMake-e0778d48bd98969f6610333e6ceac21c9a48791d.tar.bz2
COMP: Remove alignment warning
Diffstat (limited to 'Source/CTest/Curl/hostip4.c')
-rw-r--r--Source/CTest/Curl/hostip4.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/Source/CTest/Curl/hostip4.c b/Source/CTest/Curl/hostip4.c
index f46e2c3..1b4c3c1 100644
--- a/Source/CTest/Curl/hostip4.c
+++ b/Source/CTest/Curl/hostip4.c
@@ -403,15 +403,22 @@ Curl_addrinfo *Curl_he2ai(struct hostent *he, int port)
Curl_addrinfo *ai;
Curl_addrinfo *prevai = NULL;
Curl_addrinfo *firstai = NULL;
- struct sockaddr_in *addr;
int i;
- struct in_addr *curr;
+
+ union {
+ struct in_addr *addr;
+ char* list;
+ } curr;
+ union {
+ struct sockaddr_in* addr_in;
+ struct sockaddr* addr;
+ } address;
if(!he)
/* no input == no output! */
return NULL;
- for(i=0; (curr = (struct in_addr *)he->h_addr_list[i]); i++) {
+ for(i=0; (curr.list = he->h_addr_list[i]); i++) {
ai = calloc(1, sizeof(Curl_addrinfo) + sizeof(struct sockaddr_in));
@@ -431,15 +438,15 @@ Curl_addrinfo *Curl_he2ai(struct hostent *he, int port)
ai->ai_addrlen = sizeof(struct sockaddr_in);
/* make the ai_addr point to the address immediately following this struct
and use that area to store the address */
- ai->ai_addr = (struct sockaddr *) ((char*)ai + sizeof(Curl_addrinfo));
+ ai->ai_addr = (struct sockaddr *) (ai + 1);
/* leave the rest of the struct filled with zero */
- addr = (struct sockaddr_in *)ai->ai_addr; /* storage area for this info */
+ address.addr = ai->ai_addr; /* storage area for this info */
- memcpy((char *)&(addr->sin_addr), curr, sizeof(struct in_addr));
- addr->sin_family = he->h_addrtype;
- addr->sin_port = htons((unsigned short)port);
+ memcpy((char *)&(address.addr_in->sin_addr), curr.addr, sizeof(struct in_addr));
+ address.addr_in->sin_family = he->h_addrtype;
+ address.addr_in->sin_port = htons((unsigned short)port);
prevai = ai;
}