git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Elijah Newren <newren@gmail.com>
To: Derrick Stolee <derrickstolee@github.com>
Cc: Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH] merge-ort: fix calling merge_finalize() with no intermediate merge
Date: Fri, 21 Apr 2023 19:04:41 -0700	[thread overview]
Message-ID: <CABPp-BGVEWM_N3eXjfEGjemeNzrLMmqDOuWKCvzOuHGeMueoJQ@mail.gmail.com> (raw)
In-Reply-To: <d5c93b5b-32b9-ec50-1661-06f73fa37f5f@github.com>

On Thu, Apr 20, 2023 at 6:10 AM Derrick Stolee <derrickstolee@github.com> wrote:
>
> On 4/20/2023 3:14 AM, Elijah Newren via GitGitGadget wrote:
> > From: Elijah Newren <newren@gmail.com>
>
> > While at it, ensure the FREE_AND_NULL() in the function does something
> > useful with the nulling aspect, namely sets result->priv to NULL rather
> > than a mere temporary.
>
> Good call. It also makes the code look better.
>
> >  void merge_finalize(struct merge_options *opt,
> >                   struct merge_result *result)
> >  {
> > -     struct merge_options_internal *opti = result->priv;
> > -
> >       if (opt->renormalize)
> >               git_attr_set_direction(GIT_ATTR_CHECKIN);
> >       assert(opt->priv == NULL);
> >
> > -     clear_or_reinit_internal_opts(opti, 0);
> > -     FREE_AND_NULL(opti);
> > +     if (!result->priv)
> > +             return;
> > +     clear_or_reinit_internal_opts(result->priv, 0);
> > +     FREE_AND_NULL(result->priv);
>
> Perhaps this would be better as
>
>         if (result->priv) {
>                 clear_or_reinit_internal_opts(result->priv, 0);
>                 FREE_AND_NULL(result->priv);
>         }
>
> to avoid an accidental addition of code to the end of this
> method that doesn't depend on result->priv?

Ooh, yes, that'd be a good improvement; thanks.

  parent reply	other threads:[~2023-04-22  2:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-20  7:14 [PATCH] merge-ort: fix calling merge_finalize() with no intermediate merge Elijah Newren via GitGitGadget
2023-04-20 13:10 ` Derrick Stolee
2023-04-20 17:10   ` Junio C Hamano
2023-04-22  2:04   ` Elijah Newren [this message]
2023-04-20 16:11 ` Junio C Hamano
2023-04-22 20:22 ` [PATCH v2] " Elijah Newren via GitGitGadget
2023-04-24 15:17   ` Derrick Stolee

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=CABPp-BGVEWM_N3eXjfEGjemeNzrLMmqDOuWKCvzOuHGeMueoJQ@mail.gmail.com \
    --to=newren@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    /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 NNTP newsgroup(s).