Re: [PATCH 1/4] wrapper: add git_mkdtemp()
- From
Chris Torek <chris.torek@gmail.com>
- Date
- Dec 4, 2025, 11:51 UTC
- Message-ID
- <CAPx1GvfAFLZz_SA+mBe7o8Cu4sL0_U5zzerhpev=sp4asEwcPw@mail.gmail.com>
- In-Reply-To
- <65c997a7-e480-4617-a761-fc9dc8a7b20d@web.de>
fairly trivial, but:
On Wed, Dec 3, 2025 at 2:52 AM René Scharfe <l.s.r@web.de> wrote:
> Extend git_mkstemps_mode() to optionally call mkdir(2) instead of > open(2), then use that ability to create a mkdtemp(3) replacement, > git_mkdtemp(). We'll start using it in the next commit.
[snip]
Show 5 quoted lines
> - fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode); > + if (dir) > + fd = mkdir(pattern, mode); > + else > + fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
mkdir() returns a success (0) / fail (-1) indication, rather than a file descriptor, so this is kind of misleading. I think a comment mentioning it would suffice (but also be a good idea, lest someone later think it needs a close() call).
Chris