public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/siddhesh/gai-cleanup2] gaih_inet: Clean up some variables and branches Date: Tue, 1 Mar 2022 02:41:22 +0000 (GMT) [thread overview] Message-ID: <20220301024122.7D615385841D@sourceware.org> (raw) 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; } }
reply other threads:[~2022-03-01 2:41 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220301024122.7D615385841D@sourceware.org \ --to=siddhesh@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).