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_getanswer_slice: Drop useless had_error
Date: Tue, 22 Feb 2022 13:51:14 +0000 (GMT)	[thread overview]
Message-ID: <20220222135114.0D1DD3870886@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3fc0bd92bddeb8167e5d26c8f9ef0a40b0c2f201

commit 3fc0bd92bddeb8167e5d26c8f9ef0a40b0c2f201
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date:   Mon Feb 14 14:11:13 2022 +0530

    gaih_getanswer_slice: Drop useless had_error
    
    Simply break out of the while loop instead of setting had_error since
    it's not really used for anything other than breaking out of the loop
    anyway.
    
    Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

Diff:
---
 resolv/nss_dns/dns-host.c | 36 +++++++++---------------------------
 1 file changed, 9 insertions(+), 27 deletions(-)

diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index 913a5cb82f..e32a4710e2 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -1064,7 +1064,6 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
   cp += n + QFIXEDSZ;
 
   int haveanswer = 0;
-  int had_error = 0;
   char *canon = NULL;
   char *h_name = NULL;
   int h_namelen = 0;
@@ -1075,7 +1074,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
       return NSS_STATUS_NOTFOUND;
     }
 
-  while (ancount-- > 0 && cp < end_of_message && had_error == 0)
+  while (ancount-- > 0 && cp < end_of_message)
     {
       n = __ns_name_unpack (answer->buf, end_of_message, cp,
 			    packtmp, sizeof packtmp);
@@ -1088,10 +1087,8 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
 	  n = -1;
 	}
       if (__glibc_unlikely (n < 0 || __libc_res_hnok (buffer) == 0))
-	{
-	  ++had_error;
-	  continue;
-	}
+	break;
+
       if (*firstp && canon == NULL)
 	{
 	  h_name = buffer;
@@ -1102,10 +1099,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
       cp += n;				/* name */
 
       if (__glibc_unlikely (cp + 10 > end_of_message))
-	{
-	  ++had_error;
-	  continue;
-	}
+	break;
 
       uint16_t type;
       NS_GET16 (type, cp);
@@ -1116,11 +1110,8 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
       NS_GET16 (n, cp);		/* RDATA length.  */
 
       if (end_of_message - cp < n)
-	{
-	  /* RDATA extends beyond the end of the packet.  */
-	  ++had_error;
-	  continue;
-	}
+	/* RDATA extends beyond the end of the packet.  */
+	break;
 
       if (class != C_IN)
 	{
@@ -1139,10 +1130,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
 	  n = __libc_dn_expand (answer->buf, end_of_message, cp,
 				tbuf, sizeof tbuf);
 	  if (__glibc_unlikely (n < 0 || __libc_res_hnok (tbuf) == 0))
-	    {
-	      ++had_error;
-	      continue;
-	    }
+	    break;
 	  cp += n;
 
 	  if (*firstp)
@@ -1158,10 +1146,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
 	      if (__glibc_unlikely (n > buflen))
 		goto too_small;
 	      if (__glibc_unlikely (n >= MAXHOSTNAMELEN))
-		{
-		  ++had_error;
-		  continue;
-		}
+		break;
 
 	      canon = buffer;
 	      buffer = __mempcpy (buffer, tbuf, n);
@@ -1176,10 +1161,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
       if (type == T_A || type == T_AAAA)
 	{
 	  if (n != rrtype_to_rdata_length (type))
-	    {
-	      ++had_error;
-	      continue;
-	    }
+	    break;
 	}
       else
 	{


             reply	other threads:[~2022-02-22 13:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 13:51 Siddhesh Poyarekar [this message]
2022-03-01  2:40 Siddhesh Poyarekar

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=20220222135114.0D1DD3870886@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: link
Be 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).