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

Re: [PATCH 4/4] t-reftable-merged: check realloc errors

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 27, 2024, 05:46 UTC
Message-ID
<xmqqplldvfsk.fsf@gitster.g>
In-Reply-To
<6084c017-9557-478b-b485-a1c1a21842e7@web.de>
René Scharfe <l.s.r@web.de> writes:
> Report reallocation errors in unit tests, like everywhere else.
OK.  That's good for consistency if anything else.

We have a test framework for doing unit test at such low level, yet we cannot really write tests that validates that the right thing happens when a particular realloc() call returns NULL, which feels somewhat disappointing, but that is not a fault of this series.

Thanks.
Show 30 quoted lines
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
>  t/unit-tests/t-reftable-merged.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/unit-tests/t-reftable-merged.c b/t/unit-tests/t-reftable-merged.c
> index a12bd0e1a3..60836f80d6 100644
> --- a/t/unit-tests/t-reftable-merged.c
> +++ b/t/unit-tests/t-reftable-merged.c
> @@ -178,7 +178,7 @@ static void t_merged_refs(void)
>  		if (err > 0)
>  			break;
>
> -		REFTABLE_ALLOC_GROW(out, len + 1, cap);
> +		check(!REFTABLE_ALLOC_GROW(out, len + 1, cap));
>  		out[len++] = ref;
>  	}
>  	reftable_iterator_destroy(&it);
> @@ -459,7 +459,7 @@ static void t_merged_logs(void)
>  		if (err > 0)
>  			break;
>
> -		REFTABLE_ALLOC_GROW(out, len + 1, cap);
> +		check(!REFTABLE_ALLOC_GROW(out, len + 1, cap));
>  		out[len++] = log;
>  	}
>  	reftable_iterator_destroy(&it);
> --
> 2.47.1
Previous: René ScharfeNext: Patrick Steinhardt
Message 13 of 25 in “reftable: fix realloc error handling”
  1. 0/4 reftable: fix realloc error handlingRené Scharfe, Dec 25, 2024
  2. 1/4 reftable: avoid leaks on realloc errorRené Scharfe, Dec 25, 2024
  3. Junio C HamanoDec 27, 2024
  4. Patrick SteinhardtDec 27, 2024
  5. René ScharfeDec 27, 2024
  6. Patrick SteinhardtDec 30, 2024
  7. 2/4 reftable: fix allocation count on realloc errorRené Scharfe, Dec 25, 2024
  8. Patrick SteinhardtDec 27, 2024
  9. René ScharfeDec 27, 2024
  10. René ScharfeDec 27, 2024
  11. 3/4 reftable: handle realloc error in parse_names()René Scharfe, Dec 25, 2024
  12. 4/4 t-reftable-merged: check realloc errorsRené Scharfe, Dec 25, 2024
  13. Junio C HamanoDec 27, 2024
  14. Patrick SteinhardtDec 27, 2024
  15. René ScharfeDec 27, 2024
  16. Patrick SteinhardtDec 27, 2024
  17. Junio C HamanoDec 27, 2024
  18. 0/4 reftable: fix realloc error handlingRené Scharfe, Dec 28, 2024
  19. 1/4 reftable: avoid leaks on realloc errorRené Scharfe, Dec 28, 2024
  20. Patrick SteinhardtDec 30, 2024
  21. 2/4 reftable: fix allocation count on realloc errorRené Scharfe, Dec 28, 2024
  22. 3/4 reftable: handle realloc error in parse_names()René Scharfe, Dec 28, 2024
  23. Patrick SteinhardtDec 30, 2024
  24. 4/4 t-reftable-merged: handle realloc errorsRené Scharfe, Dec 28, 2024
  25. Patrick SteinhardtDec 30, 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.