summaryrefslogtreecommitdiff
path: root/libc/inet/getaddrinfo.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-12-08 23:53:21 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-12-08 23:53:21 +0000
commit73723d710b6f1868a20f8eb36383795524f516ad (patch)
tree645e7ad54fd4cefac5770a022f64eac52c3ae6c0 /libc/inet/getaddrinfo.c
parenta2465d1b4a41d0a25862a3e7e77bd88f60377e0b (diff)
getaddrinfo: remove superfluout indentation, fix incorrect one.
remove one superfluous statement.
Diffstat (limited to 'libc/inet/getaddrinfo.c')
-rw-r--r--libc/inet/getaddrinfo.c125
1 files changed, 64 insertions, 61 deletions
diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c
index f3440c8c3..b1aae1281 100644
--- a/libc/inet/getaddrinfo.c
+++ b/libc/inet/getaddrinfo.c
@@ -169,45 +169,49 @@ struct gaih {
static unsigned __check_pf(void)
{
unsigned seen = 0;
+
#if defined __UCLIBC_SUPPORT_AI_ADDRCONFIG__
- {
- /* Get the interface list via getifaddrs. */
- struct ifaddrs *ifa = NULL;
- struct ifaddrs *runp;
- if (getifaddrs(&ifa) != 0) {
- /* We cannot determine what interfaces are available.
- * Be optimistic. */
+
+ struct ifaddrs *ifa;
+ struct ifaddrs *runp;
+
+ /* Get the interface list via getifaddrs. */
+ if (getifaddrs(&ifa) != 0) {
+ /* We cannot determine what interfaces are available.
+ * Be optimistic. */
#if defined __UCLIBC_HAS_IPV4__
- seen |= SEEN_IPV4;
-#endif /* __UCLIBC_HAS_IPV4__ */
+ seen |= SEEN_IPV4;
+#endif
#if defined __UCLIBC_HAS_IPV6__
- seen |= SEEN_IPV6;
-#endif /* __UCLIBC_HAS_IPV6__ */
- return seen;
- }
+ seen |= SEEN_IPV6;
+#endif
+ return seen;
+ }
- for (runp = ifa; runp != NULL; runp = runp->ifa_next) {
+ for (runp = ifa; runp != NULL; runp = runp->ifa_next) {
#if defined __UCLIBC_HAS_IPV4__
- if (runp->ifa_addr->sa_family == PF_INET)
- seen |= SEEN_IPV4;
-#endif /* __UCLIBC_HAS_IPV4__ */
+ if (runp->ifa_addr->sa_family == PF_INET)
+ seen |= SEEN_IPV4;
+#endif
#if defined __UCLIBC_HAS_IPV6__
- if (runp->ifa_addr->sa_family == PF_INET6)
- seen |= SEEN_IPV6;
-#endif /* __UCLIBC_HAS_IPV6__ */
- }
- freeifaddrs(ifa);
+ if (runp->ifa_addr->sa_family == PF_INET6)
+ seen |= SEEN_IPV6;
+#endif
}
+ freeifaddrs(ifa);
+
#else
+
/* AI_ADDRCONFIG is disabled, assume both ipv4 and ipv6 available. */
#if defined __UCLIBC_HAS_IPV4__
seen |= SEEN_IPV4;
-#endif /* __UCLIBC_HAS_IPV4__ */
+#endif
#if defined __UCLIBC_HAS_IPV6__
seen |= SEEN_IPV6;
-#endif /* __UCLIBC_HAS_IPV6__ */
+#endif
#endif /* __UCLIBC_SUPPORT_AI_ADDRCONFIG__ */
+
return seen;
}
@@ -264,52 +268,51 @@ gaih_local(const char *name, const struct gaih_service *service,
strcmp(name, "unix") &&
strcmp(name, utsname.nodename))
return (GAIH_OKIFUNSPEC | -EAI_NONAME);
- }
+ }
- if (req->ai_protocol || req->ai_socktype) {
- const struct gaih_typeproto *tp = gaih_inet_typeproto + 1;
+ if (req->ai_protocol || req->ai_socktype) {
+ const struct gaih_typeproto *tp = gaih_inet_typeproto + 1;
- while (tp->name[0]
- && ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0
- || (req->ai_socktype != 0 && req->ai_socktype != tp->socktype)
- || (req->ai_protocol != 0 && !(tp->protoflag & GAI_PROTO_PROTOANY) && req->ai_protocol != tp->protocol))
- ) {
- ++tp;
- }
- if (! tp->name[0]) {
- if (req->ai_socktype)
- return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
- return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
- }
+ while (tp->name[0]
+ && ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0
+ || (req->ai_socktype != 0 && req->ai_socktype != tp->socktype)
+ || (req->ai_protocol != 0 && !(tp->protoflag & GAI_PROTO_PROTOANY) && req->ai_protocol != tp->protocol))
+ ) {
+ ++tp;
}
+ if (! tp->name[0]) {
+ if (req->ai_socktype)
+ return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
+ return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
+ }
+ }
- *pai = ai = malloc(sizeof(struct addrinfo) + sizeof(struct sockaddr_un)
- + ((req->ai_flags & AI_CANONNAME)
- ? (strlen(utsname.nodename) + 1) : 0));
- if (ai == NULL)
- return -EAI_MEMORY;
-
- ai->ai_next = NULL;
- ai->ai_flags = req->ai_flags;
- ai->ai_family = AF_LOCAL;
- ai->ai_socktype = req->ai_socktype ? req->ai_socktype : SOCK_STREAM;
- ai->ai_protocol = req->ai_protocol;
- ai->ai_addrlen = sizeof(struct sockaddr_un);
- ai->ai_addr = (void *)ai + sizeof(struct addrinfo);
+ *pai = ai = malloc(sizeof(struct addrinfo) + sizeof(struct sockaddr_un)
+ + ((req->ai_flags & AI_CANONNAME)
+ ? (strlen(utsname.nodename) + 1) : 0));
+ if (ai == NULL)
+ return -EAI_MEMORY;
+
+ ai->ai_next = NULL;
+ ai->ai_flags = req->ai_flags;
+ ai->ai_family = AF_LOCAL;
+ ai->ai_socktype = req->ai_socktype ? req->ai_socktype : SOCK_STREAM;
+ ai->ai_protocol = req->ai_protocol;
+ ai->ai_addrlen = sizeof(struct sockaddr_un);
+ ai->ai_addr = (void *)ai + sizeof(struct addrinfo);
#if SALEN
- ((struct sockaddr_un *)ai->ai_addr)->sun_len = sizeof(struct sockaddr_un);
+ ((struct sockaddr_un *)ai->ai_addr)->sun_len = sizeof(struct sockaddr_un);
#endif /* SALEN */
- ((struct sockaddr_un *)ai->ai_addr)->sun_family = AF_LOCAL;
- memset(((struct sockaddr_un *)ai->ai_addr)->sun_path, 0, UNIX_PATH_MAX);
-
- if (service) {
- struct sockaddr_un *sunp = (struct sockaddr_un *)ai->ai_addr;
+ ((struct sockaddr_un *)ai->ai_addr)->sun_family = AF_LOCAL;
+ memset(((struct sockaddr_un *)ai->ai_addr)->sun_path, 0, UNIX_PATH_MAX);
- if (strchr(service->name, '/') != NULL) {
- if (strlen(service->name) >= sizeof(sunp->sun_path))
- return GAIH_OKIFUNSPEC | -EAI_SERVICE;
+ if (service) {
+ struct sockaddr_un *sunp = (struct sockaddr_un *)ai->ai_addr;
+ if (strchr(service->name, '/') != NULL) {
+ if (strlen(service->name) >= sizeof(sunp->sun_path))
+ return GAIH_OKIFUNSPEC | -EAI_SERVICE;
strcpy(sunp->sun_path, service->name);
} else {
if (strlen(P_tmpdir "/") + 1 + strlen(service->name) >= sizeof(sunp->sun_path))