git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Derrick Stolee <derrickstolee@github.com>
To: Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>
Subject: Re: [PATCH] merge-ort: fix calling merge_finalize() with no intermediate merge
Date: Thu, 20 Apr 2023 09:10:47 -0400	[thread overview]
Message-ID: <d5c93b5b-32b9-ec50-1661-06f73fa37f5f@github.com> (raw)
In-Reply-To: <pull.1518.git.1681974847078.gitgitgadget@gmail.com>

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?

Thanks,
-Stolee

  reply	other threads:[~2023-04-20 13:10 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 [this message]
2023-04-20 17:10   ` Junio C Hamano
2023-04-22  2:04   ` Elijah Newren
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=d5c93b5b-32b9-ec50-1661-06f73fa37f5f@github.com \
    --to=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=newren@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).