Re: [PATCH 06/11] streaming: a new API to read from the object store
- From
Jeff King <peff@peff.net>
- Date
- May 18, 2011, 08:09 UTC
- Message-ID
- <20110518080947.GE27482@sigill.intra.peff.net>
- In-Reply-To
- <1305505831-31587-7-git-send-email-gitster@pobox.com>
On Sun, May 15, 2011 at 05:30:26PM -0700, Junio C Hamano wrote:
Show 22 quoted lines
> +struct git_istream *open_istream(const unsigned char *sha1,
> + enum object_type *type,
> + unsigned long *sz)
> +{
> + struct git_istream *st;
> + struct object_info oi;
> + const unsigned char *real = lookup_replace_object(sha1);
> + enum input_source src = istream_source(real, type, &oi);
> +
> + if (src < 0)
> + return NULL;
> +
> + st = xmalloc(sizeof(*st));
> + st->source = src;
> + if (open_istream_tbl[src](st, &oi, real, type, sz)) {
> + if (open_istream_incore(st, &oi, real, type, sz)) {
> + free(st);
> + st = NULL;
> + }
> + }
> + return st;
> +}I assume the "sz" parameter is meant to be an output parameter with the total size of the object. The open_istream_incore function fills it in properly. But later, when you add open_istream_loose and open_istream_pack_non_delta, neither of them actually touches the "sz" parameter at all. So code like:
struct git_istream *st; enum object_type type; unsigned long size; st = open_istream(sha1, &type, &size);
may or may not have "size" meaningful at this point, which seems like a bug.
-Peff