git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] merge-ort: fix calling merge_finalize() with no intermediate merge

From
Elijah Newren <newren@gmail.com>
Date
Apr 22, 2023, 02:04 UTC
Message-ID
<CABPp-BGVEWM_N3eXjfEGjemeNzrLMmqDOuWKCvzOuHGeMueoJQ@mail.gmail.com>
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:
Show 35 quoted lines
>
> 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.
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 7 in “merge-ort: fix calling merge_finalize() with no intermediate merge”
  1. merge-ort: fix calling merge_finalize() with no intermediate mergeElijah Newren via GitGitGadget, Apr 20, 2023
  2. Derrick StoleeApr 20, 2023
  3. Junio C HamanoApr 20, 2023
  4. Elijah NewrenApr 22, 2023
  5. Junio C HamanoApr 20, 2023
  6. merge-ort: fix calling merge_finalize() with no intermediate mergeElijah Newren via GitGitGadget, Apr 22, 2023
  7. Derrick StoleeApr 24, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.