Re: [PATCH v9 04/41] builtin/apply: read_patch_file() return -1 instead of die()ing
- From
Stefan Beller <sbeller@google.com>
- Date
- Aug 1, 2016, 16:24 UTC
- Message-ID
- <CAGZ79kaijAFndjxUd93a49No1AwCx-VzFcwKhkrQNjdmyxodwQ@mail.gmail.com>
- In-Reply-To
- <20160730172509.22939-5-chriscool@tuxfamily.org>
On Sat, Jul 30, 2016 at 10:24 AM, Christian Couder <christian.couder@gmail.com> wrote:
Show 6 quoted lines
> -static void read_patch_file(struct strbuf *sb, int fd)
> +static int read_patch_file(struct strbuf *sb, int fd)
> {
> if (strbuf_read(sb, fd, 0) < 0)
> - die_errno("git apply: failed to read");
> + return error_errno("git apply: failed to read");which always returns -1.
Show 6 quoted lines
> @@ -4425,7 +4426,8 @@ static int apply_patch(struct apply_state *state, > int res = 0; > > state->patch_input_file = filename; > - read_patch_file(&buf, fd); > + if (read_patch_file(&buf, fd))
In case a reroll turns out to be needed, check for "read_patch_file(..) < 0" here, as we only want to error out in case of errors from that function? The return value of read_patch_file, is not documented as it seems trivial at the moment, i.e.
0 for success negative values for errors positive values are currently not returned, but are reserved for future use?
The current implementation is correct as-is, though I think we follow the "negative values indicate a serious error and positive values are to be expected, and not necessarily an error" pattern in lots of other places, so we could here as well.