Parcourir la source

resolv.c: shrink code a bit in getnameinfo.

Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Peter S. Mazinger il y a 13 ans
Parent
commit
d9f20698ed
1 fichiers modifiés avec 4 ajouts et 6 suppressions
  1. 4 6
      libc/inet/resolv.c

+ 4 - 6
libc/inet/resolv.c

@@ -1774,7 +1774,7 @@ int getnameinfo(const struct sockaddr *sa,
 		unsigned flags)
 {
 	int serrno = errno;
-	unsigned ok;
+	bool ok = 0;
 	struct hostent *hoste = NULL;
 	char domain[256];
 
@@ -1784,16 +1784,15 @@ int getnameinfo(const struct sockaddr *sa,
 	if (sa == NULL || addrlen < sizeof(sa_family_t))
 		return EAI_FAMILY;
 
-	ok = sa->sa_family;
-	if (ok == AF_LOCAL) /* valid */;
+	if (sa->sa_family == AF_LOCAL) /* valid */;
 #ifdef __UCLIBC_HAS_IPV4__
-	else if (ok == AF_INET) {
+	else if (sa->sa_family == AF_INET) {
 		if (addrlen < sizeof(struct sockaddr_in))
 			return EAI_FAMILY;
 	}
 #endif
 #ifdef __UCLIBC_HAS_IPV6__
-	else if (ok == AF_INET6) {
+	else if (sa->sa_family == AF_INET6) {
 		if (addrlen < sizeof(struct sockaddr_in6))
 			return EAI_FAMILY;
 	}
@@ -1801,7 +1800,6 @@ int getnameinfo(const struct sockaddr *sa,
 	else
 		return EAI_FAMILY;
 
-	ok = 0;
 	if (host != NULL && hostlen > 0)
 		switch (sa->sa_family) {
 		case AF_INET: