From: Junio C Hamano <gitster@pobox.com>
To: "Rubén Justo" <rjusto@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH 4/5] apply: error message in `record_ws_error()`
Date: Mon, 26 Aug 2024 17:44:39 -0700 [thread overview]
Message-ID: <xmqqjzg2eqvc.fsf@gitster.g> (raw)
In-Reply-To: <a8ce6f0d-f0f2-4467-bf16-e7ce78c6ce2d@gmail.com> ("Rubén Justo"'s message of "Sun, 25 Aug 2024 12:19:27 +0200")
Rubén Justo <rjusto@gmail.com> writes:
> It does not make sense to construct an error message if we're not
> going to use it, especially when the process involves memory
> allocations that need to be freed immediately.
>
> If we know in advance that we won't use the message, not getting it
> slightly reduces the workload and simplifies the code a bit.
Makes sense.
>
> Do it.
No need to say this when the above two paragraphs are clear enough,
like in this patch.
>
> Signed-off-by: Rubén Justo <rjusto@gmail.com>
> ---
> apply.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/apply.c b/apply.c
> index e1b4d14dba..e6df8b6ab4 100644
> --- a/apply.c
> +++ b/apply.c
> @@ -1642,8 +1642,6 @@ static void record_ws_error(struct apply_state *state,
> int len,
> int linenr)
> {
> - char *err;
> -
> if (!result)
> return;
>
> @@ -1652,11 +1650,12 @@ static void record_ws_error(struct apply_state *state,
> state->squelch_whitespace_errors < state->whitespace_error)
> return;
>
> - err = whitespace_error_string(result);
> - if (state->apply_verbosity > verbosity_silent)
> + if (state->apply_verbosity > verbosity_silent) {
> + char *err = whitespace_error_string(result);
> fprintf(stderr, "%s:%d: %s.\n%.*s\n",
> state->patch_input_file, linenr, err, len, line);
> - free(err);
> + free(err);
> + }
> }
>
> static void check_whitespace(struct apply_state *state,
next prev parent reply other threads:[~2024-08-27 0:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-25 10:09 [PATCH 0/5] `--whitespace=fix` with `--no-ignore-whitespace` Rubén Justo
2024-08-25 10:17 ` [PATCH 1/5] apply: introduce `ignore_ws_default` Rubén Justo
2024-08-27 1:11 ` Junio C Hamano
2024-08-25 10:18 ` [PATCH 2/5] apply: honor `ignore_ws_none` with `correct_ws_error` Rubén Justo
2024-08-27 0:35 ` Junio C Hamano
2024-08-29 5:07 ` Rubén Justo
2024-08-29 23:13 ` Junio C Hamano
2024-09-03 22:06 ` Rubén Justo
2024-09-04 4:41 ` Junio C Hamano
2024-09-04 18:20 ` Rubén Justo
2024-08-25 10:18 ` [PATCH 3/5] apply: whitespace errors in context lines if we have Rubén Justo
2024-08-27 0:43 ` Junio C Hamano
2024-08-27 1:49 ` Junio C Hamano
2024-08-27 16:12 ` Junio C Hamano
2024-08-27 0:51 ` Junio C Hamano
2024-08-25 10:19 ` [PATCH 4/5] apply: error message in `record_ws_error()` Rubén Justo
2024-08-27 0:44 ` Junio C Hamano [this message]
2024-08-25 10:19 ` [PATCH 5/5] t4124: move test preparation into the test context Rubén Justo
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=xmqqjzg2eqvc.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=rjusto@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 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 NNTP newsgroup(s).