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

[PATCH 1/6] fast-export: drop const when storing anonymized values

From
Jeff King <peff@peff.net>
Date
Mar 22, 2023, 17:37 UTC
Message-ID
<20230322173717.GA5795@coredump.intra.peff.net>
In-Reply-To
<20230322173636.GA5643@coredump.intra.peff.net>

We store anonymized values as pointers to "const char *", since they are conceptually const to callers who use them. But they are actually allocated strings whose memory is owned by the struct.

The ownership mismatch hasn't been a big deal since we never free() them (they are held until the program ends), but let's switch them to "char *" in preparation for changing that.

Since most code only accesses them via anonymize_str(), it can continue to narrow them to "const char *" in its return value.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/fast-export.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 78493c6d2bf..f422819c82a 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -110,7 +110,7 @@ static struct decoration idnums;
 static uint32_t last_idnum;
 struct anonymized_entry {
 	struct hashmap_entry hash;
-	const char *anon;
+	char *anon;
 	const char orig[FLEX_ARRAY];
 };
 
-- 
2.40.0.595.g9b96b494d8c
Previous: Jeff KingNext: Jeff King
Message 2 of 9 in “minor cleanups to fast-export --anonymize”
  1. 0/6 minor cleanups to fast-export --anonymizeJeff King, Mar 22, 2023
  2. 1/6 fast-export: drop const when storing anonymized valuesJeff King, Mar 22, 2023
  3. 2/6 fast-export: simplify initialization of anonymized hashmapsJeff King, Mar 22, 2023
  4. 3/6 fast-export: factor out anonymized_entry creationJeff King, Mar 22, 2023
  5. 4/6 fast-export: de-obfuscate --anonymize-map handlingJeff King, Mar 22, 2023
  6. 5/6 fast-export: drop data parameter from anonymous generatorsJeff King, Mar 22, 2023
  7. 6/6 fast-export: drop unused parameter from anonymize_commit_message()Jeff King, Mar 22, 2023
  8. Derrick StoleeMar 24, 2023
  9. Junio C HamanoMar 24, 2023

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.