summaryrefslogtreecommitdiff
path: root/lib/tests
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.com>2026-02-11 10:14:35 +0100
committerPetr Mladek <pmladek@suse.com>2026-02-11 10:14:35 +0100
commit9abbecf408cba09d73d14f044e1bc12ab7776da0 (patch)
tree64c2eb801cbbb6a1c83d52e5fb5d568797a4536d /lib/tests
parent7a2c1b27cd6b853e924bb0bbcb01eb64fbb97875 (diff)
parentb07829d546c83134629591f02c5348d57cea0c1e (diff)
Merge branch 'for-6.20' into for-linus
Diffstat (limited to 'lib/tests')
-rw-r--r--lib/tests/printf_kunit.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/tests/printf_kunit.c b/lib/tests/printf_kunit.c
index 7617e5b8b02c..f6f21b445ece 100644
--- a/lib/tests/printf_kunit.c
+++ b/lib/tests/printf_kunit.c
@@ -266,15 +266,17 @@ hash_pointer(struct kunit *kunittest)
KUNIT_EXPECT_MEMNEQ(kunittest, buf, PTR_STR, PTR_WIDTH);
}
-static void
-test_hashed(struct kunit *kunittest, const char *fmt, const void *p)
-{
- char buf[PLAIN_BUF_SIZE];
-
- plain_hash_to_buffer(kunittest, p, buf, PLAIN_BUF_SIZE);
-
- test(buf, fmt, p);
-}
+/*
+ * This is a macro so that the compiler can compare its arguments to the
+ * __printf() attribute on __test(). This cannot be a function with a __printf()
+ * attribute because GCC requires __printf() functions to be variadic.
+ */
+#define test_hashed(kunittest, fmt, p) \
+ do { \
+ char buf[PLAIN_BUF_SIZE]; \
+ plain_hash_to_buffer(kunittest, p, buf, PLAIN_BUF_SIZE); \
+ test(buf, fmt, p); \
+ } while (0)
/*
* NULL pointers aren't hashed.