[PATCH v3 3/8] selftests: kselftest.h: Add unused macro

Muhammad Usama Anjum usama.anjum at collabora.com
Fri Aug 22 01:21:00 PDT 2025


Add unused macro instead of using the complete verbose unused compiler
attribute. The raw __attribute__((__unused__)) is quite long and makes
code too much verbose to the kernel developer's taste.

Add always_unused and maybe_unused variants just like kernel itself
have.

Signed-off-by: Muhammad Usama Anjum <usama.anjum at collabora.com>
---
Changes since v2:
- Add always_unused and maybe_unused instead of __unused macro
---
 tools/testing/selftests/kselftest.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
index c3b6d2604b1e4..274480e3573ab 100644
--- a/tools/testing/selftests/kselftest.h
+++ b/tools/testing/selftests/kselftest.h
@@ -92,6 +92,14 @@
 #endif
 #define __printf(a, b)   __attribute__((format(printf, a, b)))
 
+#ifndef __always_unused
+#define __always_unused __attribute__((__unused__))
+#endif
+
+#ifndef __maybe_unused
+#define __maybe_unused __attribute__((__unused__))
+#endif
+
 /* counters */
 struct ksft_count {
 	unsigned int ksft_pass;
-- 
2.47.2




More information about the linux-riscv mailing list