This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH 1/4] getaddrinfo: Remove unnecessary variables and code
- From: Pavel Simerda <psimerda at redhat dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: libc-alpha <libc-alpha at sourceware dot org>, Siddhesh Poyarekar <siddhesh at redhat dot com>
- Date: Mon, 9 Dec 2013 13:22:36 -0500 (EST)
- Subject: Re: [PATCH 1/4] getaddrinfo: Remove unnecessary variables and code
- Authentication-results: sourceware.org; auth=none
- References: <860551836 dot 23953523 dot 1386596222016 dot JavaMail dot root at redhat dot com> <841948625 dot 23953604 dot 1386596238564 dot JavaMail dot root at redhat dot com> <20131209152710 dot GA29105 at domone dot podge>
----- Original Message -----
> From: "OndÅej BÃlka" <firstname.lastname@example.org>
> To: "Pavel Simerda" <email@example.com>
> Cc: "libc-alpha" <firstname.lastname@example.org>, "Siddhesh Poyarekar" <email@example.com>
> Sent: Monday, December 9, 2013 4:27:10 PM
> Subject: Re: [PATCH 1/4] getaddrinfo: Remove unnecessary variables and code
> On Mon, Dec 09, 2013 at 08:37:18AM -0500, Pavel Simerda wrote:
> > Variable 'end' in getaddrinfo() was only used to compute 'nresults'
> > which was already computed in gaih_inet() and stored in 'naddrs'.
> This needs know code in detail, it looks similir but I there is
> following fragment that may mak these differ
> /* 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
> && (req->ai_flags & (AI_V4MAPPED|AI_ALL)) == AI_V4MAPPED
> && IN6_IS_ADDR_V4MAPPED (at2->addr))
> goto ignore;
Looking at it once again. This code is only preceeded by canonical name handling without struct addrinfo allocation. Therefore the goto not only results in skipping the incrementation, but also skipping the addrinfo list append action which is a couple of lines below the goto command. Looks safe to me.
> > Variable 'last_i' was used at the end of getaddrinfo() even though
> > it was always zero.
> ok with last_i part.