From: Patrick Steinhardt <ps@pks.im>
To: Justin Tobler <jltobler@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/4] tmp-objdir: preserve errno when directory creation fails
Date: Wed, 11 Nov 2026 14:16:09 +0100 [thread overview]
Message-ID: <avRqmRR29QSbj1k4@pks.im> (raw)
In-Reply-To: <20261110002251.2007617-4-jltobler@gmail.com>
On Mon, Nov 09, 2026 at 06:22:50PM -0600, Justin Tobler wrote:
> diff --git a/tmp-objdir.c b/tmp-objdir.c
> index 5307717354..4b91d86787 100644
> --- a/tmp-objdir.c
> +++ b/tmp-objdir.c
> @@ -148,10 +148,13 @@ static int setup_tmp_objdir(const char *root)
> {
> char *path;
> int ret = 0;
> + int saved_errno;
>
> path = xstrfmt("%s/pack", root);
> ret = mkdir(path, 0777);
> + saved_errno = errno;
> free(path);
> + errno = saved_errno;
>
> return ret;
> }
This whole function here is somewhat pointless, it's only really
required because memory handling would otherwise be awkward. That
could've been avoided if its only caller had a single return path, but
it doesn't.
No need to fix that as part of your patch series though, if you ask me.
> @@ -163,6 +166,7 @@ struct tmp_objdir *tmp_objdir_create(struct repository *r,
> struct odb_source_files *files = odb_source_files_downcast(r->objects->source);
> static int installed_handlers;
> struct tmp_objdir *t;
> + int saved_errno;
>
> if (the_tmp_objdir)
> BUG("only one tmp_objdir can be used at a time");
This could've been a local variable in each of the two blocks, but okay.
> @@ -185,8 +189,10 @@ struct tmp_objdir *tmp_objdir_create(struct repository *r,
> chdir_notify_register(tmp_objdir_reparent, t);
>
> if (!mkdtemp(t->path.buf)) {
> + saved_errno = errno;
> /* free, not destroy, as we never touched the filesystem */
> tmp_objdir_free(t);
> + errno = saved_errno;
> return NULL;
> }
>
> @@ -197,7 +203,9 @@ struct tmp_objdir *tmp_objdir_create(struct repository *r,
> }
>
> if (setup_tmp_objdir(t->path.buf)) {
> + saved_errno = errno;
> tmp_objdir_destroy(t);
> + errno = saved_errno;
> return NULL;
> }
Okay, both early returns are adapted in the same way. Makes sense.
Patrick
next prev parent reply other threads:[~2026-11-11 13:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 0:22 [PATCH 0/4] object-file: eagerly create ODB transaction temporary directory Justin Tobler
2026-11-10 0:22 ` [PATCH 1/4] object-file: rename default transaction prefix Justin Tobler
2026-11-11 13:15 ` Patrick Steinhardt
2026-11-11 14:36 ` Karthik Nayak
2026-11-10 0:22 ` [PATCH 2/4] object-file: only flush batched fsync writes when enabled Justin Tobler
2026-11-11 13:16 ` Patrick Steinhardt
2026-11-11 14:48 ` Karthik Nayak
2026-11-10 0:22 ` [PATCH 3/4] tmp-objdir: preserve errno when directory creation fails Justin Tobler
2026-11-11 13:16 ` Patrick Steinhardt [this message]
2026-11-11 16:44 ` Karthik Nayak
2026-11-10 0:22 ` [PATCH 4/4] object-file: create ODB transaction temporary directory eagerly Justin Tobler
2026-11-11 13:15 ` Patrick Steinhardt
2026-11-11 16:48 ` Karthik Nayak
2026-11-11 14:33 ` [PATCH 0/4] object-file: eagerly create ODB transaction temporary directory Karthik Nayak
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=avRqmRR29QSbj1k4@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=jltobler@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