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

Re: [PATCH] git_open_noatime: return with errno=0 on success

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 5, 2015, 16:27 UTC
Message-ID
<xmqqvbct4s67.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20150805143600.GA3111@musxeris015.imu.intel.com>
Clemens Buchacher <clemens.buchacher@intel.com> writes:
Show 28 quoted lines
> On Wed, Aug 05, 2015 at 10:59:09AM +0200, Linus Torvalds wrote:
> ...
>> A stale 'errno' generally shouldn't matter, because we either
>> 
>>  (a) return success (and nobody should look at errno)
>> 
>> or
>> 
>>  (b) return an error later, without setting errno for that _later_ error.
>> 
>> and I think either of those two situations are the real bug, and this
>> "clear stale errno" is just a workaround.
>
> I agree. But I do not see how to get there easily.
>
> We are trying to read an object. We first try to read from a pack. We
> may encounter broken pack files, missing index files, unreadable files,
> but those errors are not necessarily fatal since we may still be able to
> read the object from the next pack file or from a sha1 file.
>
> If finally we do not find the object anywhere, in
> read_sha1_file_extended we try our best to die with an appropriate error
> message, for example by looking at errno, and otherwise we just return
> NULL. Most callers seem to die explicitly or they dereference the null
> pointer.
>
> I think we should instead output error messages closer to the source,
> like for example in map_sha1_file, but continue anyway.

Hmm, if we find one data source unreadable but an alternative usable, do we really want that error message? What should it say? "error: cannot read from pack"? Such a message, unless we later give "info: but we managed to read it from elsewhere" and make sure these two messages are clearly associated with each other, would make things unnecessarily alarming, wouldn't it?

Perhaps we should not rely so heavily on 'errno', but explicitly pass around error code (or enough information to formulate an intelligent message at the end) in the callchain instead.

Then the earlier part can notice EPERM on a pack, for example, and return to the caller, and after consulting an alternate data source (e.g. loose object file), the caller can then choose to say "we managed to read the data, but FYI, you may want to check the permission bits of this pack", or choose to stay silent.

Previous: Clemens Buchacher
Message 7 of 7 in “git_open_noatime: return with errno=0 on success”
  1. git_open_noatime: return with errno=0 on successClemens Buchacher, Jul 8, 2015
  2. Eric SunshineJul 8, 2015
  3. git_open_noatime: return with errno=0 on successClemens Buchacher, Aug 4, 2015
  4. Junio C HamanoAug 4, 2015
  5. Linus TorvaldsAug 5, 2015
  6. Clemens BuchacherAug 5, 2015
  7. Junio C HamanoAug 5, 2015

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.