selftests/kvm: Replace attribute with macro
authorMaciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Fri, 13 Oct 2023 11:36:30 +0000 (13:36 +0200)
committerShuah Khan <skhan@linuxfoundation.org>
Fri, 13 Oct 2023 20:08:31 +0000 (14:08 -0600)
The __printf() macro is used in many tools in the linux kernel to
validate the format specifiers in functions that use printf. The kvm
selftest uses it without putting it in a macro definition while it
also imports the kselftests.h header where the macro attribute is
defined.

Use __printf() from kselftests.h instead of the full attribute.

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/kvm/include/test_util.h

index 7e614adc6cf4778b69a7b8f94f6f08608f44baf5..8e5f413a593d94d0757648814d425e2710a9e9e5 100644 (file)
@@ -33,7 +33,7 @@ static inline int _no_printf(const char *format, ...) { return 0; }
 #define pr_info(...) _no_printf(__VA_ARGS__)
 #endif
 
-void print_skip(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
+void __printf(1, 2) print_skip(const char *fmt, ...);
 #define __TEST_REQUIRE(f, fmt, ...)                            \
 do {                                                           \
        if (!(f))                                               \
@@ -46,9 +46,9 @@ ssize_t test_write(int fd, const void *buf, size_t count);
 ssize_t test_read(int fd, void *buf, size_t count);
 int test_seq_read(const char *path, char **bufp, size_t *sizep);
 
-void test_assert(bool exp, const char *exp_str,
-                const char *file, unsigned int line, const char *fmt, ...)
-               __attribute__((format(printf, 5, 6)));
+void __printf(5, 6) test_assert(bool exp, const char *exp_str,
+                               const char *file, unsigned int line,
+                               const char *fmt, ...);
 
 #define TEST_ASSERT(e, fmt, ...) \
        test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__)