git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] builtin/apply: exit when parse_binary() fails

From
Christian Couder <christian.couder@gmail.com>
Date
Mar 16, 2016, 20:19 UTC
Message-ID
<CAP8UFD2OxW0nDfm6P4qXkJb2BORg_r=4ZS_cVtv16YnA115w9A@mail.gmail.com>
In-Reply-To
<xmqqshzq438s.fsf@gitster.mtv.corp.google.com>
On Wed, Mar 16, 2016 at 8:44 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 19 quoted lines
> Christian Couder <christian.couder@gmail.com> writes:
>
>> In parse_binary() there is:
>>
>>       forward = parse_binary_hunk(&buffer, &size, &status, &used);
>>       if (!forward && !status)
>>               /* there has to be one hunk (forward hunk) */
>>               return error(_("unrecognized binary patch at line %d"), linenr-1);
>>
>> so parse_binary() can return -1, because that's what error() returns.
>>
>> Also parse_binary_hunk() sets "status" to -1 in case of error and
>> parse_binary() does "if (status) return status;".
>
> All of the above sounds sensible, and your follow-up patch expects
> parse_chunk() to return -1 on failure--it is a bit sad that you make
> parse_chunk() to directly call exit(2).  In the spirit of eventually
> libifying this codepath, shouldn't we be turning existing die() to
> an error return, instead of introducing more calls to exit(2)?

Yeah, I found these little bugs when working on libifying these functions. So I agree that it is sad to introduce an exit() call now and I am ok to make parse_chunk() return -1 instead.

I will resend with that change.

Thanks, Christian.

Previous: Junio C Hamano
Message 3 of 3 in “builtin/apply: exit when parse_binary() fails”
  1. builtin/apply: exit when parse_binary() failsChristian Couder, Mar 16, 2016
  2. Junio C HamanoMar 16, 2016
  3. Christian CouderMar 16, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.