Re: [PATCH v9 04/41] builtin/apply: read_patch_file() return -1 instead of die()ing
From: Stefan Beller <hidden>
Date: 2016-08-01 16:31:08
On Sat, Jul 30, 2016 at 10:24 AM, Christian Couder [off-list ref] wrote:
-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.
quoted hunk ↗ jump to hunk
@@ -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.