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

[PATCH 05/10] convert/sub-process: drop cast to hashmap_cmp_fn

From
Stefan Beller <sbeller@google.com>
Date
Jul 1, 2017, 00:28 UTC
Message-ID
<20170701002838.22785-6-sbeller@google.com>
In-Reply-To
<20170701002838.22785-1-sbeller@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 convert.c     | 3 +--
 sub-process.c | 7 +++++--
 sub-process.h | 4 ++--
 3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/convert.c b/convert.c
index deaf0ba7b3..04966c723c 100644
--- a/convert.c
+++ b/convert.c
@@ -583,8 +583,7 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
 
 	if (!subprocess_map_initialized) {
 		subprocess_map_initialized = 1;
-		hashmap_init(&subprocess_map, (hashmap_cmp_fn) cmd2process_cmp,
-			     NULL, 0);
+		hashmap_init(&subprocess_map, cmd2process_cmp, NULL, 0);
 		entry = NULL;
 	} else {
 		entry = (struct cmd2process *)subprocess_find_entry(&subprocess_map, cmd);
diff --git a/sub-process.c b/sub-process.c
index a3cfab1a9d..6cbffa4406 100644
--- a/sub-process.c
+++ b/sub-process.c
@@ -6,10 +6,13 @@
 #include "pkt-line.h"
 
 int cmd2process_cmp(const void *unused_cmp_data,
-		    const struct subprocess_entry *e1,
-		    const struct subprocess_entry *e2,
+		    const void *entry,
+		    const void *entry_or_key,
 		    const void *unused_keydata)
 {
+	const struct subprocess_entry *e1 = entry;
+	const struct subprocess_entry *e2 = entry_or_key;
+
 	return strcmp(e1->cmd, e2->cmd);
 }
 
diff --git a/sub-process.h b/sub-process.h
index 96a2cca360..8cd07a59ab 100644
--- a/sub-process.h
+++ b/sub-process.h
@@ -21,8 +21,8 @@ struct subprocess_entry {
 /* subprocess functions */
 
 extern int cmd2process_cmp(const void *unused_cmp_data,
-			   const struct subprocess_entry *e1,
-			   const struct subprocess_entry *e2,
+			   const void *e1,
+			   const void *e2,
 			   const void *unused_keydata);
 
 typedef int(*subprocess_start_fn)(struct subprocess_entry *entry);
-- 
2.13.0.31.g9b732c453e
Previous: Stefan BellerNext: Stefan Beller
Message 10 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.