From: Taylor Blau <me@ttaylorr.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] usage.[ch] API users: use report_fn, not hardcoded prototype
Date: Mon, 21 Feb 2022 13:21:12 -0500 [thread overview]
Message-ID: <YhPYGDfzdMElklX7@nand.local> (raw)
In-Reply-To: <patch-1.1-7551daf131b-20220221T160719Z-avarab@gmail.com>
On Mon, Feb 21, 2022 at 05:09:18PM +0100, Ævar Arnfjörð Bjarmason wrote:
> Change a couple of users of "report_fn" that hardcoded a definition of
> it to use the definition of report_fn instead.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>
> I'll eventually want to depend on this for a larger topic I plan to
> re-roll[1], but in the meantime this trivial fix can hopefully cook &
> graduate.
This looks good to me, thanks.
> diff --git a/run-command.c b/run-command.c
> index a8501e38ceb..3d854c498aa 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -362,10 +362,9 @@ static void NORETURN child_die_fn(const char *err, va_list params)
> /* this runs in the parent process */
> static void child_err_spew(struct child_process *cmd, struct child_err *cerr)
> {
> - static void (*old_errfn)(const char *err, va_list params);
> + report_fn old_errfn = get_error_routine();
> report_fn die_message_routine = get_die_message_routine();
Perhaps as part of the larger series you alluded to earlier, but we
could get rid of the die_message_routine variable here altogether. It
only exists to pass as the argument to set_error_routine(), and isn't
used anywhere else in the function.
So you could do something like this on top:
--- >8 ---
diff --git a/run-command.c b/run-command.c
index 3d854c498a..4afa01db9a 100644
--- a/run-command.c
+++ b/run-command.c
@@ -363,9 +363,8 @@ static void NORETURN child_die_fn(const char *err, va_list params)
static void child_err_spew(struct child_process *cmd, struct child_err *cerr)
{
report_fn old_errfn = get_error_routine();
- report_fn die_message_routine = get_die_message_routine();
- set_error_routine(die_message_routine);
+ set_error_routine(get_die_message_routine());
errno = cerr->syserr;
switch (cerr->err) {
--- 8< ---
But it doesn't need to happen here, just an idle thought I had while
reading.
Thanks,
Taylor
prev parent reply other threads:[~2022-02-21 18:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-21 16:09 [PATCH] usage.[ch] API users: use report_fn, not hardcoded prototype Ævar Arnfjörð Bjarmason
2022-02-21 18:21 ` Taylor Blau [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
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=YhPYGDfzdMElklX7@nand.local \
--to=me@ttaylorr.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).