hashmap: mark unused callback parameters

Hashmap comparison functions must conform to a particular callback interface, but many don't use all of their parameters. Especially the void cmp_data pointer, but some do not use keydata either (because they can easily form a full struct to pass when doing lookups). Let's mark these to make -Wunused-parameter happy. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Aug 19, 2022 at 06:08 UTC 02c3c59e62a30771d209a171edfc75a4d7387ebe
29 files changed +59 -56
add-interactive.c
+1 -1
@@ -430,7 +430,7 @@ struct pathname_entry {
430 struct file_item *item;
431 };
432
433 -static int pathname_entry_cmp(const void *unused_cmp_data,
433 +static int pathname_entry_cmp(const void *UNUSED(cmp_data),
434 const struct hashmap_entry *he1,
435 const struct hashmap_entry *he2,
436 const void *name)
attr.c
+2 -2
@@ -61,10 +61,10 @@ struct attr_hash_entry {
61 };
62
63 /* attr_hashmap comparison function */
64 -static int attr_hash_entry_cmp(const void *unused_cmp_data,
64 +static int attr_hash_entry_cmp(const void *UNUSED(cmp_data),
65 const struct hashmap_entry *eptr,
66 const struct hashmap_entry *entry_or_key,
67 - const void *unused_keydata)
67 + const void *UNUSED(keydata))
68 {
69 const struct attr_hash_entry *a, *b;
70
bloom.c
+2 -2
@@ -163,10 +163,10 @@ void init_bloom_filters(void)
163 init_bloom_filter_slab(&bloom_filters);
164 }
165
166 -static int pathmap_cmp(const void *hashmap_cmp_fn_data,
166 +static int pathmap_cmp(const void *UNUSED(hashmap_cmp_fn_data),
167 const struct hashmap_entry *eptr,
168 const struct hashmap_entry *entry_or_key,
169 - const void *keydata)
169 + const void *UNUSED(keydata))
170 {
171 const struct pathmap_hash_entry *e1, *e2;
172
builtin/describe.c
+1 -1
@@ -63,7 +63,7 @@ static const char *prio_names[] = {
63 N_("head"), N_("lightweight"), N_("annotated"),
64 };
65
66 -static int commit_name_neq(const void *unused_cmp_data,
66 +static int commit_name_neq(const void *UNUSED(cmp_data),
67 const struct hashmap_entry *eptr,
68 const struct hashmap_entry *entry_or_key,
69 const void *peeled)
builtin/difftool.c
+5 -5
@@ -125,10 +125,10 @@ struct working_tree_entry {
125 char path[FLEX_ARRAY];
126 };
127
128 -static int working_tree_entry_cmp(const void *unused_cmp_data,
128 +static int working_tree_entry_cmp(const void *UNUSED(cmp_data),
129 const struct hashmap_entry *eptr,
130 const struct hashmap_entry *entry_or_key,
131 - const void *unused_keydata)
131 + const void *UNUSED(keydata))
132 {
133 const struct working_tree_entry *a, *b;
134
@@ -148,10 +148,10 @@ struct pair_entry {
148 const char path[FLEX_ARRAY];
149 };
150
151 -static int pair_cmp(const void *unused_cmp_data,
151 +static int pair_cmp(const void *UNUSED(cmp_data),
152 const struct hashmap_entry *eptr,
153 const struct hashmap_entry *entry_or_key,
154 - const void *unused_keydata)
154 + const void *UNUSED(keydata))
155 {
156 const struct pair_entry *a, *b;
157
@@ -184,7 +184,7 @@ struct path_entry {
184 char path[FLEX_ARRAY];
185 };
186
187 -static int path_entry_cmp(const void *unused_cmp_data,
187 +static int path_entry_cmp(const void *UNUSED(cmp_data),
188 const struct hashmap_entry *eptr,
189 const struct hashmap_entry *entry_or_key,
190 const void *key)
builtin/fast-export.c
+1 -1
@@ -119,7 +119,7 @@ struct anonymized_entry_key {
119 size_t orig_len;
120 };
121
122 -static int anonymized_entry_cmp(const void *unused_cmp_data,
122 +static int anonymized_entry_cmp(const void *UNUSED(cmp_data),
123 const struct hashmap_entry *eptr,
124 const struct hashmap_entry *entry_or_key,
125 const void *keydata)
builtin/fast-import.c
+1 -1
@@ -46,7 +46,7 @@ struct object_entry {
46 depth : DEPTH_BITS;
47 };
48
49 -static int object_entry_hashcmp(const void *map_data,
49 +static int object_entry_hashcmp(const void *UNUSED(map_data),
50 const struct hashmap_entry *eptr,
51 const struct hashmap_entry *entry_or_key,
52 const void *keydata)
builtin/fetch.c
+1 -1
@@ -301,7 +301,7 @@ struct refname_hash_entry {
301 char refname[FLEX_ARRAY];
302 };
303
304 -static int refname_hash_entry_cmp(const void *hashmap_cmp_fn_data,
304 +static int refname_hash_entry_cmp(const void *UNUSED(hashmap_cmp_fn_data),
305 const struct hashmap_entry *eptr,
306 const struct hashmap_entry *entry_or_key,
307 const void *keydata)
compat/terminal.c
+1 -1
@@ -477,7 +477,7 @@ struct escape_sequence_entry {
477 char sequence[FLEX_ARRAY];
478 };
479
480 -static int sequence_entry_cmp(const void *hashmap_cmp_fn_data,
480 +static int sequence_entry_cmp(const void *UNUSED(hashmap_cmp_fn_data),
481 const struct escape_sequence_entry *e1,
482 const struct escape_sequence_entry *e2,
483 const void *keydata)
config.c
+2 -2
@@ -2338,10 +2338,10 @@ static int configset_add_value(struct config_set *cs, const char *key, const cha
2338 return 0;
2339 }
2340
2341 -static int config_set_element_cmp(const void *unused_cmp_data,
2341 +static int config_set_element_cmp(const void *UNUSED(cmp_data),
2342 const struct hashmap_entry *eptr,
2343 const struct hashmap_entry *entry_or_key,
2344 - const void *unused_keydata)
2344 + const void *UNUSED(keydata))
2345 {
2346 const struct config_set_element *e1, *e2;
2347
diff.c
+1 -1
@@ -917,7 +917,7 @@ struct interned_diff_symbol {
917 static int interned_diff_symbol_cmp(const void *hashmap_cmp_fn_data,
918 const struct hashmap_entry *eptr,
919 const struct hashmap_entry *entry_or_key,
920 - const void *keydata)
920 + const void *UNUSED(keydata))
921 {
922 const struct diff_options *diffopt = hashmap_cmp_fn_data;
923 const struct emitted_diff_symbol *a, *b;
dir.c
+2 -2
@@ -655,10 +655,10 @@ void parse_path_pattern(const char **pattern,
655 *patternlen = len;
656 }
657
658 -int pl_hashmap_cmp(const void *unused_cmp_data,
658 +int pl_hashmap_cmp(const void *UNUSED(cmp_data),
659 const struct hashmap_entry *a,
660 const struct hashmap_entry *b,
661 - const void *key)
661 + const void *UNUSED(key))
662 {
663 const struct pattern_entry *ee1 =
664 container_of(a, struct pattern_entry, ent);
environment.c
+2 -2
@@ -333,10 +333,10 @@ static void set_git_dir_1(const char *path)
333 setup_git_env(path);
334 }
335
336 -static void update_relative_gitdir(const char *name,
336 +static void update_relative_gitdir(const char *UNUSED(name),
337 const char *old_cwd,
338 const char *new_cwd,
339 - void *data)
339 + void *UNUSED(data))
340 {
341 char *path = reparent_relative_path(old_cwd, new_cwd, get_git_dir());
342 struct tmp_objdir *tmp_objdir = tmp_objdir_unapply_primary_odb();
hashmap.c
+5 -5
@@ -142,10 +142,10 @@ static inline struct hashmap_entry **find_entry_ptr(const struct hashmap *map,
142 return e;
143 }
144
145 -static int always_equal(const void *unused_cmp_data,
146 - const struct hashmap_entry *unused1,
147 - const struct hashmap_entry *unused2,
148 - const void *unused_keydata)
145 +static int always_equal(const void *UNUSED(cmp_data),
146 + const struct hashmap_entry *UNUSED(entry1),
147 + const struct hashmap_entry *UNUSED(entry2),
148 + const void *UNUSED(keydata))
149 {
150 return 0;
151 }
@@ -313,7 +313,7 @@ struct pool_entry {
313 unsigned char data[FLEX_ARRAY];
314 };
315
316 -static int pool_entry_cmp(const void *unused_cmp_data,
316 +static int pool_entry_cmp(const void *UNUSED(cmp_data),
317 const struct hashmap_entry *eptr,
318 const struct hashmap_entry *entry_or_key,
319 const void *keydata)
merge-recursive.c
+5 -5
@@ -45,7 +45,7 @@ struct path_hashmap_entry {
45 char path[FLEX_ARRAY];
46 };
47
48 -static int path_hashmap_cmp(const void *cmp_data,
48 +static int path_hashmap_cmp(const void *UNUSED(cmp_data),
49 const struct hashmap_entry *eptr,
50 const struct hashmap_entry *entry_or_key,
51 const void *keydata)
@@ -89,10 +89,10 @@ static struct dir_rename_entry *dir_rename_find_entry(struct hashmap *hashmap,
89 return hashmap_get_entry(hashmap, &key, ent, NULL);
90 }
91
92 -static int dir_rename_cmp(const void *unused_cmp_data,
92 +static int dir_rename_cmp(const void *UNUSED(cmp_data),
93 const struct hashmap_entry *eptr,
94 const struct hashmap_entry *entry_or_key,
95 - const void *unused_keydata)
95 + const void *UNUSED(keydata))
96 {
97 const struct dir_rename_entry *e1, *e2;
98
@@ -134,10 +134,10 @@ static struct collision_entry *collision_find_entry(struct hashmap *hashmap,
134 return hashmap_get_entry(hashmap, &key, ent, NULL);
135 }
136
137 -static int collision_cmp(const void *unused_cmp_data,
137 +static int collision_cmp(const void *UNUSED(cmp_data),
138 const struct hashmap_entry *eptr,
139 const struct hashmap_entry *entry_or_key,
140 - const void *unused_keydata)
140 + const void *UNUSED(keydata))
141 {
142 const struct collision_entry *e1, *e2;
143
name-hash.c
+2 -2
@@ -18,7 +18,7 @@ struct dir_entry {
18 char name[FLEX_ARRAY];
19 };
20
21 -static int dir_entry_cmp(const void *unused_cmp_data,
21 +static int dir_entry_cmp(const void *UNUSED(cmp_data),
22 const struct hashmap_entry *eptr,
23 const struct hashmap_entry *entry_or_key,
24 const void *keydata)
@@ -120,7 +120,7 @@ static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)
120 add_dir_entry(istate, ce);
121 }
122
123 -static int cache_entry_cmp(const void *unused_cmp_data,
123 +static int cache_entry_cmp(const void *UNUSED(cmp_data),
124 const struct hashmap_entry *eptr,
125 const struct hashmap_entry *entry_or_key,
126 const void *remove)
object-store.h
+1 -1
@@ -141,7 +141,7 @@ struct packed_git {
141
142 struct multi_pack_index;
143
144 -static inline int pack_map_entry_cmp(const void *unused_cmp_data,
144 +static inline int pack_map_entry_cmp(const void *UNUSED(cmp_data),
145 const struct hashmap_entry *entry,
146 const struct hashmap_entry *entry2,
147 const void *keydata)
oidmap.c
+1 -1
@@ -1,7 +1,7 @@
1 #include "cache.h"
2 #include "oidmap.h"
3
4 -static int oidmap_neq(const void *hashmap_cmp_fn_data,
4 +static int oidmap_neq(const void *UNUSED(hashmap_cmp_fn_data),
5 const struct hashmap_entry *e1,
6 const struct hashmap_entry *e2,
7 const void *keydata)
packfile.c
+1 -1
@@ -1392,7 +1392,7 @@ static int delta_base_cache_key_eq(const struct delta_base_cache_key *a,
1392 return a->p == b->p && a->base_offset == b->base_offset;
1393 }
1394
1395 -static int delta_base_cache_hash_cmp(const void *unused_cmp_data,
1395 +static int delta_base_cache_hash_cmp(const void *UNUSED(cmp_data),
1396 const struct hashmap_entry *va,
1397 const struct hashmap_entry *vb,
1398 const void *vkey)
patch-ids.c
+1 -1
@@ -38,7 +38,7 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,
38 static int patch_id_neq(const void *cmpfn_data,
39 const struct hashmap_entry *eptr,
40 const struct hashmap_entry *entry_or_key,
41 - const void *unused_keydata)
41 + const void *UNUSED(keydata))
42 {
43 /* NEEDSWORK: const correctness? */
44 struct diff_options *opt = (void *)cmpfn_data;
range-diff.c
+4 -2
@@ -224,8 +224,10 @@ cleanup:
224 return ret;
225 }
226
227 -static int patch_util_cmp(const void *dummy, const struct patch_util *a,
228 - const struct patch_util *b, const char *keydata)
227 +static int patch_util_cmp(const void *UNUSED(cmp_data),
228 + const struct patch_util *a,
229 + const struct patch_util *b,
230 + const char *keydata)
231 {
232 return strcmp(a->diff, keydata ? keydata : b->diff);
233 }
ref-filter.c
+1 -1
@@ -89,7 +89,7 @@ struct ref_to_worktree_entry {
89 struct worktree *wt; /* key is wt->head_ref */
90 };
91
92 -static int ref_to_worktree_map_cmpfnc(const void *unused_lookupdata,
92 +static int ref_to_worktree_map_cmpfnc(const void *UNUSED(lookupdata),
93 const struct hashmap_entry *eptr,
94 const struct hashmap_entry *kptr,
95 const void *keydata_aka_refname)
refs.c
+1 -1
@@ -1815,7 +1815,7 @@ struct ref_store_hash_entry
1815 char name[FLEX_ARRAY];
1816 };
1817
1818 -static int ref_store_hash_cmp(const void *unused_cmp_data,
1818 +static int ref_store_hash_cmp(const void *UNUSED(cmp_data),
1819 const struct hashmap_entry *eptr,
1820 const struct hashmap_entry *entry_or_key,
1821 const void *keydata)
remote.c
+2 -2
@@ -86,7 +86,7 @@ struct remotes_hash_key {
86 int len;
87 };
88
89 -static int remotes_hash_cmp(const void *unused_cmp_data,
89 +static int remotes_hash_cmp(const void *UNUSED(cmp_data),
90 const struct hashmap_entry *eptr,
91 const struct hashmap_entry *entry_or_key,
92 const void *keydata)
@@ -170,7 +170,7 @@ struct branches_hash_key {
170 int len;
171 };
172
173 -static int branches_hash_cmp(const void *unused_cmp_data,
173 +static int branches_hash_cmp(const void *UNUSED(cmp_data),
174 const struct hashmap_entry *eptr,
175 const struct hashmap_entry *entry_or_key,
176 const void *keydata)
revision.c
+2 -2
@@ -119,10 +119,10 @@ struct path_and_oids_entry {
119 struct oidset trees;
120 };
121
122 -static int path_and_oids_cmp(const void *hashmap_cmp_fn_data,
122 +static int path_and_oids_cmp(const void *UNUSED(hashmap_cmp_fn_data),
123 const struct hashmap_entry *eptr,
124 const struct hashmap_entry *entry_or_key,
125 - const void *keydata)
125 + const void *UNUSED(keydata))
126 {
127 const struct path_and_oids_entry *e1, *e2;
128
sequencer.c
+3 -2
@@ -5254,7 +5254,8 @@ struct labels_entry {
5254 char label[FLEX_ARRAY];
5255 };
5256
5257 -static int labels_cmp(const void *fndata, const struct hashmap_entry *eptr,
5257 +static int labels_cmp(const void *UNUSED(fndata),
5258 + const struct hashmap_entry *eptr,
5259 const struct hashmap_entry *entry_or_key, const void *key)
5260 {
5261 const struct labels_entry *a, *b;
@@ -6131,7 +6132,7 @@ struct subject2item_entry {
6132 char subject[FLEX_ARRAY];
6133 };
6134
6134 -static int subject2item_cmp(const void *fndata,
6135 +static int subject2item_cmp(const void *UNUSED(fndata),
6136 const struct hashmap_entry *eptr,
6137 const struct hashmap_entry *entry_or_key,
6138 const void *key)
strmap.c
+2 -2
@@ -2,10 +2,10 @@
2 #include "strmap.h"
3 #include "mem-pool.h"
4
5 -int cmp_strmap_entry(const void *hashmap_cmp_fn_data,
5 +int cmp_strmap_entry(const void *UNUSED(hashmap_cmp_fn_data),
6 const struct hashmap_entry *entry1,
7 const struct hashmap_entry *entry2,
8 - const void *keydata)
8 + const void *UNUSED(keydata))
9 {
10 const struct strmap_entry *e1, *e2;
11
sub-process.c
+2 -2
@@ -5,10 +5,10 @@
5 #include "sigchain.h"
6 #include "pkt-line.h"
7
8 -int cmd2process_cmp(const void *unused_cmp_data,
8 +int cmd2process_cmp(const void *UNUSED(cmp_data),
9 const struct hashmap_entry *eptr,
10 const struct hashmap_entry *entry_or_key,
11 - const void *unused_keydata)
11 + const void *UNUSED(keydata))
12 {
13 const struct subprocess_entry *e1, *e2;
14
submodule-config.c
+4 -4
@@ -38,10 +38,10 @@ enum lookup_type {
38 lookup_path
39 };
40
41 -static int config_path_cmp(const void *unused_cmp_data,
41 +static int config_path_cmp(const void *UNUSED(cmp_data),
42 const struct hashmap_entry *eptr,
43 const struct hashmap_entry *entry_or_key,
44 - const void *unused_keydata)
44 + const void *UNUSED(keydata))
45 {
46 const struct submodule_entry *a, *b;
47
@@ -52,10 +52,10 @@ static int config_path_cmp(const void *unused_cmp_data,
52 !oideq(&a->config->gitmodules_oid, &b->config->gitmodules_oid);
53 }
54
55 -static int config_name_cmp(const void *unused_cmp_data,
55 +static int config_name_cmp(const void *UNUSED(cmp_data),
56 const struct hashmap_entry *eptr,
57 const struct hashmap_entry *entry_or_key,
58 - const void *unused_keydata)
58 + const void *UNUSED(keydata))
59 {
60 const struct submodule_entry *a, *b;
61