summaryrefslogtreecommitdiff
path: root/fake-getaddrinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'fake-getaddrinfo.c')
-rw-r--r--fake-getaddrinfo.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/fake-getaddrinfo.c b/fake-getaddrinfo.c
index b918798c4..456c41e58 100644
--- a/fake-getaddrinfo.c
+++ b/fake-getaddrinfo.c
@@ -41,7 +41,7 @@ struct addrinfo *ai;
41 do { 41 do {
42 next = ai->ai_next; 42 next = ai->ai_next;
43 free(ai); 43 free(ai);
44 } while (ai = next); 44 } while (NULL != (ai = next));
45} 45}
46#endif /* !HAVE_FREEADDRINFO */ 46#endif /* !HAVE_FREEADDRINFO */
47 47
@@ -53,8 +53,8 @@ u_long addr;
53{ 53{
54 struct addrinfo *ai; 54 struct addrinfo *ai;
55 55
56 if (ai = (struct addrinfo *)malloc(sizeof(struct addrinfo) + 56 if (NULL != (ai = (struct addrinfo *)malloc(sizeof(struct addrinfo) +
57 sizeof(struct sockaddr_in))) { 57 sizeof(struct sockaddr_in)))) {
58 memset(ai, 0, sizeof(struct addrinfo) + sizeof(struct sockaddr_in)); 58 memset(ai, 0, sizeof(struct addrinfo) + sizeof(struct sockaddr_in));
59 ai->ai_addr = (struct sockaddr *)(ai + 1); 59 ai->ai_addr = (struct sockaddr *)(ai + 1);
60 /* XXX -- ssh doesn't use sa_len */ 60 /* XXX -- ssh doesn't use sa_len */
@@ -83,25 +83,25 @@ struct addrinfo **res;
83 else 83 else
84 port = 0; 84 port = 0;
85 if (hints && hints->ai_flags & AI_PASSIVE) 85 if (hints && hints->ai_flags & AI_PASSIVE)
86 if (*res = malloc_ai(port, htonl(0x00000000))) 86 if (NULL != (*res = malloc_ai(port, htonl(0x00000000))))
87 return 0; 87 return 0;
88 else 88 else
89 return EAI_MEMORY; 89 return EAI_MEMORY;
90 if (!hostname) 90 if (!hostname)
91 if (*res = malloc_ai(port, htonl(0x7f000001))) 91 if (NULL != (*res = malloc_ai(port, htonl(0x7f000001))))
92 return 0; 92 return 0;
93 else 93 else
94 return EAI_MEMORY; 94 return EAI_MEMORY;
95 if (inet_addr(hostname) != -1) 95 if (inet_addr(hostname) != -1)
96 if (*res = malloc_ai(port, inet_addr(hostname))) 96 if (NULL != (*res = malloc_ai(port, inet_addr(hostname))))
97 return 0; 97 return 0;
98 else 98 else
99 return EAI_MEMORY; 99 return EAI_MEMORY;
100 if ((hp = gethostbyname(hostname)) && 100 if ((hp = gethostbyname(hostname)) &&
101 hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { 101 hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
102 for (i = 0; hp->h_addr_list[i]; i++) 102 for (i = 0; hp->h_addr_list[i]; i++)
103 if (cur = malloc_ai(port, 103 if (NULL != (cur = malloc_ai(port,
104 ((struct in_addr *)hp->h_addr_list[i])->s_addr)) { 104 ((struct in_addr *)hp->h_addr_list[i])->s_addr))) {
105 if (prev) 105 if (prev)
106 prev->ai_next = cur; 106 prev->ai_next = cur;
107 else 107 else