From: "René Scharfe" <l.s.r@web.de>
To: "Martin Ågren" <martin.agren@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] help: make help_unknown_ref() NORETURN
Date: Thu, 29 Aug 2019 22:08:18 +0200 [thread overview]
Message-ID: <bde881b6-7c23-6f4e-5cb0-a793a5e4f5d7@web.de> (raw)
In-Reply-To: <CAN0heSp4bdJt4NKELOkvdpoygbkNZVn-96FrZnu9ymE5UNOSag@mail.gmail.com>
Am 29.08.19 um 21:40 schrieb Martin Ågren:
> On Thu, 29 Aug 2019 at 21:15, René Scharfe <l.s.r@web.de> wrote:
>> diff --git a/help.h b/help.h
>> index b8780fbd0f..7a455beeb7 100644
>> --- a/help.h
>> +++ b/help.h
>> @@ -42,8 +42,8 @@ void list_commands(unsigned int colopts, struct cmdnames *main_cmds, struct cmdn
>> /*
>> * call this to die(), when it is suspected that the user mistyped a
>> * ref to the command, to give suggested "correct" refs.
>> */
>> -void help_unknown_ref(const char *ref, const char *cmd, const char *error);
>> +NORETURN void help_unknown_ref(const char *ref, const char *cmd, const char *error);
>
> Funny how this claims we'll call `die()`, when we'll actually call
> `exit(1)`.
Ah, I didn't even notice that.
> If we actually did call `die()`, I suppose the compiler
> should/could figure out by itself that this function, too, won't ever
> return.
The compiler can figure it out with exit(), too; system headers (at
least for glibc, but it's probably common) assign it the noreturn
attribute. But there is no way to transmit that information to callers
across compilation units if not for the header file, right?
> I wonder whether the real bug here is that the implementation calls
> `exit(1)`, not `die()`. That is, the exit code is wrong (1 != 128) and
> we're missing out on the flexibility offered by `set_die_routine()`. If
> not that, then I'd say the documentation is buggy. Hm?
This inconsistency has been present since e56181060e ("help: add
help_unknown_ref()", 2013-05-04). Using die() is going to be difficult
due to the multi-line suggestions printed by the function.
René
next prev parent reply other threads:[~2019-08-29 20:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-29 19:13 [PATCH] help: make help_unknown_ref() NORETURN René Scharfe
2019-08-29 19:40 ` Martin Ågren
2019-08-29 20:08 ` René Scharfe [this message]
2019-08-30 3:50 ` Martin Ågren
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bde881b6-7c23-6f4e-5cb0-a793a5e4f5d7@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=martin.agren@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).