if (s_in->sin_family != AF_INET) {
#ifdef DEBUG
bb_error_msg("rresolve: unsupported address family %d!",
- s_in->sin_family);
+ s_in->sin_family);
#endif
errno = EAFNOSUPPORT;
return NULL;
int FAST_FUNC INET6_resolve(const char *name, struct sockaddr_in6 *sin6)
{
- struct addrinfo req, *ai;
+ struct addrinfo req, *ai = NULL;
int s;
- memset(&req, '\0', sizeof req);
+ memset(&req, 0, sizeof(req));
req.ai_family = AF_INET6;
s = getaddrinfo(name, NULL, &req, &ai);
- if (s) {
+ if (s != 0) {
bb_error_msg("getaddrinfo: %s: %d", name, s);
return -1;
}
- memcpy(sin6, ai->ai_addr, sizeof(struct sockaddr_in6));
- freeaddrinfo(ai);
+ memcpy(sin6, ai->ai_addr, sizeof(*sin6));
+ if (ai)
+ freeaddrinfo(ai);
return 0;
}
if (sin6->sin6_family != AF_INET6) {
#ifdef DEBUG
bb_error_msg("rresolve: unsupported address family %d!",
- sin6->sin6_family);
+ sin6->sin6_family);
#endif
errno = EAFNOSUPPORT;
return NULL;
return xstrdup("*");
}
- s = getnameinfo((struct sockaddr *) sin6, sizeof(struct sockaddr_in6),
- name, sizeof(name), NULL, 0, 0);
- if (s) {
+ s = getnameinfo((struct sockaddr *) sin6, sizeof(*sin6),
+ name, sizeof(name),
+ /*serv,servlen:*/ NULL, 0,
+ 0);
+ if (s != 0) {
bb_error_msg("getnameinfo failed");
return NULL;
}