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

[PATCH] chdir-notify: UNLEAK registrated callback entries

From
René Scharfe <l.s.r@web.de>
Date
Nov 14, 2020, 21:40 UTC
Message-ID
<8a9cf9ba-f615-3ff5-8d35-c24c22d5d859@web.de>

chdir_notify_register() allows registering functions to notify when chdir() is called. There is no way to unsubscribe or shut this mechanism down, so these entries are present until the program ends.

Valgrind reports allocations for these registrations as "possibly lost", probably because it doesn't see through list.h's offsetof tricks. Annotate them using UNLEAK, which causes Valgrind to report them as "still reachable" instead.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 chdir-notify.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/chdir-notify.c b/chdir-notify.c
index 5f7f2c2ac2..b236288416 100644
--- a/chdir-notify.c
+++ b/chdir-notify.c
@@ -16,6 +16,7 @@ void chdir_notify_register(const char *name,
 			   void *data)
 {
 	struct chdir_notify_entry *e = xmalloc(sizeof(*e));
+	UNLEAK(e);
 	e->name = name;
 	e->cb = cb;
 	e->data = data;
--
2.29.2
Next: René Scharfe
Message 1 of 8 in “chdir-notify: UNLEAK registrated callback entries”
  1. chdir-notify: UNLEAK registrated callback entriesRené Scharfe, Nov 14, 2020
  2. René ScharfeNov 14, 2020
  3. Junio C HamanoNov 16, 2020
  4. Elijah NewrenNov 17, 2020
  5. Jeff KingNov 17, 2020
  6. Elijah NewrenNov 17, 2020
  7. Jeff KingNov 17, 2020
  8. René ScharfeNov 17, 2020

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.