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

Re: [PATCH v2 1/4] streaming: allow to call close_istream(NULL);

From
Junio C Hamano <gitster@pobox.com>
Date
May 18, 2012, 21:02 UTC
Message-ID
<xmqqobpl2oep.fsf@junio.mtv.corp.google.com>
In-Reply-To
<1337169731-23416-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
> This makes it more convenient in cleanup code, like free(NULL).

If the justification were "like fclose(NULL)", it have made more sense, but fclose(NULL) does not silently turn itself into a successful no-op. You are expected to check the returned value from the matching function (i.e. fopen()) and do not call it. So taking this patch alone, I smell a bad design taste.

Show 18 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  streaming.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/streaming.c b/streaming.c
> index 3a3cd12..38b39cd 100644
> --- a/streaming.c
> +++ b/streaming.c
> @@ -94,7 +94,7 @@ struct git_istream {
>  
>  int close_istream(struct git_istream *st)
>  {
> -	int r = st->vtbl->close(st);
> +	int r = st ? st->vtbl->close(st) : 0;
>  	free(st);
>  	return r;
>  }
Previous: Nguyễn Thái Ngọc Duy
Message 16 of 16 in “pack-objects: use streaming interface for reading large loose blobs”
  1. pack-objects: use streaming interface for reading large loose blobsNguyễn Thái Ngọc Duy, May 12, 2012
  2. Nicolas PitreMay 12, 2012
  3. pack-objects: use streaming interface for reading large loose blobsNguyễn Thái Ngọc Duy, May 13, 2012
  4. Junio C HamanoMay 14, 2012
  5. Junio C HamanoMay 14, 2012
  6. Nguyen Thai Ngoc DuyMay 15, 2012
  7. Junio C HamanoMay 15, 2012
  8. Nguyen Thai Ngoc DuyMay 16, 2012
  9. 1/4 streaming: allow to call close_istream(NULL);Nguyễn Thái Ngọc Duy, May 16, 2012
  10. 2/4 pack-objects, streaming: turn "xx >= big_file_threshold" to ".. > .."Nguyễn Thái Ngọc Duy, May 16, 2012
  11. Junio C HamanoMay 18, 2012
  12. 3/4 pack-objects: refactor write_object()Nguyễn Thái Ngọc Duy, May 16, 2012
  13. Junio C HamanoMay 18, 2012
  14. Nicolas PitreMay 19, 2012
  15. 4/4 pack-objects: use streaming interface for reading large loose blobsNguyễn Thái Ngọc Duy, May 16, 2012
  16. Junio C HamanoMay 18, 2012

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.