From: Junio C Hamano <gitster@pobox.com>
To: "Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Han-Wen Nienhuys <hanwenn@gmail.com>,
Han-Wen Nienhuys <hanwen@google.com>
Subject: Re: [PATCH 1/3] refs: push lock management into packed backend
Date: Mon, 18 Sep 2023 15:46:21 -0700 [thread overview]
Message-ID: <xmqqa5tjje0y.fsf@gitster.g> (raw)
In-Reply-To: <dea0fbb139a82fe449a7edab6a8f445ce763d0c0.1695059978.git.gitgitgadget@gmail.com> (Han-Wen Nienhuys via GitGitGadget's message of "Mon, 18 Sep 2023 17:59:36 +0000")
"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:
> struct ref_transaction *tr;
> + int ret = 0;
> assert(err);
>
> CALLOC_ARRAY(tr, 1);
> tr->ref_store = refs;
> +
> + if (refs->be->transaction_begin)
> + ret = refs->be->transaction_begin(refs, tr, err);
> + if (ret) {
> + free(tr);
> + return NULL;
> + }
> return tr;
> }
This looks a bit more convoluted than necessary. Is it the same as
if (refs->be->transaction_begin &&
refs->be->transaction_begin(refs, tr, err))
FREE_AND_NULL(tr);
> + if (backend_data->packed_transaction) {
> + if (backend_data->packed_transaction_needed) {
> + ret = ref_transaction_commit(packed_transaction, err);
> + if (ret)
> + goto cleanup;
> + /* TODO: leaks on error path. */
> + ref_transaction_free(packed_transaction);
> + packed_transaction = NULL;
> + backend_data->packed_transaction = NULL;
> + } else {
If it were just a matter of flipping the early return and freeing of
the transaction before going to clean-up, then that would have been
less effort than leaving the TODO: comment. What other things are
needed to plug this leak?
next prev parent reply other threads:[~2023-09-18 22:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 17:59 [PATCH 0/3] Simple reftable backend Han-Wen Nienhuys via GitGitGadget
2023-09-18 17:59 ` [PATCH 1/3] refs: push lock management into packed backend Han-Wen Nienhuys via GitGitGadget
2023-09-18 22:46 ` Junio C Hamano [this message]
2023-09-19 15:52 ` Han-Wen Nienhuys
2023-09-18 17:59 ` [PATCH 2/3] refs: move is_packed_transaction_needed out of packed-backend.c Han-Wen Nienhuys via GitGitGadget
2023-09-18 17:59 ` [PATCH 3/3] refs: alternate reftable ref backend implementation Han-Wen Nienhuys via GitGitGadget
2023-09-18 22:43 ` [PATCH 0/3] Simple reftable backend Junio C Hamano
2023-09-20 13:02 ` [PATCH v2 0/6] RFC: simple " Han-Wen Nienhuys via GitGitGadget
2023-09-20 13:02 ` [PATCH v2 1/6] refs: construct transaction using a _begin callback Han-Wen Nienhuys via GitGitGadget
2023-09-20 13:02 ` [PATCH v2 2/6] refs: wrap transaction in a debug-specific transaction Han-Wen Nienhuys via GitGitGadget
2023-09-20 13:02 ` [PATCH v2 3/6] refs: push lock management into packed backend Han-Wen Nienhuys via GitGitGadget
2023-09-20 13:02 ` [PATCH v2 4/6] refs: move is_packed_transaction_needed out of packed-backend.c Han-Wen Nienhuys via GitGitGadget
2023-09-20 13:02 ` [PATCH v2 5/6] refs: alternate reftable ref backend implementation Han-Wen Nienhuys via GitGitGadget
2023-09-20 13:02 ` [PATCH v2 6/6] refs: always try to do packed transactions for reftable Han-Wen Nienhuys via GitGitGadget
2023-09-21 10:01 ` [PATCH v2 0/6] RFC: simple reftable backend Patrick Steinhardt
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=xmqqa5tjje0y.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=hanwen@google.com \
--cc=hanwenn@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).