From: Junio C Hamano <gitster@pobox.com>
To: Paul Tan <pyokagan@gmail.com>
Cc: Jeff King <peff@peff.net>,
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
git@vger.kernel.org
Subject: Re: [PATCH 1/2] git-credential-store: support XDG config dir
Date: Thu, 05 Mar 2015 10:37:16 -0800 [thread overview]
Message-ID: <xmqqk2yv47fn.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CACRoPnTBmqtB+mvx9wFG3EUDRjfrsM==GQsso6V3q9NHH1k-YA@mail.gmail.com> (Paul Tan's message of "Thu, 5 Mar 2015 14:26:39 +0800")
Paul Tan <pyokagan@gmail.com> writes:
> On Wed, Mar 4, 2015 at 7:01 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> Paul Tan <pyokagan@gmail.com> writes:
>>
>>> struct credential entry = CREDENTIAL_INIT;
>>> + int found_credential = 0;
>>>
>>> fh = fopen(fn, "r");
>>> if (!fh) {
>>> if (errno != ENOENT)
>>> die_errno("unable to open %s", fn);
>>> - return;
>>> + return 0;
>>
>> Returning found_credential here would be easier to read, no? After
>> all, that is why you explicitly initialized it to 0 up there to say
>> "no we haven't found any yet".
>
> Actually I think die_errno is a function that does not return at all.
> The return is just to shut the compiler up. Perhaps I shall comment
> that.
Commenting just on this part (I am not agreeing or disagreeing with
you on other parts of your message yet).
When fopen() fails because we cannot open an existing file for
reading, then die_errno() will trigger and we stop there, in which
case the return will not be reached.
But when we try to open fn and we fail only because fn does not
exist, we do not say "die". We instead return to the caller,
telling it that we have not found any credential so far in the file
supplied by the caller.
So the return does matter, and spelling that zero with
found_credential does matter for readability, I would think.
next prev parent reply other threads:[~2015-03-05 18:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-03 20:24 [PATCH] [GSoC15] git-credentials-store: support XDG config dir Paul Tan
2015-03-03 20:24 ` [PATCH 1/2] git-credential-store: " Paul Tan
2015-03-03 22:00 ` Matthieu Moy
2015-03-03 23:01 ` Junio C Hamano
2015-03-04 9:45 ` Jeff King
2015-03-05 6:26 ` Paul Tan
2015-03-05 18:37 ` Junio C Hamano [this message]
2015-03-06 9:57 ` Matthieu Moy
2015-03-03 20:24 ` [PATCH 2/2] tests: test credential-store XDG support Paul Tan
2015-03-03 22:08 ` Matthieu Moy
2015-03-03 23:11 ` Junio C Hamano
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=xmqqk2yv47fn.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=pyokagan@gmail.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.