mark "pointless" data pointers in callbacks

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>

Jeff King committed Feb 24, 2023 at 01:39 UTC d3dcfa047f415de5590b60781dcdf11492e25d41
2 files changed +3 -2
path.c
+2 -1
@@ -347,7 +347,8 @@ static void init_common_trie(void)
347 * Helper function for update_common_dir: returns 1 if the dir
348 * prefix is common.
349 */
350 -static int check_common(const char *unmatched, void *value, void *baton)
350 +static int check_common(const char *unmatched, void *value,
351 + void *baton UNUSED)
352 {
353 struct common_dir *dir = value;
354
revision.c
+1 -1
@@ -4159,7 +4159,7 @@ static struct commit *get_revision_1(struct rev_info *revs)
4159 * Return true for entries that have not yet been shown. (This is an
4160 * object_array_each_func_t.)
4161 */
4162 -static int entry_unshown(struct object_array_entry *entry, void *cb_data_unused)
4162 +static int entry_unshown(struct object_array_entry *entry, void *cb_data UNUSED)
4163 {
4164 return !(entry->item->flags & SHOWN);
4165 }