]> git.ipfire.org Git - thirdparty/git.git/commitdiff
hashmap: mark unused callback parameters
authorJeff King <peff@peff.net>
Fri, 19 Aug 2022 10:08:46 +0000 (06:08 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Aug 2022 19:18:55 +0000 (12:18 -0700)
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>
29 files changed:
add-interactive.c
attr.c
bloom.c
builtin/describe.c
builtin/difftool.c
builtin/fast-export.c
builtin/fast-import.c
builtin/fetch.c
compat/terminal.c
config.c
diff.c
dir.c
environment.c
hashmap.c
merge-recursive.c
name-hash.c
object-store.h
oidmap.c
packfile.c
patch-ids.c
range-diff.c
ref-filter.c
refs.c
remote.c
revision.c
sequencer.c
strmap.c
sub-process.c
submodule-config.c

index 22fcd3412ca5d8b343190cd3ae07148d83fd55e3..2fcad676544480913984ef999c6ef93b0627a30d 100644 (file)
@@ -430,7 +430,7 @@ struct pathname_entry {
        struct file_item *item;
 };
 
-static int pathname_entry_cmp(const void *unused_cmp_data,
+static int pathname_entry_cmp(const void *UNUSED(cmp_data),
                              const struct hashmap_entry *he1,
                              const struct hashmap_entry *he2,
                              const void *name)
diff --git a/attr.c b/attr.c
index 21e4ad25ada625885ebcc524facf6a9ce816d39e..375b5c0dbf7c200f1efb5423dda195af65ab1db5 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -61,10 +61,10 @@ struct attr_hash_entry {
 };
 
 /* attr_hashmap comparison function */
-static int attr_hash_entry_cmp(const void *unused_cmp_data,
+static int attr_hash_entry_cmp(const void *UNUSED(cmp_data),
                               const struct hashmap_entry *eptr,
                               const struct hashmap_entry *entry_or_key,
-                              const void *unused_keydata)
+                              const void *UNUSED(keydata))
 {
        const struct attr_hash_entry *a, *b;
 
diff --git a/bloom.c b/bloom.c
index 816f063dca58bda64cd0ff452c9ae917d3c681a9..94fb97e60edd3f94309eac6451255036f8983489 100644 (file)
--- a/bloom.c
+++ b/bloom.c
@@ -163,10 +163,10 @@ void init_bloom_filters(void)
        init_bloom_filter_slab(&bloom_filters);
 }
 
-static int pathmap_cmp(const void *hashmap_cmp_fn_data,
+static int pathmap_cmp(const void *UNUSED(hashmap_cmp_fn_data),
                       const struct hashmap_entry *eptr,
                       const struct hashmap_entry *entry_or_key,
-                      const void *keydata)
+                      const void *UNUSED(keydata))
 {
        const struct pathmap_hash_entry *e1, *e2;
 
index 3af36483f2409c69d247d79870042f072126ef3d..084fa00f2a5d4ce15cd382aeac143b157a87eac5 100644 (file)
@@ -63,7 +63,7 @@ static const char *prio_names[] = {
        N_("head"), N_("lightweight"), N_("annotated"),
 };
 
-static int commit_name_neq(const void *unused_cmp_data,
+static int commit_name_neq(const void *UNUSED(cmp_data),
                           const struct hashmap_entry *eptr,
                           const struct hashmap_entry *entry_or_key,
                           const void *peeled)
index b3c509b8de305db3ba5b393618024087e387dc46..a570200e66accd5c3687a8f3e656f366119a2856 100644 (file)
@@ -125,10 +125,10 @@ struct working_tree_entry {
        char path[FLEX_ARRAY];
 };
 
-static int working_tree_entry_cmp(const void *unused_cmp_data,
+static int working_tree_entry_cmp(const void *UNUSED(cmp_data),
                                  const struct hashmap_entry *eptr,
                                  const struct hashmap_entry *entry_or_key,
-                                 const void *unused_keydata)
+                                 const void *UNUSED(keydata))
 {
        const struct working_tree_entry *a, *b;
 
@@ -148,10 +148,10 @@ struct pair_entry {
        const char path[FLEX_ARRAY];
 };
 
-static int pair_cmp(const void *unused_cmp_data,
+static int pair_cmp(const void *UNUSED(cmp_data),
                    const struct hashmap_entry *eptr,
                    const struct hashmap_entry *entry_or_key,
-                   const void *unused_keydata)
+                   const void *UNUSED(keydata))
 {
        const struct pair_entry *a, *b;
 
@@ -184,7 +184,7 @@ struct path_entry {
        char path[FLEX_ARRAY];
 };
 
-static int path_entry_cmp(const void *unused_cmp_data,
+static int path_entry_cmp(const void *UNUSED(cmp_data),
                          const struct hashmap_entry *eptr,
                          const struct hashmap_entry *entry_or_key,
                          const void *key)
index e1748fb98be5b970a8d31bf43f3f708d6a60c3d9..bb05b50a5a0a1fcdc65c6e98b81c442b9fc592a3 100644 (file)
@@ -119,7 +119,7 @@ struct anonymized_entry_key {
        size_t orig_len;
 };
 
-static int anonymized_entry_cmp(const void *unused_cmp_data,
+static int anonymized_entry_cmp(const void *UNUSED(cmp_data),
                                const struct hashmap_entry *eptr,
                                const struct hashmap_entry *entry_or_key,
                                const void *keydata)
index 14113cfd82b78034cb7bbb4d0ff843f20d5ae498..76ed0c2db9c1e6347619a40b220be2ccd87a97e5 100644 (file)
@@ -46,7 +46,7 @@ struct object_entry {
                depth : DEPTH_BITS;
 };
 
-static int object_entry_hashcmp(const void *map_data,
+static int object_entry_hashcmp(const void *UNUSED(map_data),
                                const struct hashmap_entry *eptr,
                                const struct hashmap_entry *entry_or_key,
                                const void *keydata)
index 9e7c8099fed83753d76e0fc21cbac19ccfa9a8c2..5fddaef4804b2d9aa5c44364caf0a5dc8eb91d8b 100644 (file)
@@ -301,7 +301,7 @@ struct refname_hash_entry {
        char refname[FLEX_ARRAY];
 };
 
-static int refname_hash_entry_cmp(const void *hashmap_cmp_fn_data,
+static int refname_hash_entry_cmp(const void *UNUSED(hashmap_cmp_fn_data),
                                  const struct hashmap_entry *eptr,
                                  const struct hashmap_entry *entry_or_key,
                                  const void *keydata)
index 7db330c52dcc2326f245f8984e259f0a8dac1294..0b0caae8571fb09fe35c70b67743b88beca93841 100644 (file)
@@ -477,7 +477,7 @@ struct escape_sequence_entry {
        char sequence[FLEX_ARRAY];
 };
 
-static int sequence_entry_cmp(const void *hashmap_cmp_fn_data,
+static int sequence_entry_cmp(const void *UNUSED(hashmap_cmp_fn_data),
                              const struct escape_sequence_entry *e1,
                              const struct escape_sequence_entry *e2,
                              const void *keydata)
index 589dec90282804431a4182da0a291543fe66ced3..c92f1efd6bf0272f639ae89f7545984cfc0a851c 100644 (file)
--- a/config.c
+++ b/config.c
@@ -2338,10 +2338,10 @@ static int configset_add_value(struct config_set *cs, const char *key, const cha
        return 0;
 }
 
-static int config_set_element_cmp(const void *unused_cmp_data,
+static int config_set_element_cmp(const void *UNUSED(cmp_data),
                                  const struct hashmap_entry *eptr,
                                  const struct hashmap_entry *entry_or_key,
-                                 const void *unused_keydata)
+                                 const void *UNUSED(keydata))
 {
        const struct config_set_element *e1, *e2;
 
diff --git a/diff.c b/diff.c
index 8a9c9083f35cd186a55b83ab563d582c3d34a2c9..7c7d53d2771c28c9f413a90c946f2911ebc5ebe3 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -917,7 +917,7 @@ struct interned_diff_symbol {
 static int interned_diff_symbol_cmp(const void *hashmap_cmp_fn_data,
                                    const struct hashmap_entry *eptr,
                                    const struct hashmap_entry *entry_or_key,
-                                   const void *keydata)
+                                   const void *UNUSED(keydata))
 {
        const struct diff_options *diffopt = hashmap_cmp_fn_data;
        const struct emitted_diff_symbol *a, *b;
diff --git a/dir.c b/dir.c
index d7cfb08e441825f421f91a982063e00be4168c71..42f8ee06e09ee515c128784e09dbd336cb5e20f8 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -655,10 +655,10 @@ void parse_path_pattern(const char **pattern,
        *patternlen = len;
 }
 
-int pl_hashmap_cmp(const void *unused_cmp_data,
+int pl_hashmap_cmp(const void *UNUSED(cmp_data),
                   const struct hashmap_entry *a,
                   const struct hashmap_entry *b,
-                  const void *key)
+                  const void *UNUSED(key))
 {
        const struct pattern_entry *ee1 =
                        container_of(a, struct pattern_entry, ent);
index b3296ce7d15140bff12299b25d1450f69f8508ee..a0ceb6d65585d80007dd74593a267ad7197a2f3f 100644 (file)
@@ -333,10 +333,10 @@ static void set_git_dir_1(const char *path)
        setup_git_env(path);
 }
 
-static void update_relative_gitdir(const char *name,
+static void update_relative_gitdir(const char *UNUSED(name),
                                   const char *old_cwd,
                                   const char *new_cwd,
-                                  void *data)
+                                  void *UNUSED(data))
 {
        char *path = reparent_relative_path(old_cwd, new_cwd, get_git_dir());
        struct tmp_objdir *tmp_objdir = tmp_objdir_unapply_primary_odb();
index 134d2eec804c2eb4851689901f47c251f73b01de..763aa1d8a37192e33927b4f0073e2f62cd464ee6 100644 (file)
--- a/hashmap.c
+++ b/hashmap.c
@@ -142,10 +142,10 @@ static inline struct hashmap_entry **find_entry_ptr(const struct hashmap *map,
        return e;
 }
 
-static int always_equal(const void *unused_cmp_data,
-                       const struct hashmap_entry *unused1,
-                       const struct hashmap_entry *unused2,
-                       const void *unused_keydata)
+static int always_equal(const void *UNUSED(cmp_data),
+                       const struct hashmap_entry *UNUSED(entry1),
+                       const struct hashmap_entry *UNUSED(entry2),
+                       const void *UNUSED(keydata))
 {
        return 0;
 }
@@ -313,7 +313,7 @@ struct pool_entry {
        unsigned char data[FLEX_ARRAY];
 };
 
-static int pool_entry_cmp(const void *unused_cmp_data,
+static int pool_entry_cmp(const void *UNUSED(cmp_data),
                          const struct hashmap_entry *eptr,
                          const struct hashmap_entry *entry_or_key,
                          const void *keydata)
index b83a129b4313d9c6a4f6434fbe2002068ef7a542..775ebe2182680283c4cc141d00d726f18bcbac9b 100644 (file)
@@ -45,7 +45,7 @@ struct path_hashmap_entry {
        char path[FLEX_ARRAY];
 };
 
-static int path_hashmap_cmp(const void *cmp_data,
+static int path_hashmap_cmp(const void *UNUSED(cmp_data),
                            const struct hashmap_entry *eptr,
                            const struct hashmap_entry *entry_or_key,
                            const void *keydata)
@@ -89,10 +89,10 @@ static struct dir_rename_entry *dir_rename_find_entry(struct hashmap *hashmap,
        return hashmap_get_entry(hashmap, &key, ent, NULL);
 }
 
-static int dir_rename_cmp(const void *unused_cmp_data,
+static int dir_rename_cmp(const void *UNUSED(cmp_data),
                          const struct hashmap_entry *eptr,
                          const struct hashmap_entry *entry_or_key,
-                         const void *unused_keydata)
+                         const void *UNUSED(keydata))
 {
        const struct dir_rename_entry *e1, *e2;
 
@@ -134,10 +134,10 @@ static struct collision_entry *collision_find_entry(struct hashmap *hashmap,
        return hashmap_get_entry(hashmap, &key, ent, NULL);
 }
 
-static int collision_cmp(const void *unused_cmp_data,
+static int collision_cmp(const void *UNUSED(cmp_data),
                         const struct hashmap_entry *eptr,
                         const struct hashmap_entry *entry_or_key,
-                        const void *unused_keydata)
+                        const void *UNUSED(keydata))
 {
        const struct collision_entry *e1, *e2;
 
index 7487d331240e2aa25d1ecfbe22cee9eb4998df50..d0da6db56466ff0d3178d2fad1d548fd6202b0cb 100644 (file)
@@ -18,7 +18,7 @@ struct dir_entry {
        char name[FLEX_ARRAY];
 };
 
-static int dir_entry_cmp(const void *unused_cmp_data,
+static int dir_entry_cmp(const void *UNUSED(cmp_data),
                         const struct hashmap_entry *eptr,
                         const struct hashmap_entry *entry_or_key,
                         const void *keydata)
@@ -120,7 +120,7 @@ static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)
                add_dir_entry(istate, ce);
 }
 
-static int cache_entry_cmp(const void *unused_cmp_data,
+static int cache_entry_cmp(const void *UNUSED(cmp_data),
                           const struct hashmap_entry *eptr,
                           const struct hashmap_entry *entry_or_key,
                           const void *remove)
index 5222ee54600fad6ca68cf8a5fdb6471aba10cab4..cf5494af807e287119cf1d6ea95e9ad6a7f8eb61 100644 (file)
@@ -141,7 +141,7 @@ struct packed_git {
 
 struct multi_pack_index;
 
-static inline int pack_map_entry_cmp(const void *unused_cmp_data,
+static inline int pack_map_entry_cmp(const void *UNUSED(cmp_data),
                                     const struct hashmap_entry *entry,
                                     const struct hashmap_entry *entry2,
                                     const void *keydata)
index 286a04a53c20119fe567eec4accbaba4d9f04a97..32aeb0526fe5fd108063b6e5c1a667de9bcfc88b 100644 (file)
--- a/oidmap.c
+++ b/oidmap.c
@@ -1,7 +1,7 @@
 #include "cache.h"
 #include "oidmap.h"
 
-static int oidmap_neq(const void *hashmap_cmp_fn_data,
+static int oidmap_neq(const void *UNUSED(hashmap_cmp_fn_data),
                      const struct hashmap_entry *e1,
                      const struct hashmap_entry *e2,
                      const void *keydata)
index 5ae3ce8ea992887bd1bc948cf2079853afb3088c..d7cf8382deeb819c9f0c1c4c9ceb1355e5ba0780 100644 (file)
@@ -1392,7 +1392,7 @@ static int delta_base_cache_key_eq(const struct delta_base_cache_key *a,
        return a->p == b->p && a->base_offset == b->base_offset;
 }
 
-static int delta_base_cache_hash_cmp(const void *unused_cmp_data,
+static int delta_base_cache_hash_cmp(const void *UNUSED(cmp_data),
                                     const struct hashmap_entry *va,
                                     const struct hashmap_entry *vb,
                                     const void *vkey)
index 8bf425555de252f12935b4fae68f375f3a815987..cdfa5135490f804c910455df338b51b39269cabd 100644 (file)
@@ -38,7 +38,7 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,
 static int patch_id_neq(const void *cmpfn_data,
                        const struct hashmap_entry *eptr,
                        const struct hashmap_entry *entry_or_key,
-                       const void *unused_keydata)
+                       const void *UNUSED(keydata))
 {
        /* NEEDSWORK: const correctness? */
        struct diff_options *opt = (void *)cmpfn_data;
index f63b3ffc200a8b71df3d7287322321ac70be2595..1528fdd0db83ef665424e210d32da7269561b921 100644 (file)
@@ -224,8 +224,10 @@ cleanup:
        return ret;
 }
 
-static int patch_util_cmp(const void *dummy, const struct patch_util *a,
-                         const struct patch_util *b, const char *keydata)
+static int patch_util_cmp(const void *UNUSED(cmp_data),
+                         const struct patch_util *a,
+                         const struct patch_util *b,
+                         const char *keydata)
 {
        return strcmp(a->diff, keydata ? keydata : b->diff);
 }
index bdf39fa761ef9bb961ec03141f35ce71a000c91e..baf252b77d6e76d0a9f56db51d4def1153be01f8 100644 (file)
@@ -89,7 +89,7 @@ struct ref_to_worktree_entry {
        struct worktree *wt; /* key is wt->head_ref */
 };
 
-static int ref_to_worktree_map_cmpfnc(const void *unused_lookupdata,
+static int ref_to_worktree_map_cmpfnc(const void *UNUSED(lookupdata),
                                      const struct hashmap_entry *eptr,
                                      const struct hashmap_entry *kptr,
                                      const void *keydata_aka_refname)
diff --git a/refs.c b/refs.c
index 38b1165189f93da4afd16ff741aa81eb32e9809e..5012bba35785e689e9dd3433801afc32cb328adc 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1815,7 +1815,7 @@ struct ref_store_hash_entry
        char name[FLEX_ARRAY];
 };
 
-static int ref_store_hash_cmp(const void *unused_cmp_data,
+static int ref_store_hash_cmp(const void *UNUSED(cmp_data),
                              const struct hashmap_entry *eptr,
                              const struct hashmap_entry *entry_or_key,
                              const void *keydata)
index 029fc630b95d030d717671803dcc4195ed25b00b..ef12aba91dc3955b2b99f5ad8d4692a839590a4b 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -86,7 +86,7 @@ struct remotes_hash_key {
        int len;
 };
 
-static int remotes_hash_cmp(const void *unused_cmp_data,
+static int remotes_hash_cmp(const void *UNUSED(cmp_data),
                            const struct hashmap_entry *eptr,
                            const struct hashmap_entry *entry_or_key,
                            const void *keydata)
@@ -170,7 +170,7 @@ struct branches_hash_key {
        int len;
 };
 
-static int branches_hash_cmp(const void *unused_cmp_data,
+static int branches_hash_cmp(const void *UNUSED(cmp_data),
                             const struct hashmap_entry *eptr,
                             const struct hashmap_entry *entry_or_key,
                             const void *keydata)
index 6c7250d6a8b350de31fc089978abe022bbbed93b..5eb71e32d0d394db09aa6f6ebe41d75e1e4c1100 100644 (file)
@@ -119,10 +119,10 @@ struct path_and_oids_entry {
        struct oidset trees;
 };
 
-static int path_and_oids_cmp(const void *hashmap_cmp_fn_data,
+static int path_and_oids_cmp(const void *UNUSED(hashmap_cmp_fn_data),
                             const struct hashmap_entry *eptr,
                             const struct hashmap_entry *entry_or_key,
-                            const void *keydata)
+                            const void *UNUSED(keydata))
 {
        const struct path_and_oids_entry *e1, *e2;
 
index 5f22b7cd37798ef9f9b1cfec2dfa7504175ad763..e5b52651f88610a0ad5022a1cd2a13f701d0a42e 100644 (file)
@@ -5254,7 +5254,8 @@ struct labels_entry {
        char label[FLEX_ARRAY];
 };
 
-static int labels_cmp(const void *fndata, const struct hashmap_entry *eptr,
+static int labels_cmp(const void *UNUSED(fndata),
+                     const struct hashmap_entry *eptr,
                      const struct hashmap_entry *entry_or_key, const void *key)
 {
        const struct labels_entry *a, *b;
@@ -6131,7 +6132,7 @@ struct subject2item_entry {
        char subject[FLEX_ARRAY];
 };
 
-static int subject2item_cmp(const void *fndata,
+static int subject2item_cmp(const void *UNUSED(fndata),
                            const struct hashmap_entry *eptr,
                            const struct hashmap_entry *entry_or_key,
                            const void *key)
index ee48635708219e66bf03bad6f5e9100c766d2fb7..4e79734e4f995b137ac702fa204a3a2daceb8f9b 100644 (file)
--- a/strmap.c
+++ b/strmap.c
@@ -2,10 +2,10 @@
 #include "strmap.h"
 #include "mem-pool.h"
 
-int cmp_strmap_entry(const void *hashmap_cmp_fn_data,
+int cmp_strmap_entry(const void *UNUSED(hashmap_cmp_fn_data),
                     const struct hashmap_entry *entry1,
                     const struct hashmap_entry *entry2,
-                    const void *keydata)
+                    const void *UNUSED(keydata))
 {
        const struct strmap_entry *e1, *e2;
 
index cae56ae6b8077547a35eda62bb3d250ca6d6510b..bd6a372a670a4c56eaaa978111824685c9f53aae 100644 (file)
@@ -5,10 +5,10 @@
 #include "sigchain.h"
 #include "pkt-line.h"
 
-int cmd2process_cmp(const void *unused_cmp_data,
+int cmd2process_cmp(const void *UNUSED(cmp_data),
                    const struct hashmap_entry *eptr,
                    const struct hashmap_entry *entry_or_key,
-                   const void *unused_keydata)
+                   const void *UNUSED(keydata))
 {
        const struct subprocess_entry *e1, *e2;
 
index c2ac7e7bf39b2eb9c273a11fb457b0dbc7369aa6..d7a8ca0269a9f08b3edd55343052492b2fc40898 100644 (file)
@@ -38,10 +38,10 @@ enum lookup_type {
        lookup_path
 };
 
-static int config_path_cmp(const void *unused_cmp_data,
+static int config_path_cmp(const void *UNUSED(cmp_data),
                           const struct hashmap_entry *eptr,
                           const struct hashmap_entry *entry_or_key,
-                          const void *unused_keydata)
+                          const void *UNUSED(keydata))
 {
        const struct submodule_entry *a, *b;
 
@@ -52,10 +52,10 @@ static int config_path_cmp(const void *unused_cmp_data,
               !oideq(&a->config->gitmodules_oid, &b->config->gitmodules_oid);
 }
 
-static int config_name_cmp(const void *unused_cmp_data,
+static int config_name_cmp(const void *UNUSED(cmp_data),
                           const struct hashmap_entry *eptr,
                           const struct hashmap_entry *entry_or_key,
-                          const void *unused_keydata)
+                          const void *UNUSED(keydata))
 {
        const struct submodule_entry *a, *b;