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

Re: [PATCH 3/3] fixup! reftable: add a heap-based priority queue for reftable records

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 2, 2021, 20:08 UTC
Message-ID
<xmqqeea6kaed.fsf@gitster.g>
In-Reply-To
<YTCU3F+0sKcrym6F@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 27 quoted lines
> On Wed, Sep 01, 2021 at 10:30:23PM -0700, Carlo Marcelo Arenas Belón wrote:
>
>> diff --git a/reftable/pq.c b/reftable/pq.c
>> index 8918d158e2..a6acca006b 100644
>> --- a/reftable/pq.c
>> +++ b/reftable/pq.c
>> @@ -43,12 +43,14 @@ int merged_iter_pqueue_is_empty(struct merged_iter_pqueue pq)
>>  
>>  void merged_iter_pqueue_check(struct merged_iter_pqueue pq)
>>  {
>> +#ifndef NDEBUG
>>  	int i = 0;
>>  	for (i = 1; i < pq.len; i++) {
>>  		int parent = (i - 1) / 2;
>>  
>>  		assert(pq_less(pq.heap[parent], pq.heap[i]));
>>  	}
>> +#endif
>>  }
>
> This will trigger -Wunused-parameter warnings, since the function body
> is now empty when NDEBUG is undefined. Probably switching the assert()
> to die() would be better, since the whole point of the function is just
> to exit on error.
>
> If there's a problem using die() from the reftable code, it could also
> return an error and the caller in the test helper could propagate it.

I agree that the patch as posted does not help but if this is originally an assertion, then it should never trigger in real life, so BUG() would be more appropriate than an error return, no?

Previous: Jeff KingNext: Jeff King
Message 8 of 10 in “hn/reftable: fixes for building with -DNDEBUG”
  1. 0/3 hn/reftable: fixes for building with -DNDEBUGCarlo Marcelo Arenas Belón, Sep 2, 2021
  2. 1/3 fixup! refs: RFC: Reftable support for git-coreCarlo Marcelo Arenas Belón, Sep 2, 2021
  3. Jeff KingSep 2, 2021
  4. Han-Wen NienhuysSep 2, 2021
  5. 2/3 fixup! reftable: add merged table viewCarlo Marcelo Arenas Belón, Sep 2, 2021
  6. 3/3 fixup! reftable: add a heap-based priority queue for reftable recordsCarlo Marcelo Arenas Belón, Sep 2, 2021
  7. Jeff KingSep 2, 2021
  8. Junio C HamanoSep 2, 2021
  9. Jeff KingSep 2, 2021
  10. Junio C HamanoSep 3, 2021

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.