public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/siddhesh/gai-cleanup2] gaih_getanswer_slice: Drop useless had_error
@ 2022-03-01  2:40 Siddhesh Poyarekar
  0 siblings, 0 replies; 2+ messages in thread
From: Siddhesh Poyarekar @ 2022-03-01  2:40 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=61734d085b63219ee9c4cbd8256ff64ff528d561

commit 61734d085b63219ee9c4cbd8256ff64ff528d561
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
 	{


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [glibc/siddhesh/gai-cleanup2] gaih_getanswer_slice: Drop useless had_error
@ 2022-02-22 13:51 Siddhesh Poyarekar
  0 siblings, 0 replies; 2+ messages in thread
From: Siddhesh Poyarekar @ 2022-02-22 13:51 UTC (permalink / raw)
  To: glibc-cvs

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
 	{


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-01  2:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01  2:40 [glibc/siddhesh/gai-cleanup2] gaih_getanswer_slice: Drop useless had_error Siddhesh Poyarekar
  -- strict thread matches above, loose matches on Subject: below --
2022-02-22 13:51 Siddhesh Poyarekar

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).