Patchwork [v2] sysdeps/posix: Simplify if expression in getaddrinfo()

login
register
mail settings
Submitter Tim Rühsen
Date Nov. 24, 2019, 7:35 p.m.
Message ID <20191124193517.251297-1-tim.ruehsen@gmx.de>
Download mbox | patch
Permalink /patch/36165/
State New
Headers show

Comments

Tim Rühsen - Nov. 24, 2019, 7:35 p.m.
Small code cleanup for better readability.
---
 sysdeps/posix/getaddrinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.24.0
Florian Weimer - Nov. 26, 2019, 9:18 a.m.
* Tim Rühsen:

> Small code cleanup for better readability.
> ---
>  sysdeps/posix/getaddrinfo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
> index ea127877cb..afdcdf0a3b 100644
> --- a/sysdeps/posix/getaddrinfo.c
> +++ b/sysdeps/posix/getaddrinfo.c
> @@ -2206,7 +2206,7 @@ getaddrinfo (const char *name, const char *service,
>  	{
>  	  /* If we haven't seen both IPv4 and IPv6 interfaces we can
>  	     narrow down the search.  */
> -	  if ((! seen_ipv4 || ! seen_ipv6) && (seen_ipv4 || seen_ipv6))
> +	  if (seen_ipv4 != seen_ipv6)
>  	    {
>  	      local_hints = *hints;
>  	      local_hints.ai_family = seen_ipv4 ? PF_INET : PF_INET6;

Thanks, I've pushed that for you, after dropping the () from the
subject (per GNU style).

Patch

diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index ea127877cb..afdcdf0a3b 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -2206,7 +2206,7 @@  getaddrinfo (const char *name, const char *service,
 	{
 	  /* If we haven't seen both IPv4 and IPv6 interfaces we can
 	     narrow down the search.  */
-	  if ((! seen_ipv4 || ! seen_ipv6) && (seen_ipv4 || seen_ipv6))
+	  if (seen_ipv4 != seen_ipv6)
 	    {
 	      local_hints = *hints;
 	      local_hints.ai_family = seen_ipv4 ? PF_INET : PF_INET6;