This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/4] getaddrinfo: Avoid negating error values


There's no reason for negating the error values in the current code.

	* sysdeps/posix/getaddrinfo.c (gaih_inet_serv): Remove error negation.
	(gaih_inet): Likewise.
	(getaddrinfo): Likewise.

diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 023fc04..1300238 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -154,7 +154,7 @@ gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp,
 	  if (r == ERANGE)
 	    tmpbuflen *= 2;
 	  else
-	    return -EAI_SERVICE;
+	    return EAI_SERVICE;
 	}
     }
   while (r);
@@ -191,7 +191,7 @@ gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp,
 			      2 * tmpbuflen);				      \
 	if (newp == NULL)						      \
 	  {								      \
-	    result = -EAI_MEMORY;					      \
+	    result = EAI_MEMORY;					      \
 	    goto free_and_return;					      \
 	  }								      \
 	tmpbuf = newp;							      \
@@ -209,7 +209,7 @@ gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp,
 	{								      \
 	  __set_h_errno (herrno);					      \
 	  _res.options |= old_res_options & RES_USE_INET6;		      \
-	  result = -EAI_SYSTEM;						      \
+	  result = EAI_SYSTEM;						      \
 	  goto free_and_return;						      \
 	}								      \
       if (herrno == TRY_AGAIN)						      \
@@ -296,9 +296,9 @@ gaih_inet (const char *name, const struct gaih_service *service,
       if (! tp->name[0])
 	{
 	  if (req->ai_socktype)
-	    return -EAI_SOCKTYPE;
+	    return EAI_SOCKTYPE;
 	  else
-	    return -EAI_SERVICE;
+	    return EAI_SERVICE;
 	}
     }
 
@@ -306,7 +306,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
   if (service != NULL)
     {
       if ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0)
-	return -EAI_SERVICE;
+	return EAI_SERVICE;
 
       if (service->num < 0)
 	{
@@ -351,7 +351,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 		  pst = &(newp->next);
 		}
 	      if (st == (struct gaih_servtuple *) &nullserv)
-		return -EAI_SERVICE;
+		return EAI_SERVICE;
 	    }
 	}
       else
@@ -426,10 +426,10 @@ gaih_inet (const char *name, const struct gaih_service *service,
 	    {
 	      /* No need to jump to free_and_return here.  */
 	      if (rc == IDNA_MALLOC_ERROR)
-		return -EAI_MEMORY;
+		return EAI_MEMORY;
 	      if (rc == IDNA_DLOPEN_ERROR)
-		return -EAI_SYSTEM;
-	      return -EAI_IDN_ENCODE;
+		return EAI_SYSTEM;
+	      return EAI_IDN_ENCODE;
 	    }
 	  /* In case the output string is the same as the input string
 	     no new string has been allocated.  */
@@ -455,7 +455,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 	    }
 	  else
 	    {
-	      result = -EAI_ADDRFAMILY;
+	      result = EAI_ADDRFAMILY;
 	      goto free_and_return;
 	    }
 
@@ -491,7 +491,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 			if (namebuf == NULL)
 			  {
 			    assert (!malloc_name);
-			    return -EAI_MEMORY;
+			    return EAI_MEMORY;
 			  }
 			malloc_namebuf = true;
 		      }
@@ -518,7 +518,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 		}
 	      else
 		{
-		  result = -EAI_ADDRFAMILY;
+		  result = EAI_ADDRFAMILY;
 		  goto free_and_return;
 		}
 
@@ -543,7 +543,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 							10);
 		      if (*end != '\0')
 			{
-			  result = -EAI_NONAME;
+			  result = EAI_NONAME;
 			  goto free_and_return;
 			}
 		    }
@@ -599,7 +599,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 					    2 * tmpbuflen);
 		      if (newp == NULL)
 			{
-			  result = -EAI_MEMORY;
+			  result = EAI_MEMORY;
 			  goto free_and_return;
 			}
 		      tmpbuf = newp;
@@ -629,7 +629,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 					    * sizeof (struct gaih_addrtuple));
 			  if (addrmem == NULL)
 			    {
-			      result = -EAI_MEMORY;
+			      result = EAI_MEMORY;
 			      goto free_and_return;
 			    }
 			  malloc_addrmem = true;
@@ -657,14 +657,14 @@ gaih_inet (const char *name, const struct gaih_service *service,
 		  if (herrno == NETDB_INTERNAL)
 		    {
 		      __set_h_errno (herrno);
-		      result = -EAI_SYSTEM;
+		      result = EAI_SYSTEM;
 		    }
 		  else if (herrno == TRY_AGAIN)
-		    result = -EAI_AGAIN;
+		    result = EAI_AGAIN;
 		  else
 		    /* We made requests but they turned out no data.
 		       The name is known, though.  */
-		    result = -EAI_NODATA;
+		    result = EAI_NODATA;
 
 		  goto free_and_return;
 		}
@@ -701,7 +701,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 					* sizeof (struct gaih_addrtuple));
 		      if (addrmem == NULL)
 			{
-			  result = -EAI_MEMORY;
+			  result = EAI_MEMORY;
 			  goto free_and_return;
 			}
 		      malloc_addrmem = true;
@@ -732,7 +732,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 			      canonbuf = malloc (canonlen);
 			      if (canonbuf == NULL)
 				{
-				  result = -EAI_MEMORY;
+				  result = EAI_MEMORY;
 				  goto free_and_return;
 				}
 			      malloc_canonbuf = true;
@@ -770,7 +770,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 
 		  if (at->family == AF_UNSPEC)
 		    {
-		      result = -EAI_NONAME;
+		      result = EAI_NONAME;
 		      goto free_and_return;
 		    }
 
@@ -782,11 +782,11 @@ gaih_inet (const char *name, const struct gaih_service *service,
 	      else if (__nss_not_use_nscd_hosts == 0)
 		{
 		  if (herrno == NETDB_INTERNAL && errno == ENOMEM)
-		    result = -EAI_MEMORY;
+		    result = EAI_MEMORY;
 		  else if (herrno == TRY_AGAIN)
-		    result = -EAI_AGAIN;
+		    result = EAI_AGAIN;
 		  else
-		    result = -EAI_SYSTEM;
+		    result = EAI_SYSTEM;
 
 		  goto free_and_return;
 		}
@@ -825,7 +825,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 	      if (tmpbuf == NULL)
 		{
 		  _res.options |= old_res_options & RES_USE_INET6;
-		  result = -EAI_MEMORY;
+		  result = EAI_MEMORY;
 		  goto free_and_return;
 		}
 	    }
@@ -875,7 +875,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 			  if (newp == NULL)
 			    {
 			      _res.options |= old_res_options & RES_USE_INET6;
-			      result = -EAI_MEMORY;
+			      result = EAI_MEMORY;
 			      goto free_and_return;
 			    }
 			  tmpbuf = newp;
@@ -996,7 +996,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 					{
 					  _res.options
 					    |= old_res_options & RES_USE_INET6;
-					  result = -EAI_MEMORY;
+					  result = EAI_MEMORY;
 					  goto free_and_return;
 					}
 				      malloc_canonbuf = true;
@@ -1061,7 +1061,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 
 	  if (h_errno == NETDB_INTERNAL)
 	    {
-	      result = -EAI_SYSTEM;
+	      result = EAI_SYSTEM;
 	      goto free_and_return;
 	    }
 
@@ -1069,11 +1069,11 @@ gaih_inet (const char *name, const struct gaih_service *service,
 	    {
 	      /* If both requests timed out report this.  */
 	      if (no_data == EAI_AGAIN && no_inet6_data == EAI_AGAIN)
-		result = -EAI_AGAIN;
+		result = EAI_AGAIN;
 	      else
 		/* We made requests but they turned out no data.  The name
 		   is known, though.  */
-		result = -EAI_NODATA;
+		result = EAI_NODATA;
 
 	      goto free_and_return;
 	    }
@@ -1082,7 +1082,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
     process_list:
       if (at->family == AF_UNSPEC)
 	{
-	  result = -EAI_NONAME;
+	  result = EAI_NONAME;
 	  goto free_and_return;
 	}
     }
@@ -1147,11 +1147,11 @@ gaih_inet (const char *name, const struct gaih_service *service,
 		if (rc != IDNA_SUCCESS)
 		  {
 		    if (rc == IDNA_MALLOC_ERROR)
-		      result = -EAI_MEMORY;
+		      result = EAI_MEMORY;
 		    else if (rc == IDNA_DLOPEN_ERROR)
-		      result = -EAI_SYSTEM;
+		      result = EAI_SYSTEM;
 		    else
-		      result = -EAI_IDN_ENCODE;
+		      result = EAI_IDN_ENCODE;
 		    goto free_and_return;
 		  }
 		/* In case the output string is the same as the input
@@ -1175,7 +1175,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 		    canon = strdup (canon);
 		    if (canon == NULL)
 		      {
-			result = -EAI_MEMORY;
+			result = EAI_MEMORY;
 			goto free_and_return;
 		      }
 		  }
@@ -1205,7 +1205,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
 	    if (ai == NULL)
 	      {
 		free ((char *) canon);
-		result = -EAI_MEMORY;
+		result = EAI_MEMORY;
 		goto free_and_return;
 	      }
 
@@ -2405,7 +2405,7 @@ getaddrinfo (const char *name, const char *service,
 	{
 	  freeaddrinfo (p);
 	  __free_in6ai (in6ai);
-          return -error;
+          return error;
 	}
     }
   else


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]