From patchwork Mon Jun 30 05:59:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1814 Received: (qmail 21038 invoked by alias); 30 Jun 2014 05:57:45 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 21026 invoked by uid 89); 30 Jun 2014 05:57:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Date: Mon, 30 Jun 2014 11:29:10 +0530 From: Siddhesh Poyarekar To: Roland McGrath Cc: "Carlos O'Donell" , libc-alpha@sourceware.org Subject: [PATCH v2] Remove MULTI_PTRS_ARE_ALIASES to fix Wundef warning Message-ID: <20140630055909.GN4477@spoyarek.pnq.redhat.com> References: <20140627173501.GA12370@spoyarek.pnq.redhat.com> <53ADB5FD.1030202@redhat.com> <20140628012721.GL4477@spoyarek.pnq.redhat.com> <20140628043419.AFBF62C3A0D@topped-with-meat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140628043419.AFBF62C3A0D@topped-with-meat.com> User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) On Fri, Jun 27, 2014 at 09:34:19PM -0700, Roland McGrath wrote: > I guess for now the inconsistency just makes me want to have the other code > forks around as documentation. I suppose comments would do it just as > well. Still my inclination is to make these something like: > > /* Insert long new comment about the weirdness and referring to the other > file where the opposite fork is used in equivalent code. */ > #if 0 /* was MULTI_PTRS_ARE_ALIASES */ After reading further, I don't think there is any inconsistency in functionality. The gethostbyaddr function also uses the dns-host.c bits and gethnamaddr.c is currently not used at all. The only reference it has is in resolv/README: The files gethnamaddr.c, mapv4v6addr.h and mapv4v6hostent.h are leftovers from BIND 4.9.7. Given this newly discovered fact, how about the following patch instead? I don't modify gethnamaddr.c because it's not even used. I wonder - given that we have decided to own the resolver bits now - if we should just get rid of gethnamaddr.c and other unused files. I could add a note in the README mentioning this. Siddhesh * resolv/nss_dns/dns-host.c (getanswer_r) [MULTI_PTRS_ARE_ALIASES]: Remove code. commit 8e2ad63093a3c1e18122acdb50db5883770a3fc5 Author: Siddhesh Poyarekar Date: Mon Jun 30 11:17:51 2014 +0530 Remove MULTI_PTRS_ARE_ALIASES in dns-hosts.c The code in gethnamaddr.c for gethostbyaddr used and set this macro to allow multiple PTR records to be added as aliases. This was useful for gethostbyaddr since it returns a hostent structure, which can return aliases. The gethnamaddr.c source however is unused in glibc since pretty much forever. Instead, the DNS lookup bits for gethostbyaddr (as well as getnameinfo) are implemented in dns-hosts.c and in that implementation all but one (the first one) of the multiple PTR records are ignored. Since gethnamaddr.c is essentially dead code, ignore that implementation and replace the MULTI_PTRS_ARE_ALIASES bit with a comment mentioning that bind adds PTR records as aliases while we don't. diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index a5f2c0a..3258e70 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -869,27 +869,8 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, ++had_error; break; } -#if MULTI_PTRS_ARE_ALIASES - cp += n; - if (haveanswer == 0) - result->h_name = bp; - else if (ap < &host_data->aliases[MAXALIASES-1]) - *ap++ = bp; - else - n = -1; - if (n != -1) - { - n = strlen (bp) + 1; /* for the \0 */ - if (__builtin_expect (n, 0) >= MAXHOSTNAMELEN) - { - ++had_error; - break; - } - bp += n; - linebuflen -= n; - } - break; -#else + /* bind would put multiple PTR records as aliases, but we don't do + that. */ result->h_name = bp; if (have_to_map) { @@ -906,7 +887,6 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, } *h_errnop = NETDB_SUCCESS; return NSS_STATUS_SUCCESS; -#endif case T_A: case T_AAAA: if (__builtin_expect (strcasecmp (result->h_name, bp), 0) != 0)