From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Eric DeCosta via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, "Jeff Hostetler" <git@jeffhostetler.com>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Torsten Bögershausen" <tboegi@web.de>,
"Ramsay Jones" <ramsay@ramsayjones.plus.com>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Eric DeCosta" <edecosta@mathworks.com>
Subject: Re: [PATCH v12 4/6] fsmonitor: deal with synthetic firmlinks on macOS
Date: Mon, 26 Sep 2022 17:27:16 +0200 [thread overview]
Message-ID: <220926.86r0zyywp1.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <6efdc6ed74ec9224d93a1b88ff8be85d533cb30f.1664048782.git.gitgitgadget@gmail.com>
On Sat, Sep 24 2022, Eric DeCosta via GitGitGadget wrote:
> From: Eric DeCosta <edecosta@mathworks.com>
..one aspect I missed...
> + state.alias.alias = NULL;
> + state.alias.points_to = NULL;
> + if (fsmonitor__get_alias(state.path_worktree_watch.buf, &state.alias)) {
> + err = error(_("could not get worktree alias"));
> + goto done;
Okey, it errored and we call error() to say it didn't work, good so far,
but...
> +int fsmonitor__get_alias(const char *path, struct alias_info *info)
> +{
> + DIR * dir;
> + int read;
> + int retval;
...we could just...
> + struct dirent *de;
> + struct strbuf alias;
> + struct strbuf points_to;
> +
> + retval = 0;
...have initialized that above if we do it unconditionally, but more on
this below...
> + dir = opendir("/");
> + if (!dir)
> + return -1;
Here in the actual implementation, which looking at the end-state we
*only* end up calling from that one caller we could have called
error_errno() to get a better message, but didn't.
I think much better would be to skip that above entirely, or keep it you
want two errors, but then just have the more meaningful error_errno()
here, where we're closer to the error, and can report a better one.
Of course we might sometimes have a good error, and sometimes a bad one,
but...(continued below)
> +
> + strbuf_init(&alias, 256);
> + strbuf_init(&points_to, MAXPATHLEN);
> +
> + while ((de = readdir(dir)) != NULL) {
> + strbuf_reset(&alias);
> + strbuf_addch(&alias, '/');
> + strbuf_add(&alias, de->d_name, strlen(de->d_name));
> +
> + read = readlink(alias.buf, points_to.buf, MAXPATHLEN);
I think a:
if (!read)
BUG("got 0 from readlink?");
Or something would be a good paranoia addition, as you're technically
relying on...
> + if (read > 0) {
> + strbuf_setlen(&points_to, read);
> + if ((strncmp(points_to.buf, path, points_to.len) == 0)
> + && path[points_to.len] == '/') {
> + info->alias = strbuf_detach(&alias, NULL);
> + info->points_to = strbuf_detach(&points_to, NULL);
> + trace_printf_key(&trace_fsmonitor,
> + "Found alias for '%s' : '%s' -> '%s'",
> + path, info->alias, info->points_to);
> + retval = 0;
> + goto done;
> + }
> + } else if (errno != EINVAL) { /* Something other than not a link */
...the possibility that we return 0 but a stale errno happens to be set,
I don't think it'll happen in practice and that it always returned -1 if
we get here, but being strict with calling syscalls is generally good.
> + trace_printf_key(&trace_fsmonitor, "Error %s", strerror(errno));
(continued from above)..here we see the only codepath that sets retval
!= 0,
> + retval = -1;
Here we could have just called error_errno() instead.
> + * The caller owns the storage that the returned string occupies and
> + * is responsible for releasing it with `free(3)` when done.
nit: we could just put a full stop after "it" and skip the
rest. I.e. trust that the reader knows that allocated memory is freed
with free().
> + */
> +char *fsmonitor__resolve_alias(const char *path,
> + const struct alias_info *info);
> +
> +
nit: extra whitespace at end of file.
> #endif
next prev parent reply other threads:[~2022-09-26 16:49 UTC|newest]
Thread overview: 170+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-18 20:48 [PATCH] fsmonitor: option to allow fsmonitor to run against network-mounted repos Eric DeCosta via GitGitGadget
2022-08-18 21:35 ` Junio C Hamano
2022-08-18 21:38 ` Junio C Hamano
2022-08-19 10:05 ` Johannes Schindelin
2022-08-19 16:50 ` Jeff Hostetler
2022-08-19 18:38 ` Eric DeCosta
2022-08-19 20:15 ` Jeff Hostetler
2022-08-19 17:48 ` Eric Sunshine
2022-08-19 18:58 ` Torsten Bögershausen
2022-08-20 22:24 ` Junio C Hamano
2022-08-22 13:22 ` Johannes Schindelin
2022-08-22 16:07 ` Junio C Hamano
2022-08-23 13:51 ` Jeff Hostetler
2022-08-24 15:45 ` Eric DeCosta
2022-08-23 13:03 ` [PATCH v2 0/4] " Eric DeCosta via GitGitGadget
2022-08-23 13:03 ` [PATCH v2 1/4] " Eric DeCosta via GitGitGadget
2022-08-23 13:03 ` [PATCH v2 2/4] fsmonitor: macOS: " Eric DeCosta via GitGitGadget
2022-08-23 13:03 ` [PATCH v2 3/4] Check working directory and Unix domain socket file for compatability edecosta via GitGitGadget
2022-08-23 13:03 ` [PATCH v2 4/4] Minor refactoring and simplification of Windows settings checks edecosta via GitGitGadget
2022-08-23 18:55 ` [PATCH v3 0/2] fsmonitor: option to allow fsmonitor to run against network-mounted repos Eric DeCosta via GitGitGadget
2022-08-23 18:55 ` [PATCH v3 1/2] fsmonitor: macOS: " Eric DeCosta via GitGitGadget
2022-08-23 18:55 ` [PATCH v3 2/2] Check working directory and Unix domain socket file for compatability edecosta via GitGitGadget
2022-08-24 20:31 ` Junio C Hamano
2022-08-24 16:46 ` [PATCH v3 0/2] fsmonitor: option to allow fsmonitor to run against network-mounted repos Junio C Hamano
2022-08-31 16:09 ` [PATCH v4 0/4] " Eric DeCosta via GitGitGadget
2022-08-31 16:09 ` [PATCH v4 1/4] fsmonitor: add two new config options, allowRemote and socketDir Eric DeCosta via GitGitGadget
2022-08-31 19:41 ` Ævar Arnfjörð Bjarmason
2022-08-31 20:04 ` Junio C Hamano
2022-09-01 2:25 ` Ramsay Jones
2022-09-01 17:53 ` Jeff Hostetler
2022-09-01 18:04 ` Jeff Hostetler
2022-09-01 21:21 ` Jeff Hostetler
2022-09-02 16:54 ` Eric DeCosta
2022-09-06 14:27 ` Jeff Hostetler
2022-08-31 16:09 ` [PATCH v4 2/4] fsmonitor: generate unique Unix socket file name in the desired location Eric DeCosta via GitGitGadget
2022-08-31 19:49 ` Ævar Arnfjörð Bjarmason
2022-08-31 20:11 ` Junio C Hamano
2022-08-31 16:09 ` [PATCH v4 3/4] fsmonitor: ensure filesystem and unix socket filesystem are compatible Eric DeCosta via GitGitGadget
2022-08-31 16:09 ` [PATCH v4 4/4] fsmonitor: normalize FSEvents event paths to the real path Eric DeCosta via GitGitGadget
2022-08-31 19:37 ` Ævar Arnfjörð Bjarmason
2022-09-01 20:05 ` Jeff Hostetler
2022-09-02 16:35 ` Eric DeCosta
2022-09-06 17:13 ` Jeff Hostetler
2022-09-06 19:02 ` Eric DeCosta
2022-09-06 19:33 ` Eric DeCosta
2022-09-06 22:11 ` Eric DeCosta
2022-09-07 19:14 ` Jeff Hostetler
2022-09-07 23:04 ` Eric DeCosta
2022-09-10 20:00 ` [PATCH v5 0/4] fsmonitor: option to allow fsmonitor to run against network-mounted repos Eric DeCosta via GitGitGadget
2022-09-10 20:00 ` [PATCH v5 1/4] fsmonitor: refactor filesystem checks to common interface Eric DeCosta via GitGitGadget
2022-09-10 20:00 ` [PATCH v5 2/4] fsmonitor: relocate socket file if .git directory is remote Eric DeCosta via GitGitGadget
2022-09-10 20:00 ` [PATCH v5 3/4] fsmonitor: avoid socket location check if using hook Eric DeCosta via GitGitGadget
2022-09-10 20:00 ` [PATCH v5 4/4] fsmonitor: deal with synthetic firmlinks on macOS Eric DeCosta via GitGitGadget
2022-09-11 1:01 ` Eric Sunshine
2022-09-12 15:27 ` [PATCH v5 0/4] fsmonitor: option to allow fsmonitor to run against network-mounted repos Junio C Hamano
2022-09-12 19:37 ` Junio C Hamano
2022-09-12 19:39 ` Eric DeCosta
2022-09-12 15:35 ` Junio C Hamano
2022-09-12 19:35 ` Eric DeCosta
2022-09-13 20:27 ` [PATCH v6 0/6] " Eric DeCosta via GitGitGadget
2022-09-13 20:27 ` [PATCH v6 1/6] " Eric DeCosta via GitGitGadget
2022-09-13 20:27 ` [PATCH v6 2/6] fsmonitor: refactor filesystem checks to common interface Eric DeCosta via GitGitGadget
2022-09-13 20:27 ` [PATCH v6 3/6] fsmonitor: relocate socket file if .git directory is remote Eric DeCosta via GitGitGadget
2022-09-14 0:48 ` Junio C Hamano
2022-09-14 15:47 ` Eric DeCosta
2022-09-13 20:27 ` [PATCH v6 4/6] fsmonitor: avoid socket location check if using hook Eric DeCosta via GitGitGadget
2022-09-14 1:48 ` Junio C Hamano
2022-09-13 20:27 ` [PATCH v6 5/6] fsmonitor: deal with synthetic firmlinks on macOS Eric DeCosta via GitGitGadget
2022-09-13 20:27 ` [PATCH v6 6/6] fsmonitor: add documentation for allowRemote and socketDir options Eric DeCosta via GitGitGadget
2022-09-16 17:58 ` [PATCH v6 0/6] fsmonitor: option to allow fsmonitor to run against network-mounted repos Jeff Hostetler
2022-09-16 20:02 ` Eric DeCosta
2022-09-16 19:53 ` [PATCH v7 " Eric DeCosta via GitGitGadget
2022-09-16 19:53 ` [PATCH v7 1/6] fsmonitor: refactor filesystem checks to common interface Eric DeCosta via GitGitGadget
2022-09-16 19:53 ` [PATCH v7 2/6] fsmonitor: relocate socket file if .git directory is remote Eric DeCosta via GitGitGadget
2022-09-16 20:11 ` Junio C Hamano
2022-09-19 12:31 ` Jeff Hostetler
2022-09-19 16:42 ` Junio C Hamano
2022-09-19 17:08 ` Jeff Hostetler
2022-09-19 17:49 ` Junio C Hamano
2022-09-19 23:51 ` Eric DeCosta
2022-09-20 14:35 ` Jeff Hostetler
2022-09-20 15:49 ` Eric DeCosta
2022-09-16 19:53 ` [PATCH v7 3/6] fsmonitor: avoid socket location check if using hook Eric DeCosta via GitGitGadget
2022-09-16 19:53 ` [PATCH v7 4/6] fsmonitor: deal with synthetic firmlinks on macOS Eric DeCosta via GitGitGadget
2022-09-16 19:53 ` [PATCH v7 5/6] " Eric DeCosta via GitGitGadget
2022-09-16 20:15 ` Junio C Hamano
2022-09-16 19:53 ` [PATCH v7 6/6] fsmonitor: add documentation for allowRemote and socketDir options Eric DeCosta via GitGitGadget
2022-09-16 20:09 ` [PATCH v7 0/6] fsmonitor: option to allow fsmonitor to run against network-mounted repos Junio C Hamano
2022-09-17 1:12 ` [PATCH v8 0/5] " Eric DeCosta via GitGitGadget
2022-09-17 1:12 ` [PATCH v8 1/5] fsmonitor: refactor filesystem checks to common interface Eric DeCosta via GitGitGadget
2022-09-17 1:12 ` [PATCH v8 2/5] fsmonitor: relocate socket file if .git directory is remote Eric DeCosta via GitGitGadget
2022-09-17 4:13 ` Eric Sunshine
2022-09-19 16:50 ` Junio C Hamano
2022-09-17 6:29 ` Eric Sunshine
2022-09-17 16:29 ` Eric DeCosta
2022-09-19 16:58 ` Junio C Hamano
2022-09-17 1:12 ` [PATCH v8 3/5] fsmonitor: avoid socket location check if using hook Eric DeCosta via GitGitGadget
2022-09-17 1:12 ` [PATCH v8 4/5] fsmonitor: deal with synthetic firmlinks on macOS Eric DeCosta via GitGitGadget
2022-09-17 1:12 ` [PATCH v8 5/5] fsmonitor: add documentation for allowRemote and socketDir options Eric DeCosta via GitGitGadget
2022-09-17 6:08 ` Eric Sunshine
2022-09-19 23:55 ` Eric DeCosta
2022-09-19 19:37 ` [PATCH v9 0/6] fsmonitor: option to allow fsmonitor to run against network-mounted repos Eric DeCosta via GitGitGadget
2022-09-19 19:37 ` [PATCH v9 1/6] fsmonitor: refactor filesystem checks to common interface Eric DeCosta via GitGitGadget
2022-09-19 19:37 ` [PATCH v9 2/6] fsmonitor: relocate socket file if .git directory is remote Eric DeCosta via GitGitGadget
2022-09-19 19:57 ` Eric Sunshine
2022-09-19 19:37 ` [PATCH v9 3/6] fsmonitor: avoid socket location check if using hook Eric DeCosta via GitGitGadget
2022-09-19 19:37 ` [PATCH v9 4/6] fsmonitor: deal with synthetic firmlinks on macOS Eric DeCosta via GitGitGadget
2022-09-19 19:37 ` [PATCH v9 5/6] fsmonitor: check for compatability before communicating with fsmonitor Eric DeCosta via GitGitGadget
2022-09-19 19:37 ` [PATCH v9 6/6] fsmonitor: add documentation for allowRemote and socketDir options Eric DeCosta via GitGitGadget
2022-09-20 20:33 ` [PATCH v10 0/6] fsmonitor: option to allow fsmonitor to run against network-mounted repos Eric DeCosta via GitGitGadget
2022-09-20 20:33 ` [PATCH v10 1/6] fsmonitor: refactor filesystem checks to common interface Eric DeCosta via GitGitGadget
2022-09-20 20:33 ` [PATCH v10 2/6] fsmonitor: relocate socket file if .git directory is remote Eric DeCosta via GitGitGadget
2022-09-20 20:33 ` [PATCH v10 3/6] fsmonitor: avoid socket location check if using hook Eric DeCosta via GitGitGadget
2022-09-20 20:33 ` [PATCH v10 4/6] fsmonitor: deal with synthetic firmlinks on macOS Eric DeCosta via GitGitGadget
2022-09-20 20:33 ` [PATCH v10 5/6] fsmonitor: check for compatability before communicating with fsmonitor Eric DeCosta via GitGitGadget
2022-09-21 11:22 ` Jeff Hostetler
2022-09-21 13:03 ` Eric DeCosta
2022-09-20 20:33 ` [PATCH v10 6/6] fsmonitor: add documentation for allowRemote and socketDir options Eric DeCosta via GitGitGadget
2022-09-21 22:18 ` [PATCH v11 0/6] fsmonitor: option to allow fsmonitor to run against network-mounted repos Eric DeCosta via GitGitGadget
2022-09-21 22:18 ` [PATCH v11 1/6] fsmonitor: refactor filesystem checks to common interface Eric DeCosta via GitGitGadget
2022-09-21 22:18 ` [PATCH v11 2/6] fsmonitor: relocate socket file if .git directory is remote Eric DeCosta via GitGitGadget
2022-09-21 22:18 ` [PATCH v11 3/6] fsmonitor: avoid socket location check if using hook Eric DeCosta via GitGitGadget
2022-09-21 22:18 ` [PATCH v11 4/6] fsmonitor: deal with synthetic firmlinks on macOS Eric DeCosta via GitGitGadget
2022-09-21 22:18 ` [PATCH v11 5/6] fsmonitor: check for compatability before communicating with fsmonitor Eric DeCosta via GitGitGadget
2022-09-21 22:18 ` [PATCH v11 6/6] fsmonitor: add documentation for allowRemote and socketDir options Eric DeCosta via GitGitGadget
2022-09-24 19:46 ` [PATCH v12 0/6] fsmonitor: option to allow fsmonitor to run against network-mounted repos Eric DeCosta via GitGitGadget
2022-09-24 19:46 ` [PATCH v12 1/6] fsmonitor: refactor filesystem checks to common interface Eric DeCosta via GitGitGadget
2022-09-24 19:46 ` [PATCH v12 2/6] fsmonitor: relocate socket file if .git directory is remote Eric DeCosta via GitGitGadget
2022-09-24 19:46 ` [PATCH v12 3/6] fsmonitor: avoid socket location check if using hook Eric DeCosta via GitGitGadget
2022-09-24 19:46 ` [PATCH v12 4/6] fsmonitor: deal with synthetic firmlinks on macOS Eric DeCosta via GitGitGadget
2022-09-26 15:16 ` Ævar Arnfjörð Bjarmason
2022-09-27 1:53 ` Eric DeCosta
2022-09-26 15:27 ` Ævar Arnfjörð Bjarmason [this message]
2022-09-24 19:46 ` [PATCH v12 5/6] fsmonitor: check for compatability before communicating with fsmonitor Eric DeCosta via GitGitGadget
2022-09-25 14:00 ` Eric DeCosta
2022-09-26 15:23 ` Ævar Arnfjörð Bjarmason
2022-09-27 1:25 ` Eric DeCosta
2022-09-24 19:46 ` [PATCH v12 6/6] fsmonitor: add documentation for allowRemote and socketDir options Eric DeCosta via GitGitGadget
2022-09-26 15:11 ` Ævar Arnfjörð Bjarmason
2022-09-27 2:16 ` Eric Sunshine
2022-09-27 4:03 ` Eric DeCosta
2022-09-25 14:18 ` [PATCH v12 0/6] fsmonitor: option to allow fsmonitor to run against network-mounted repos Eric DeCosta
2022-09-27 20:57 ` [PATCH v13 " Eric DeCosta via GitGitGadget
2022-09-27 20:57 ` [PATCH v13 1/6] fsmonitor: refactor filesystem checks to common interface Eric DeCosta via GitGitGadget
2022-09-27 20:57 ` [PATCH v13 2/6] fsmonitor: relocate socket file if .git directory is remote Eric DeCosta via GitGitGadget
2022-09-27 20:57 ` [PATCH v13 3/6] fsmonitor: avoid socket location check if using hook Eric DeCosta via GitGitGadget
2022-09-27 20:57 ` [PATCH v13 4/6] fsmonitor: deal with synthetic firmlinks on macOS Eric DeCosta via GitGitGadget
2022-09-28 5:55 ` Ævar Arnfjörð Bjarmason
2022-09-27 20:57 ` [PATCH v13 5/6] fsmonitor: check for compatability before communicating with fsmonitor Eric DeCosta via GitGitGadget
2022-09-27 20:57 ` [PATCH v13 6/6] fsmonitor: add documentation for allowRemote and socketDir options Eric DeCosta via GitGitGadget
2022-09-28 20:12 ` [PATCH v14 0/6] fsmonitor: option to allow fsmonitor to run against network-mounted repos Eric DeCosta via GitGitGadget
2022-09-28 20:12 ` [PATCH v14 1/6] fsmonitor: refactor filesystem checks to common interface Eric DeCosta via GitGitGadget
2022-09-28 20:12 ` [PATCH v14 2/6] fsmonitor: relocate socket file if .git directory is remote Eric DeCosta via GitGitGadget
2022-09-28 20:12 ` [PATCH v14 3/6] fsmonitor: avoid socket location check if using hook Eric DeCosta via GitGitGadget
2022-09-28 20:12 ` [PATCH v14 4/6] fsmonitor: deal with synthetic firmlinks on macOS Eric DeCosta via GitGitGadget
2022-09-28 20:12 ` [PATCH v14 5/6] fsmonitor: check for compatability before communicating with fsmonitor Eric DeCosta via GitGitGadget
2022-09-28 20:12 ` [PATCH v14 6/6] fsmonitor: add documentation for allowRemote and socketDir options Eric DeCosta via GitGitGadget
2022-10-04 17:32 ` [PATCH v15 0/6] fsmonitor: option to allow fsmonitor to run against network-mounted repos Eric DeCosta via GitGitGadget
2022-10-04 17:32 ` [PATCH v15 1/6] fsmonitor: refactor filesystem checks to common interface Eric DeCosta via GitGitGadget
2023-01-30 9:37 ` Ævar Arnfjörð Bjarmason
2022-10-04 17:32 ` [PATCH v15 2/6] fsmonitor: relocate socket file if .git directory is remote Eric DeCosta via GitGitGadget
2023-01-30 9:58 ` Ævar Arnfjörð Bjarmason
2022-10-04 17:32 ` [PATCH v15 3/6] fsmonitor: avoid socket location check if using hook Eric DeCosta via GitGitGadget
2022-10-04 17:32 ` [PATCH v15 4/6] fsmonitor: deal with synthetic firmlinks on macOS Eric DeCosta via GitGitGadget
2023-01-30 10:08 ` Ævar Arnfjörð Bjarmason
2022-10-04 17:32 ` [PATCH v15 5/6] fsmonitor: check for compatability before communicating with fsmonitor Eric DeCosta via GitGitGadget
2022-10-04 17:32 ` [PATCH v15 6/6] fsmonitor: add documentation for allowRemote and socketDir options Eric DeCosta via GitGitGadget
2023-01-30 10:04 ` Ævar Arnfjörð Bjarmason
2022-10-05 18:05 ` [PATCH v15 0/6] fsmonitor: option to allow fsmonitor to run against network-mounted repos Junio C Hamano
2022-10-05 21:14 ` Eric DeCosta
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=220926.86r0zyywp1.gmgdl@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=edecosta@mathworks.com \
--cc=git@jeffhostetler.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=ramsay@ramsayjones.plus.com \
--cc=sunshine@sunshineco.com \
--cc=tboegi@web.de \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).