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

[PATCH 2/2] commit: use strbuf_release() instead of UNLEAK()

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Feb 16, 2022, 08:21 UTC
Message-ID
<patch-2.2-e3e78c9e40b-20220216T081844Z-avarab@gmail.com>
In-Reply-To
<cover-0.2-00000000000-20220216T081844Z-avarab@gmail.com>

Convert the UNLEAK() added in 0e5bba53af7 (add UNLEAK annotation for reducing leak false positives, 2017-09-08) to release the memory using strbuf_release() instead.

The tests being marked as passing with "TEST_PASSES_SANITIZE_LEAK=true" already passed before due to the UNLEAK(), but now they really don't leak memory, so let's mark them as such.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/commit.c                 | 4 ++--
 t/t2203-add-intent.sh            | 1 +
 t/t7011-skip-worktree-reading.sh | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 696b3527adf..c38ae2b7656 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1866,7 +1866,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
 cleanup:
 	strbuf_release(&author_ident);
-	UNLEAK(err);
-	UNLEAK(sb);
+	strbuf_release(&err);
+	strbuf_release(&sb);
 	return ret;
 }
diff --git a/t/t2203-add-intent.sh b/t/t2203-add-intent.sh
index db7ca559986..ebf58db2d18 100755
--- a/t/t2203-add-intent.sh
+++ b/t/t2203-add-intent.sh
@@ -2,6 +2,7 @@
 
 test_description='Intent to add'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'intent to add' '
diff --git a/t/t7011-skip-worktree-reading.sh b/t/t7011-skip-worktree-reading.sh
index 1761a2b1b99..4adac5acd57 100755
--- a/t/t7011-skip-worktree-reading.sh
+++ b/t/t7011-skip-worktree-reading.sh
@@ -5,6 +5,7 @@
 
 test_description='skip-worktree bit test'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 cat >expect.full <<EOF
-- 
2.35.1.1028.g2d2d4be19de
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 12 in “commit: trivial leak fix, add 2 tests to linux-leaks CI”
  1. 0/2 commit: trivial leak fix, add 2 tests to linux-leaks CIÆvar Arnfjörð Bjarmason, Feb 16, 2022
  2. 1/2 commit: fix "author_ident" leakÆvar Arnfjörð Bjarmason, Feb 16, 2022
  3. Junio C HamanoFeb 16, 2022
  4. 2/2 commit: use strbuf_release() instead of UNLEAK()Ævar Arnfjörð Bjarmason, Feb 16, 2022
  5. Junio C HamanoFeb 16, 2022
  6. Junio C HamanoFeb 16, 2022
  7. Whether to keep using UNLEAK() in built-ins (was: [PATCH 2/2] commit: use strbuf_release() instead of UNLEAK())Ævar Arnfjörð Bjarmason, Feb 18, 2022
  8. Junio C HamanoFeb 18, 2022
  9. Ævar Arnfjörð BjarmasonFeb 18, 2022
  10. commit: fix "author_ident" leakJunio C Hamano, May 12, 2022
  11. Ævar Arnfjörð BjarmasonMay 17, 2022
  12. Junio C HamanoMay 18, 2022

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.