[PATCH v2 3/8] selftests: kselftest.h: Add __unused macro

John Hubbard jhubbard at nvidia.com
Sat Aug 2 16:35:55 PDT 2025


On 7/31/25 9:01 AM, Muhammad Usama Anjum wrote:
...
> diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
> index c3b6d2604b1e4..8d17036d88396 100644
> --- a/tools/testing/selftests/kselftest.h
> +++ b/tools/testing/selftests/kselftest.h
> @@ -92,6 +92,10 @@
>  #endif
>  #define __printf(a, b)   __attribute__((format(printf, a, b)))
>  
> +#ifndef __unused
> +#define __unused         __attribute__((__unused__))
> +#endif

Hi Muhammad,

In case you're interested in going slightly deeper on this:

Entertainingly, there are several kselftest dirs that also use this
attribute directly, and I quite enjoyed seeing that the *same* attribute
is now defined as:

    __maybe_unused
    __always_unused
    __unused         # from your patch here

$ git grep -n  '__attribute__((__unused__))'
bpf/prog_tests/sockmap_helpers.h:11:#define __always_unused     __attribute__((__unused__))
landlock/audit.h:28:#define __maybe_unused __attribute__((__unused__))
landlock/common.h:26:#define __maybe_unused __attribute__((__unused__))
mm/pkey-helpers.h:88:# define __maybe_unused __attribute__((__unused__))
mm/protection_keys.c:1307:      __attribute__((__unused__)) int peek_result;
net/ovpn/ovpn-cli.c:37:#define __always_unused __attribute__((__unused__))
perf_events/watermark_signal.c:20:#define __maybe_unused __attribute__((__unused__))



thanks,
-- 
John Hubbard




More information about the linux-riscv mailing list