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

Re: [PATCH] index-pack: fix truncation of off_t in comparison

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 4, 2015, 17:28 UTC
Message-ID
<xmqqlhfzv0wj.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20150604123541.GA8888@peff.net>
Jeff King <peff@peff.net> writes:
> On top of nd/slim-index-pack-memory-usage, which introduced the bug (but
> it is already in master).
Thanks.

In this round, I decided to deliberately merge more iffy and larger topics to 'master' in early part of the cycle, and it seems to be paying off nicely ;-).

Will queue.
Show 29 quoted lines
>  builtin/index-pack.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/index-pack.c b/builtin/index-pack.c
> index 3ed53e3..06dd973 100644
> --- a/builtin/index-pack.c
> +++ b/builtin/index-pack.c
> @@ -616,7 +616,9 @@ static int compare_ofs_delta_bases(off_t offset1, off_t offset2,
>  	int cmp = type1 - type2;
>  	if (cmp)
>  		return cmp;
> -	return offset1 - offset2;
> +	return offset1 < offset2 ? -1 :
> +	       offset1 > offset2 ?  1 :
> +	       0;
>  }
>  
>  static int find_ofs_delta(const off_t offset, enum object_type type)
> @@ -1051,7 +1053,9 @@ static int compare_ofs_delta_entry(const void *a, const void *b)
>  	const struct ofs_delta_entry *delta_a = a;
>  	const struct ofs_delta_entry *delta_b = b;
>  
> -	return delta_a->offset - delta_b->offset;
> +	return delta_a->offset < delta_b->offset ? -1 :
> +	       delta_a->offset > delta_b->offset ?  1 :
> +	       0;
>  }
>  
>  static int compare_ref_delta_entry(const void *a, const void *b)
Previous: Duy Nguyen
Message 3 of 3 in “index-pack: fix truncation of off_t in comparison”
  1. index-pack: fix truncation of off_t in comparisonJeff King, Jun 4, 2015
  2. Duy NguyenJun 4, 2015
  3. Junio C HamanoJun 4, 2015

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.