Re: [PATCH 05/11] mailsplit: move NULL check before first use of file handle
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 10, 2026, 03:31 UTC
- Message-ID
- <xmqq8q7jh66h.fsf@gitster.g>
- In-Reply-To
- <41eef047ae6e3c332e1c8f96a9f9abf55d5004fc.1783590159.git.gitgitgadget@gmail.com>
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 22 quoted lines
> diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
> index 264df6259a..0993418e63 100644
> --- a/builtin/mailsplit.c
> +++ b/builtin/mailsplit.c
> @@ -225,14 +225,14 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
> FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "r");
> int file_done = 0;
>
> - if (isatty(fileno(f)))
> - warning(_("reading patches from stdin/tty..."));
> -
> if (!f) {
> error_errno("cannot open mbox %s", file);
> goto out;
> }
>
> + if (isatty(fileno(f)))
> + warning(_("reading patches from stdin/tty..."));
> +
> do {
> peek = fgetc(f);
> if (peek == EOF) {Ah, obviously correct. Cannot believe nobody noticed this since it was first written in 7b20af6a06 (am/apply: warn if we end up reading patches from terminal, 2022-03-03).
Thanks.