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

Re: [PATCH] prio-queue: use size_t rather than int for size

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 20, 2024, 15:27 UTC
Message-ID
<xmqqh66yfk89.fsf@gitster.g>
In-Reply-To
<20241220085337.GA133148@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 17 quoted lines
> On Fri, Dec 20, 2024 at 03:49:49AM -0500, Jeff King wrote:
>
>> -static inline int compare(struct prio_queue *queue, int i, int j)
>> +static inline int compare(struct prio_queue *queue, size_t i, size_t j)
>>  {
>>  	int cmp = queue->compare(queue->array[i].data, queue->array[j].data,
>>  				 queue->cb_data);
>>  	if (!cmp)
>> -		cmp = queue->array[i].ctr - queue->array[j].ctr;
>> +		cmp = (queue->array[i].ctr > queue->array[j].ctr) -
>> +	              (queue->array[i].ctr < queue->array[j].ctr);
>>  	return cmp;
>>  }
>
> Sorry, just realized that "diff --check" (and apply) complains about the
> indentation here. It's a TAB followed by 14 spaces, instead of two TABs
> followed by 6 spaces. I guess caused by me lining things up manually.

"git am --whitespace=fix" with or without "-3" corrects such glitches just fine, and "git am --whitespace=error" correctly stops me from applying such a patch.

What is worrysome is "git am -3 --whitespace=warn" does not seem to catch it (without "-3" it works just fine). I do not know offhand if this is a recent regression or not.

Previous: Jeff KingNext: Jeff King
Message 3 of 6 in “prio-queue: use size_t rather than int for size”
  1. prio-queue: use size_t rather than int for sizeJeff King, Dec 20, 2024
  2. Jeff KingDec 20, 2024
  3. Junio C HamanoDec 20, 2024
  4. Jeff KingDec 20, 2024
  5. Patrick SteinhardtDec 27, 2024
  6. Jeff KingDec 27, 2024

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.