Re: [PATCH v9 04/41] builtin/apply: read_patch_file() return -1 instead of die()ing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jul 30, 2016 at 10:24 AM, Christian Couder
<christian.couder@xxxxxxxxx> 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.

> @@ -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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]