Re: [PATCH v2 01/10] compiler-context-analysis: Avoid unused parameter warning in _context_unsafe_alias()

From: Marco Elver

Date: Wed Oct 14 2026 - 01:40:47 EST


On Wed, 14 Oct 2026 at 00:26, Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> _context_unsafe_alias() does not use its parameter 'p', which triggers
> -Wunused-parameter when building code that enables -Wextra (such as
> tools/perf, tools/lib/perf, tools/lib/subcmd, and tools/lib/symbol).
> Explicitly cast 'p' to void to silence the warning, matching
> __assume_ctx_lock() and __assume_shared_ctx_lock().
>
> Assisted-by: Antigravity:gemini-3.1-pro
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>

Reviewed-by: Marco Elver <elver@xxxxxxxxxx>

Re __attribute__((unused)): I suppose it could work, but (void)p is
the more minimal solution that is not uncommon across the kernel. I
don't see a downside, and less code is better.

Thanks!

> ---
> include/linux/compiler-context-analysis.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/compiler-context-analysis.h b/include/linux/compiler-context-analysis.h
> index 8302ebc2ea8c..024e303188ad 100644
> --- a/include/linux/compiler-context-analysis.h
> +++ b/include/linux/compiler-context-analysis.h
> @@ -243,7 +243,7 @@
> * alias as a function argument).
> */
> #define context_unsafe_alias(p) _context_unsafe_alias((void **)&(p))
> -static inline void _context_unsafe_alias(void **p) { }
> +static inline void _context_unsafe_alias(void **p) { (void)p; }
>
> /**
> * token_context_lock() - declare an abstract global context lock instance
> --
> 2.56.0.385.gd3acb90ef8-goog
>