From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Han-Wen Nienhuys <hanwen@google.com>,
Bagas Sanjaya <bagasdotme@gmail.com>
Subject: Re: [PATCH v3 1/3] refs API: use "failure_errno", not "errno"
Date: Thu, 13 Jan 2022 13:14:59 +0100 [thread overview]
Message-ID: <220113.86pmovvnis.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <xmqqh7a8u3my.fsf@gitster.g>
On Wed, Jan 12 2022, Junio C Hamano wrote:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> @@ -1722,8 +1722,6 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
>> if (refs_read_raw_ref(refs, refname, oid, &sb_refname,
>> &read_flags, failure_errno)) {
>> *flags |= read_flags;
>> - if (errno)
>> - *failure_errno = errno;
>
> Looks good.
>
> The whole point of passing failure_errno down to refs_read_raw_ref()
> is that we capture the reason of the failure there without having to
> rely on errno at this point in the flow. Removal of this assignment
> makes perfect sense.
>
> But ...
>
>> diff --git a/refs/files-backend.c b/refs/files-backend.c
>> index b529fdf237e..43a3b882d7c 100644
>> --- a/refs/files-backend.c
>> +++ b/refs/files-backend.c
>> @@ -382,7 +382,6 @@ static int files_read_raw_ref(struct ref_store *ref_store, const char *refname,
>> if (lstat(path, &st) < 0) {
>> int ignore_errno;
>> myerr = errno;
>> - errno = 0;
>> if (myerr != ENOENT)
>> goto out;
>> if (refs_read_raw_ref(refs->packed_ref_store, refname, oid,
>> @@ -399,7 +398,6 @@ static int files_read_raw_ref(struct ref_store *ref_store, const char *refname,
>> strbuf_reset(&sb_contents);
>> if (strbuf_readlink(&sb_contents, path, st.st_size) < 0) {
>> myerr = errno;
>> - errno = 0;
>> if (myerr == ENOENT || myerr == EINVAL)
>> /* inconsistent with lstat; retry */
>> goto stat_ref;
>> @@ -469,6 +467,7 @@ static int files_read_raw_ref(struct ref_store *ref_store, const char *refname,
>>
>> strbuf_release(&sb_path);
>> strbuf_release(&sb_contents);
>> + errno = 0;
>> return ret;
>> }
>
> ... it is not clear to me if this part makes sense. If everybody
> above the callstack uses failure_errno as the source of truth,
> clearing errno here in this function should not be necessary and is
> misleading to readers of the code, no?
It's consistent with various other existing refs* code as we made this
transition, see:
git grep -W 'errno = 0' -- 'refs*'
I.e. we'd like to not only transition existing users away from errno,
but to ensure that the file backend errno semantics don't inadvertently
leak outside the API.
Doing so is a bit pedantic for sure, but ensures that we won't need to
deal with any subtle bugs in that are with the reftable backend.
next prev parent reply other threads:[~2022-01-13 12:16 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-08 11:38 errno oversight Han-Wen Nienhuys
2021-12-08 12:47 ` Ævar Arnfjörð Bjarmason
2021-12-08 13:00 ` Ævar Arnfjörð Bjarmason
2021-12-08 19:02 ` Junio C Hamano
2021-12-09 5:02 ` [PATCH 0/3] refs: ab/refs-errno-cleanup fixup + remove "failure_errno" Ævar Arnfjörð Bjarmason
2021-12-09 5:02 ` [PATCH 1/3] refs API: use "failure_errno", not "errno" Ævar Arnfjörð Bjarmason
2021-12-09 5:02 ` [PATCH 2/3] sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failure Ævar Arnfjörð Bjarmason
2021-12-09 5:02 ` [PATCH 3/3] refs API: remove "failure_errno" from refs_resolve_ref_unsafe() Ævar Arnfjörð Bjarmason
2021-12-12 19:53 ` [PATCH v2 0/3] refs: ab/refs-errno-cleanup fixup + remove "failure_errno" Ævar Arnfjörð Bjarmason
2021-12-12 19:53 ` [PATCH v2 1/3] refs API: use "failure_errno", not "errno" Ævar Arnfjörð Bjarmason
2021-12-12 19:53 ` [PATCH v2 2/3] sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failure Ævar Arnfjörð Bjarmason
2021-12-12 19:53 ` [PATCH v2 3/3] refs API: remove "failure_errno" from refs_resolve_ref_unsafe() Ævar Arnfjörð Bjarmason
2022-01-12 12:36 ` [PATCH v3 0/3] For v2.35.0: refs: ab/refs-errno-cleanup fixup + remove "failure_errno" Ævar Arnfjörð Bjarmason
2022-01-12 12:36 ` [PATCH v3 1/3] refs API: use "failure_errno", not "errno" Ævar Arnfjörð Bjarmason
2022-01-12 19:59 ` Junio C Hamano
2022-01-13 12:14 ` Ævar Arnfjörð Bjarmason [this message]
2022-01-12 12:36 ` [PATCH v3 2/3] sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failure Ævar Arnfjörð Bjarmason
2022-01-12 20:02 ` Junio C Hamano
2022-01-12 12:36 ` [PATCH v3 3/3] refs API: remove "failure_errno" from refs_resolve_ref_unsafe() Ævar Arnfjörð Bjarmason
2022-01-12 19:34 ` [PATCH v3 0/3] For v2.35.0: refs: ab/refs-errno-cleanup fixup + remove "failure_errno" Junio C Hamano
2022-01-13 12:22 ` Ævar Arnfjörð Bjarmason
2022-01-13 18:54 ` Junio C Hamano
2022-01-14 12:21 ` Ævar Arnfjörð Bjarmason
2022-01-26 14:36 ` [PATCH v4 0/2] refs: remove the last use of "errno" from the public API Ævar Arnfjörð Bjarmason
2022-01-26 14:37 ` [PATCH v4 1/2] sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failure Ævar Arnfjörð Bjarmason
2022-01-26 23:57 ` Junio C Hamano
2022-01-26 14:37 ` [PATCH v4 2/2] refs API: remove "failure_errno" from refs_resolve_ref_unsafe() Ævar Arnfjörð Bjarmason
2021-12-08 13:05 ` errno oversight Han-Wen Nienhuys
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=220113.86pmovvnis.gmgdl@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=bagasdotme@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hanwen@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.