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

[PATCH 2/2] Revert "fast-export: use local array to store anonymized oid"

From
Jeff King <peff@peff.net>
Date
Sep 24, 2020, 19:22 UTC
Message-ID
<20200924192229.GB2528225@coredump.intra.peff.net>
In-Reply-To
<20200924191638.GA2528003@coredump.intra.peff.net>
This reverts commit f39ad38410da554af54966bf74fa0402355852ac.

That commit was trying to silence a type-punning warning on older versions of gcc. However, its analysis was all wrong. I didn't notice that we _were_ in fact type-punning because there are two versions of put_be32(): one that uses casts and unaligned loads, and another that uses bitshifts. I looked at the latter, but on my platform we were defaulting to the former.

However, as of the previous commit, we'll always use the bitshift version. So we can drop this hackery to avoid the warning, making the code slightly cleaner.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/fast-export.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 1b8fca3ee0..e266d90a81 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -405,12 +405,12 @@ static char *generate_fake_oid(void *data)
 {
 	static uint32_t counter = 1; /* avoid null oid */
 	const unsigned hashsz = the_hash_algo->rawsz;
-	unsigned char out[GIT_MAX_RAWSZ];
+	struct object_id oid;
 	char *hex = xmallocz(GIT_MAX_HEXSZ);
 
-	hashclr(out);
-	put_be32(out + hashsz - 4, counter++);
-	return hash_to_hex_algop_r(hex, out, the_hash_algo);
+	oidclr(&oid);
+	put_be32(oid.hash + hashsz - 4, counter++);
+	return oid_to_hex_r(hex, &oid);
 }
 
 static const char *anonymize_oid(const char *oid_hex)
-- 
2.28.0.1082.g195fe9fe3f
Previous: Thomas Guyot
Message 9 of 9 in “drop unaligned loads”
  1. 0/2 drop unaligned loadsJeff King, Sep 24, 2020
  2. 1/2 bswap.h: drop unaligned loadsJeff King, Sep 24, 2020
  3. René ScharfeSep 24, 2020
  4. Jeff KingSep 25, 2020
  5. brian m. carlsonSep 25, 2020
  6. Carlo ArenasSep 25, 2020
  7. Jeff KingSep 25, 2020
  8. Thomas GuyotSep 25, 2020
  9. 2/2 Revert "fast-export: use local array to store anonymized oid"Jeff King, Sep 24, 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.