selftests/mm: Substitute attribute with a macro
authorMaciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Fri, 13 Oct 2023 11:36:31 +0000 (13:36 +0200)
committerShuah Khan <skhan@linuxfoundation.org>
Fri, 13 Oct 2023 20:08:36 +0000 (14:08 -0600)
Compiling mm selftest after adding a __printf() attribute to
ksft_print_msg() exposes -Wformat warning in remap_region().

Fix the wrong format specifier causing the warning.

The mm selftest uses the printf attribute in its full form. Since the
header file that uses it also includes kselftests.h it can use the macro
defined there.

Use __printf() included with 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/mm/mremap_test.c
tools/testing/selftests/mm/pkey-helpers.h

index 5c3773de9f0f78b1be7df121bdd9cc294037285e..1dbfcf6df2558558399354292a4470c5897f940f 100644 (file)
@@ -338,7 +338,7 @@ static long long remap_region(struct config c, unsigned int threshold_mb,
                char c = (char) rand();
 
                if (((char *) dest_addr)[i] != c) {
-                       ksft_print_msg("Data after remap doesn't match at offset %d\n",
+                       ksft_print_msg("Data after remap doesn't match at offset %llu\n",
                                       i);
                        ksft_print_msg("Expected: %#x\t Got: %#x\n", c & 0xff,
                                        ((char *) dest_addr)[i] & 0xff);
index 92f3be3dd8e59345fad9c8cb7ade283ca2c5fa55..1af3156a9db8ec1a93a3a20ceb96e490851631bb 100644 (file)
@@ -34,7 +34,7 @@ extern int test_nr;
 extern int iteration_nr;
 
 #ifdef __GNUC__
-__attribute__((format(printf, 1, 2)))
+__printf(1, 2)
 #endif
 static inline void sigsafe_printf(const char *format, ...)
 {