From 3cdddcf6b220cb6097b00ff7df1e4d0277ec43c4 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 29 Aug 2024 16:08:33 -0400 Subject: [PATCH 1/2] gc: drop MAYBE_UNUSED annotation from used parameter The "opts" parameter is always used, so marking it with MAYBE_UNUSED is just confusing. This annotation goes back to 41abfe15d9 (maintenance: add pack-refs task, 2021-02-09), when it really was unused. Back then we did not have the UNUSED macro that would complain if the code changed to use the parameter. So when we started using it in bfc2f9eb8e (builtin/gc: forward git-gc(1)'s `--auto` flag when packing refs, 2024-03-25), nobody noticed. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/gc.c b/builtin/gc.c index 427faf1cfe1bdb..8b2ac649efd3a5 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -260,7 +260,7 @@ static int pack_refs_condition(UNUSED struct gc_config *cfg) return 1; } -static int maintenance_task_pack_refs(MAYBE_UNUSED struct maintenance_run_opts *opts, +static int maintenance_task_pack_refs(struct maintenance_run_opts *opts, UNUSED struct gc_config *cfg) { struct child_process cmd = CHILD_PROCESS_INIT; From 516a9ec3d5874aad41757e573f7b841bb45cb098 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 29 Aug 2024 16:09:53 -0400 Subject: [PATCH 2/2] grep: prefer UNUSED to MAYBE_UNUSED for pcre allocators We provide custom malloc/free callbacks for the pcre library to use. Those take an extra "data" parameter, but we don't use it. Back when these were added in 513f2b0bbd (grep: make PCRE2 aware of custom allocator, 2019-10-16), we only had MAYBE_UNUSED. But these days we have UNUSED, which we should prefer, as it will let the compiler inform us if the code changes to actually use the parameters. I also moved the annotations to come after the variable name, which is how we typically spell it. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- grep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grep.c b/grep.c index 2f8b9553df9984..e5761426e4f0f3 100644 --- a/grep.c +++ b/grep.c @@ -245,7 +245,7 @@ static int is_fixed(const char *s, size_t len) #ifdef USE_LIBPCRE2 #define GREP_PCRE2_DEBUG_MALLOC 0 -static void *pcre2_malloc(PCRE2_SIZE size, MAYBE_UNUSED void *memory_data) +static void *pcre2_malloc(PCRE2_SIZE size, void *memory_data UNUSED) { void *pointer = malloc(size); #if GREP_PCRE2_DEBUG_MALLOC @@ -255,7 +255,7 @@ static void *pcre2_malloc(PCRE2_SIZE size, MAYBE_UNUSED void *memory_data) return pointer; } -static void pcre2_free(void *pointer, MAYBE_UNUSED void *memory_data) +static void pcre2_free(void *pointer, void *memory_data UNUSED) { #if GREP_PCRE2_DEBUG_MALLOC static int count = 1;