public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@linux-m68k.org>
To: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	leonardo.macchia@gmail.com
Subject: Re: [PATCH v2 3/3] inet: Return EAI_MEMORY when nrl_domainname() fails to allocate memory
Date: Fri, 12 Nov 2021 16:44:47 +0100	[thread overview]
Message-ID: <87ee7ltm34.fsf@igel.home> (raw)
In-Reply-To: <20211112142114.239913-4-adhemerval.zanella@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Fri, 12 Nov 2021 11:21:14 -0300")

On Nov 12 2021, Adhemerval Zanella via Libc-alpha wrote:

> diff --git a/inet/getnameinfo.c b/inet/getnameinfo.c
> index 2d2397e7dc..2bec3263fc 100644
> --- a/inet/getnameinfo.c
> +++ b/inet/getnameinfo.c
> @@ -83,7 +83,7 @@ libc_freeres_ptr (static char *domain);
>     now ignored.  */
>  #define DEPRECATED_NI_IDN 192
>  
> -static void
> +static bool
>  nrl_domainname_core (struct scratch_buffer *tmpbuf)
>  {
>    char *c;
> @@ -97,7 +97,7 @@ nrl_domainname_core (struct scratch_buffer *tmpbuf)
>        if (herror == NETDB_INTERNAL && errno == ERANGE)
>  	{
>  	  if (!scratch_buffer_grow (tmpbuf))
> -	    return;
> +	    return false;
>  	}
>        else
>  	break;
> @@ -111,10 +111,13 @@ nrl_domainname_core (struct scratch_buffer *tmpbuf)
>  	 now to get more information.  */
>        while (__gethostname (tmpbuf->data, tmpbuf->length))
>  	if (!scratch_buffer_grow (tmpbuf))
> -	  return;
> +	  return false;
>  
>        if ((c = strchr (tmpbuf->data, '.')) != NULL)
> -	domain = __strdup (++c);
> +	{
> +	  domain = __strdup (++c);
> +	  return domain != NULL;
> +	}
>        else

You can remove `else' here and save a level of indentation.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

  reply	other threads:[~2021-11-12 15:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-12 14:21 [PATCH v2 0/3] Fixes for getnameinfo() with NI_NOFQDN Adhemerval Zanella
2021-11-12 14:21 ` [PATCH v2 1/3] inet: Fix getnameinfo (NI_NOFQDN) race condition (BZ#28566) Adhemerval Zanella
2021-11-12 14:21 ` [PATCH v2 2/3] inet: Remove strdupa from nrl_domainname() Adhemerval Zanella
2021-11-12 14:21 ` [PATCH v2 3/3] inet: Return EAI_MEMORY when nrl_domainname() fails to allocate memory Adhemerval Zanella
2021-11-12 15:44   ` Andreas Schwab [this message]
2021-11-25 16:38     ` [PATCH v3] " Adhemerval Zanella
2021-12-10 11:07 [PATCH v2 0/3] Fixes for getnameinfo() with NI_NOFQDN Adhemerval Zanella
2021-12-10 11:07 ` [PATCH v2 3/3] inet: Return EAI_MEMORY when nrl_domainname() fails to allocate memory Adhemerval Zanella
2022-02-03 20:53   ` Adhemerval Zanella
2022-03-08  4:12   ` DJ Delorie
2022-03-08 15:43     ` Adhemerval Zanella

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=87ee7ltm34.fsf@igel.home \
    --to=schwab@linux-m68k.org \
    --cc=adhemerval.zanella@linaro.org \
    --cc=leonardo.macchia@gmail.com \
    --cc=libc-alpha@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).