git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] refs: remove EINVAL specification from the errno sideband in read_raw_ref_fn

From
Jeff King <peff@peff.net>
Date
Apr 23, 2021, 12:57 UTC
Message-ID
<YILENm8vZE28HyuZ@coredump.intra.peff.net>
In-Reply-To
<pull.1011.git.git.1619173446857.gitgitgadget@gmail.com>
On Fri, Apr 23, 2021 at 10:24:06AM +0000, Han-Wen Nienhuys via GitGitGadget wrote:
> Subject: refs: remove EINVAL specification from the errno sideband in read_raw_ref_fn

The subject says "read_raw_ref_fn", but the patch is touching refs_resolve_ref_unsafe(). The former is an abstract type, and I didn't dig to see the relationships, but I'll focus on the code change in the patch.

> A grep for EINVAL */*c reveals that no code inspects EINVAL after reading
> references.
I don't think that's sufficient, for two reasons:
  - in general we try to be careful about forks and topics in flight,
    which might end up with semantic conflicts. So we don't necessarily
    assume that we can see all code, and prefer if any subtle changes
    like this at least result in a compile failure (e.g., changing
    function name or signature). In practice, this is balanced with how
    likely such code is, how bad the breakage would be, what we're
    gaining, etc.
  - just because they are not looking for EINVAL specifically doesn't
    mean they are not looking at errno at all (e.g., after calling
    refs_resolve_ref_unsafe(), lock_ref_oid_basic() does so). So we have
    to set errno to _something_ after the error. After your patch, we
    don't set it at all for these error returns, and so we'll be left
    with whatever junk was in errno from a previous unrelated syscall,
    which could be very misleading. Since we have to set it to
    something, EINVAL seems like a reasonable value.

I certainly buy the argument that errno is a pretty lousy channel for passing back error data, for a number of reasons. If we were going all the way towards getting rid of errno in this function (and replacing it with something better, as we must, since some callers _do_ care about more detailed information), I could see the value. But this patch doesn't get us anywhere useful and risks regressions in the meantime.

-Peff
Previous: Han-Wen Nienhuys via GitGitGadgetNext: Han-Wen Nienhuys
Message 2 of 11 in “refs: remove EINVAL specification from the errno sideband in read_raw_ref_fn”
  1. refs: remove EINVAL specification from the errno sideband in read_raw_ref_fnHan-Wen Nienhuys via GitGitGadget, Apr 23, 2021
  2. Jeff KingApr 23, 2021
  3. Han-Wen NienhuysApr 23, 2021
  4. 0/3 refs: cleanup errno sideband ref related functions.Han-Wen Nienhuys via GitGitGadget, Apr 23, 2021
  5. 1/3 refs: remove EINVAL specification from the errno sideband in read_raw_ref_fnHan-Wen Nienhuys via GitGitGadget, Apr 23, 2021
  6. 2/3 refs/files-backend: stop setting errno from lock_ref_oid_basicHan-Wen Nienhuys via GitGitGadget, Apr 23, 2021
  7. Junio C HamanoApr 28, 2021
  8. Han-Wen NienhuysApr 28, 2021
  9. Junio C HamanoApr 29, 2021
  10. Han-Wen NienhuysApr 29, 2021
  11. 3/3 refs: make errno output explicit for read_raw_ref_fnHan-Wen Nienhuys via GitGitGadget, Apr 23, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.