From patchwork Tue Aug 8 17:01:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 21986 Received: (qmail 35297 invoked by alias); 8 Aug 2017 17:01:40 -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 34271 invoked by uid 89); 8 Aug 2017 17:01:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0323772D75 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=fweimer@redhat.com Date: Tue, 08 Aug 2017 19:01:35 +0200 To: libc-alpha@sourceware.org Subject: [PATCH] getaddrinfo: Use &errno has the errno pointer User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20170808170135.D4C064029923B@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) Similar code in nss/getXXbyYY_r.c is already using &errno as the argument. 2017-08-08 Florian Weimer * sysdeps/posix/getaddrinfo.c (gethosts): Use errno directly. (getcanonname): Likewise. (gaih_inet): Likewise. diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 09f85fc..1a16820 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -247,11 +247,10 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, char *localcanon = NULL; \ no_data = 0; \ while (1) { \ - rc = 0; \ status = DL_CALL_FCT (fct, (name, _family, &th, \ tmpbuf->data, tmpbuf->length, \ - &rc, &herrno, NULL, &localcanon)); \ - if (rc != ERANGE || herrno != NETDB_INTERNAL) \ + &errno, &herrno, NULL, &localcanon)); \ + if (errno != ERANGE || herrno != NETDB_INTERNAL) \ break; \ if (!scratch_buffer_grow (tmpbuf)) \ { \ @@ -261,11 +260,11 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, goto free_and_return; \ } \ } \ - if (status == NSS_STATUS_SUCCESS && rc == 0) \ + if (status == NSS_STATUS_SUCCESS && errno == 0) \ h = &th; \ else \ h = NULL; \ - if (rc != 0) \ + if (errno != 0) \ { \ if (herrno == NETDB_INTERNAL) \ { \ @@ -335,9 +334,8 @@ getcanonname (service_user *nip, struct gaih_addrtuple *at, const char *name) { char buf[256]; int herrno; - int rc; if (DL_CALL_FCT (cfct, (at->name ?: name, buf, sizeof (buf), - &s, &rc, &herrno)) != NSS_STATUS_SUCCESS) + &s, &errno, &herrno)) != NSS_STATUS_SUCCESS) /* If the canonical name cannot be determined, use the passed string. */ s = (char *) name; @@ -353,7 +351,6 @@ gaih_inet (const char *name, const struct gaih_service *service, const struct gaih_typeproto *tp = gaih_inet_typeproto; struct gaih_servtuple *st = (struct gaih_servtuple *) &nullserv; struct gaih_addrtuple *at = NULL; - int rc; bool got_ipv6 = false; const char *canon = NULL; const char *orig_name = name; @@ -395,7 +392,8 @@ gaih_inet (const char *name, const struct gaih_service *service, st = (struct gaih_servtuple *) alloca_account (sizeof (struct gaih_servtuple), alloca_used); - if ((rc = gaih_inet_serv (service->name, tp, req, st, tmpbuf))) + int rc = gaih_inet_serv (service->name, tp, req, st, tmpbuf); + if (__glibc_unlikely (rc != 0)) return rc; } else @@ -495,7 +493,7 @@ gaih_inet (const char *name, const struct gaih_service *service, idn_flags |= IDNA_USE_STD3_ASCII_RULES; char *p = NULL; - rc = __idna_to_ascii_lz (name, &p, idn_flags); + int rc = __idna_to_ascii_lz (name, &p, idn_flags); if (rc != IDNA_SUCCESS) { /* No need to jump to free_and_return here. */ @@ -793,15 +791,14 @@ gaih_inet (const char *name, const struct gaih_service *service, while (1) { - rc = 0; status = DL_CALL_FCT (fct4, (name, pat, tmpbuf->data, tmpbuf->length, - &rc, &herrno, + &errno, &herrno, NULL)); if (status == NSS_STATUS_SUCCESS) break; if (status != NSS_STATUS_TRYAGAIN - || rc != ERANGE || herrno != NETDB_INTERNAL) + || errno != ERANGE || herrno != NETDB_INTERNAL) { if (herrno == TRY_AGAIN) no_data = EAI_AGAIN;