All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Clemens Buchacher <clemens.buchacher@intel.com>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
	"Git Mailing List" <git@vger.kernel.org>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Martin Schröder" <martin.h.schroeder@intel.com>
Subject: Re: [PATCH] git_open_noatime: return with errno=0 on success
Date: Wed, 05 Aug 2015 09:27:12 -0700	[thread overview]
Message-ID: <xmqqvbct4s67.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: 20150805143600.GA3111@musxeris015.imu.intel.com

Clemens Buchacher <clemens.buchacher@intel.com> writes:

> 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.

      reply	other threads:[~2015-08-05 16:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08 12:38 [PATCH] git_open_noatime: return with errno=0 on success Clemens Buchacher
2015-07-08 18:51 ` Eric Sunshine
2015-08-04  8:24   ` Clemens Buchacher
2015-08-04 21:03     ` Junio C Hamano
2015-08-05  8:59       ` Linus Torvalds
2015-08-05 14:36         ` Clemens Buchacher
2015-08-05 16:27           ` Junio C Hamano [this message]

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=xmqqvbct4s67.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=clemens.buchacher@intel.com \
    --cc=git@vger.kernel.org \
    --cc=martin.h.schroeder@intel.com \
    --cc=sunshine@sunshineco.com \
    --cc=torvalds@linux-foundation.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 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.