public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: DJ Delorie <dj@redhat.com>
To: Siddhesh Poyarekar <siddhesh@sourceware.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH 2/3] gai_init: Avoid jumping from if condition to its else counterpart
Date: Thu, 17 Mar 2022 19:48:00 -0400	[thread overview]
Message-ID: <xny218f8en.fsf@greed.delorie.com> (raw)
In-Reply-To: <20220314173039.1060650-3-siddhesh@sourceware.org> (message from Siddhesh Poyarekar via Libc-alpha on Mon, 14 Mar 2022 23:00:38 +0530)


Siddhesh Poyarekar via Libc-alpha <libc-alpha@sourceware.org> writes:
> Clean up another antipattern where code flows from an if condition to
> its else counterpart with a goto.
>
> Most of the change in this patch is whitespace-only; a `git diff -b`
> ought to show the actual logic changes.

Re-diffed as "diff -EZdbwpU5" and reviewing that...

LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>

> --- before.txt	2022-03-17 19:42:35.903049857 -0400
> +++ after.txt	2022-03-17 19:42:49.976581858 -0400
> @@ -1834,12 +1834,13 @@ gaiconf_init (void)
>    struct scopelist *scopelist =  NULL;
>    size_t nscopelist = 0;
>    bool scopelist_nullbits = false;
>  
>    FILE *fp = fopen (GAICONF_FNAME, "rce");
> +  if (fp == NULL)
> +    goto no_file;
> +
> -  if (fp != NULL)
> -    {

Ok.

>        struct __stat64_t64 st;
>        if (__fstat64_time64 (fileno (fp), &st) != 0)
>  	{
>  	  fclose (fp);
>  	  goto no_file;
> @@ -2131,24 +2132,21 @@ gaiconf_init (void)
>        scopes = new_scopes;
>        if (oldscope != default_scopes)
>  	free ((void *) oldscope);
>  
>        save_gaiconf_mtime (&st);
> -    }
> -  else
> -    {
> +  return;
> +

Ok.

>      no_file:
>        free_prefixlist (labellist);
>        free_prefixlist (precedencelist);
>        free_scopelist (scopelist);
>  
> -      /* If we previously read the file but it is gone now, free the
> -	 old data and use the builtin one.  Leave the reload flag
> -	 alone.  */
> +  /* If we previously read the file but it is gone now, free the old data and
> +     use the builtin one.  Leave the reload flag alone.  */
>        fini ();
>      }
> -}

Ok.


  reply	other threads:[~2022-03-17 23:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 17:30 [PATCH 0/3] More getaddrinfo refactoring Siddhesh Poyarekar
2022-03-14 17:30 ` [PATCH 1/3] gaiconf_init: Refactor some bits for readability Siddhesh Poyarekar
2022-03-17 22:41   ` DJ Delorie
2022-03-14 17:30 ` [PATCH 2/3] gai_init: Avoid jumping from if condition to its else counterpart Siddhesh Poyarekar
2022-03-17 23:48   ` DJ Delorie [this message]
2022-03-14 17:30 ` [PATCH 3/3] getaddrinfo: Refactor code for readability Siddhesh Poyarekar
2022-03-18  0:20   ` DJ Delorie
2022-03-22 17:10     ` [PATCH v2] " Siddhesh Poyarekar
2022-03-22 19:05       ` DJ Delorie

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=xny218f8en.fsf@greed.delorie.com \
    --to=dj@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=siddhesh@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).