From: Jonathan Nieder <jrnieder@gmail.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: ERANGE strikes again on my Windows build; RFH
Date: Mon, 30 Dec 2019 10:06:53 -0800 [thread overview]
Message-ID: <20191230180653.GA57251@google.com> (raw)
In-Reply-To: <6eb02a73-9dcb-f1fc-f015-80e71e9910d6@kdbg.org>
Hi,
Johannes Sixt wrote:
> In sha1-file.c:read_object_file_extended() we have the following pattern:
>
> errno = 0;
> data = read_object(r, repl, type, size);
> if (data)
> return data;
>
> if (errno && errno != ENOENT)
> die_errno(_("failed to read object %s"), oid_to_hex(oid));
>
> That is, it is expected that read_object() does not change the value of
> errno in the non-error case. I find it intriguing that we expect a quite
> large call graph that is behind read_object() to behave this way.
Yes, this seems dubious.
In fact this is only inspecting errno in the returned-NULL case. If I
look only at the code above and not at the implementation of
read_object, then I would say that the bug is the 'errno &&' part: when
errno is meaningful for a function for a given return value, the usual
convention is
(1) it *always* sets errno for errors, not conditionally
(2) it never sets errno to 0
There are some exceptions (like strtoul) but they are few and
unfortunate, not something to be imitated.
Do you have more details about the case where read_object is expected
to produce errno == 0? I'm wondering whether we forgot to set 'errno
= ENOENT' explicitly somewhere.
Thanks and hope that helps,
Jonathan
next prev parent reply other threads:[~2019-12-30 18:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-28 15:41 ERANGE strikes again on my Windows build; RFH Johannes Sixt
2019-12-29 14:29 ` Torsten Bögershausen
2019-12-29 14:43 ` Andreas Schwab
2019-12-29 17:25 ` Alban Gruin
2019-12-29 18:08 ` Johannes Sixt
2019-12-30 17:42 ` Junio C Hamano
2019-12-30 18:06 ` Jonathan Nieder [this message]
2019-12-30 18:46 ` Johannes Sixt
2019-12-30 18:49 ` Jonathan Nieder
2020-01-05 15:27 ` Michal Suchánek
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=20191230180653.GA57251@google.com \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
/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).