public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/siddhesh/gai-cleanup2] gaih_inet: Clean up some variables and branches
@ 2022-03-01 2:41 Siddhesh Poyarekar
0 siblings, 0 replies; only message in thread
From: Siddhesh Poyarekar @ 2022-03-01 2:41 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=67d46da1a14827d8d89c7aba5c55401495c44fbc
commit 67d46da1a14827d8d89c7aba5c55401495c44fbc
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Mon Feb 28 22:30:04 2022 +0530
gaih_inet: Clean up some variables and branches
Consolidate some redundant assignments and make the result loop
structure a bit simpler.
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diff:
---
sysdeps/posix/getaddrinfo.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 1d248c8835..3dd2f8cff7 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -1094,7 +1094,6 @@ gaih_inet (const char *name, const struct gaih_service *service,
/ sizeof (struct gaih_typeproto)] = {0};
struct gaih_addrtuple *at = NULL;
- bool got_ipv6 = false;
char *canon = NULL;
const char *orig_name = name;
@@ -1156,7 +1155,6 @@ gaih_inet (const char *name, const struct gaih_service *service,
{
at = res.at;
canon = at->name;
- got_ipv6 = res.got_ipv6;
goto process_list;
}
#endif
@@ -1167,10 +1165,8 @@ gaih_inet (const char *name, const struct gaih_service *service,
{
at = res.at;
canon = at->name;
- got_ipv6 = res.got_ipv6;
}
- process_list:
if (at == NULL)
{
result = -EAI_NONAME;
@@ -1205,19 +1201,18 @@ gaih_inet (const char *name, const struct gaih_service *service,
}
}
+process_list:
{
/* Set up the canonical name if we need it. */
if ((result = process_canonname (req, orig_name, &canon)) != 0)
goto free_and_return;
- struct gaih_addrtuple *at2 = at;
size_t socklen;
sa_family_t family;
- /*
- buffer is the size of an unformatted IPv6 address in printable format.
- */
- while (at2 != NULL)
+ /* Buffer is the size of an unformatted IPv6 address in printable
+ format. */
+ for (struct gaih_addrtuple *at2 = at; at2 != NULL; at2 = at2->next)
{
family = at2->family;
if (family == AF_INET6)
@@ -1227,10 +1222,10 @@ gaih_inet (const char *name, const struct gaih_service *service,
/* If we looked up IPv4 mapped address discard them here if
the caller isn't interested in all address and we have
found at least one IPv6 address. */
- if (got_ipv6
+ if (res.got_ipv6
&& (req->ai_flags & (AI_V4MAPPED|AI_ALL)) == AI_V4MAPPED
&& IN6_IS_ADDR_V4MAPPED (at2->addr))
- goto ignore;
+ continue;
}
else
socklen = sizeof (struct sockaddr_in);
@@ -1290,9 +1285,6 @@ gaih_inet (const char *name, const struct gaih_service *service,
}
++*naddrs;
-
- ignore:
- at2 = at2->next;
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-01 2:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01 2:41 [glibc/siddhesh/gai-cleanup2] gaih_inet: Clean up some variables and branches Siddhesh Poyarekar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).