From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Derrick Stolee <derrickstolee@github.com>
Cc: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>,
"Derrick Stolee" <stolee@gmail.com>,
"Renato Botelho" <garga@freebsd.org>,
"Todd Zullinger" <tmz@pobox.com>,
"Đoàn Trần Công Danh" <congdanhqx@gmail.com>
Subject: Re: [PATCH] gc: use temporary file for editing crontab
Date: Tue, 23 Aug 2022 21:15:28 +0000 [thread overview]
Message-ID: <YwVDcO/V+zx2iy4I@tapette.crustytoothpaste.net> (raw)
In-Reply-To: <9e737b4b-4a17-09d5-6452-4ca5eef3d9da@github.com>
[-- Attachment #1: Type: text/plain, Size: 2031 bytes --]
On 2022-08-23 at 17:06:03, Derrick Stolee wrote:
> On 8/23/2022 5:12 AM, Johannes Schindelin wrote:
> > Hi brian,
> >
> > On Tue, 23 Aug 2022, brian m. carlson wrote:
>
> >> + tmpedit = mks_tempfile_t(".git_cron_edit_tmpXXXXXX");
> >> + if (!tmpedit)
> >> + return error(_("failed to create crontab temporary file"));
> >
> > It might make sense to use the same `goto out;` pattern here, to make it
> > easier to reason about the early exit even six years from now.
> >
> > We do not even have to guard the `close_tempfile_gently()` behind an `if
> > (tempfile)` conditional because that function handles `NULL` parameters
> > gently.
I can do that. I'll need to make sure we initialize the pointer to NULL
first.
> This is focused only on the cron integration, which is not used on Windows,
> so I'm not worried about that.
Correct. The only place this could go wrong is Cygwin, but I believe it
has the proper behaviour (and if not, lots of stuff will be broken).
> I was initially worried that we lost the fclose(cron_in), but of course it
> is handled by the close_tempfile_gently() at the end.
Yup. I originally called fclose here and glibc screamed at me about a
double-free, so the fclose definitely should be removed. I'll mention
this in the commit message as well.
> Here's the crux of the matter: we are no longer using stdin but
> instead passing an argument to point to a file with our desired
> schedule. I tested that this worked on my machine, and I'm glad
> this use is the POSIX standard.
>
> There is something wrong with this patch: it needs to update
> t/helper/test-crontab.c in order to pass t7900-maintenance.sh.
Will fix.
> While the memory release is nice, I also think it would be good to use
> delete_tempfile() so the temporary file is deleted within this method,
> not waiting until the end of the process to do that cleanup.
Sounds good. I'll include that in a v2.
--
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
next prev parent reply other threads:[~2022-08-23 21:15 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-12 13:51 git maintenance broken on FreeBSD Renato Botelho
2022-08-12 14:44 ` Đoàn Trần Công Danh
2022-08-13 3:42 ` Todd Zullinger
2022-08-13 5:02 ` Junio C Hamano
2022-08-13 15:37 ` Đoàn Trần Công Danh
2022-08-13 17:26 ` Junio C Hamano
2022-08-13 17:35 ` brian m. carlson
2022-08-15 13:22 ` Derrick Stolee
2022-08-15 16:09 ` Junio C Hamano
2022-08-23 1:01 ` [PATCH] gc: use temporary file for editing crontab brian m. carlson
2022-08-23 9:12 ` Johannes Schindelin
2022-08-23 17:06 ` Derrick Stolee
2022-08-23 21:15 ` brian m. carlson [this message]
2022-08-24 16:06 ` Junio C Hamano
2022-08-28 21:41 ` [PATCH v2] " brian m. carlson
2022-08-29 6:46 ` Junio C Hamano
2022-08-29 10:52 ` Renato Botelho
2022-08-30 13:27 ` Derrick Stolee
2022-08-30 20:40 ` [PATCH] test-crontab: minor memory and error handling fixes Jeff King
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=YwVDcO/V+zx2iy4I@tapette.crustytoothpaste.net \
--to=sandals@crustytoothpaste.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=congdanhqx@gmail.com \
--cc=derrickstolee@github.com \
--cc=garga@freebsd.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=stolee@gmail.com \
--cc=tmz@pobox.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).