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

[PATCH 06/10] patch-ids.c: drop hashmap_cmp_fn cast

From
Stefan Beller <sbeller@google.com>
Date
Jul 1, 2017, 00:28 UTC
Message-ID
<20170701002838.22785-7-sbeller@google.com>
In-Reply-To
<20170701002838.22785-1-sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 patch-ids.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/patch-ids.c b/patch-ids.c
index b4166b0f38..9ea523984b 100644
--- a/patch-ids.c
+++ b/patch-ids.c
@@ -35,11 +35,16 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,
  * the side of safety.  The actual value being negative does not have
  * any significance; only that it is non-zero matters.
  */
-static int patch_id_cmp(struct diff_options *opt,
-			struct patch_id *a,
-			struct patch_id *b,
+static int patch_id_cmp(const void *cmpfn_data,
+			const void *entry,
+			const void *entry_or_key,
 			const void *unused_keydata)
 {
+	/* NEEDSWORK: const correctness? */
+	struct diff_options *opt = (void*)cmpfn_data;
+	struct patch_id *a = (void*)entry;
+	struct patch_id *b = (void*)entry_or_key;
+
 	if (is_null_oid(&a->patch_id) &&
 	    commit_patch_id(a->commit, opt, &a->patch_id, 0))
 		return error("Could not get patch ID for %s",
@@ -58,8 +63,7 @@ int init_patch_ids(struct patch_ids *ids)
 	ids->diffopts.detect_rename = 0;
 	DIFF_OPT_SET(&ids->diffopts, RECURSIVE);
 	diff_setup_done(&ids->diffopts);
-	hashmap_init(&ids->patches, (hashmap_cmp_fn)patch_id_cmp,
-		     &ids->diffopts, 256);
+	hashmap_init(&ids->patches, patch_id_cmp, &ids->diffopts, 256);
 	return 0;
 }
 
-- 
2.13.0.31.g9b732c453e
Previous: Stefan BellerNext: Stefan Beller
Message 9 of 12 in “Friday night special: hash map cleanup”
  1. 00/10 Friday night special: hash map cleanupStefan Beller, Jul 1, 2017
  2. 01/10 attr.c: drop hashmap_cmp_fn castStefan Beller, Jul 1, 2017
  3. 02/10 builtin/difftool.c: drop hashmap_cmp_fn castStefan Beller, Jul 1, 2017
  4. 03/10 builtin/describe: drop hashmap_cmp_fn castStefan Beller, Jul 1, 2017
  5. 04/10 config.c: drop hashmap_cmp_fn castStefan Beller, Jul 1, 2017
  6. 09/10 name-hash.c: drop hashmap_cmp_fn castStefan Beller, Jul 1, 2017
  7. 10/10 t/helper/test-hashmap: use custom data instead of duplicate cmp functionsStefan Beller, Jul 1, 2017
  8. 08/10 submodule-config.c: drop hashmap_cmp_fn castStefan Beller, Jul 1, 2017
  9. 06/10 patch-ids.c: drop hashmap_cmp_fn castStefan Beller, Jul 1, 2017
  10. 05/10 convert/sub-process: drop cast to hashmap_cmp_fnStefan Beller, Jul 1, 2017
  11. 07/10 remote.c: drop hashmap_cmp_fn castStefan Beller, Jul 1, 2017
  12. Junio C HamanoJul 5, 2017

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.