]> git.ipfire.org Git - thirdparty/git.git/commitdiff
mark "pointless" data pointers in callbacks
authorJeff King <peff@peff.net>
Fri, 24 Feb 2023 06:39:15 +0000 (01:39 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Feb 2023 17:13:30 +0000 (09:13 -0800)
Both the object_array_filter() and trie_find() functions use callback
functions that let the caller specify which elements match. These
callbacks take a void pointer in case the caller wants to pass in extra
data. But in each case, the single user of these functions just passes
NULL, and the callback ignores the extra pointer.

We could just remove these unused parameters from the callback interface
entirely. But it's good practice to provide such a pointer, as it guides
future callers of the function in the right direction (rather than
tempting them to access global data). Plus it's consistent with other
generic callback interfaces.

So let's instead annotate the unused parameters, in order to silence the
compiler's -Wunused-parameter warning.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
path.c
revision.c

diff --git a/path.c b/path.c
index 492e17ad12106233ddde63b724992f388693be10..0b641233e32248d00b4fd03d1db009d7012b3606 100644 (file)
--- a/path.c
+++ b/path.c
@@ -347,7 +347,8 @@ static void init_common_trie(void)
  * Helper function for update_common_dir: returns 1 if the dir
  * prefix is common.
  */
-static int check_common(const char *unmatched, void *value, void *baton)
+static int check_common(const char *unmatched, void *value,
+                       void *baton UNUSED)
 {
        struct common_dir *dir = value;
 
index 21f5f572c22ec7054da6bc20fef26ee2a59a19d5..4a24fc3fcd67a0b325a9bd0d9416dd0cf108d1ef 100644 (file)
@@ -4159,7 +4159,7 @@ static struct commit *get_revision_1(struct rev_info *revs)
  * Return true for entries that have not yet been shown.  (This is an
  * object_array_each_func_t.)
  */
-static int entry_unshown(struct object_array_entry *entry, void *cb_data_unused)
+static int entry_unshown(struct object_array_entry *entry, void *cb_data UNUSED)
 {
        return !(entry->item->flags & SHOWN);
 }