diff mbox series

selftests: mm: Fix undeclared function error

Message ID 20240417075530.3807625-1-usama.anjum@collabora.com
State New
Headers show
Series selftests: mm: Fix undeclared function error | expand

Commit Message

Muhammad Usama Anjum April 17, 2024, 7:55 a.m. UTC
Fix the error reported by clang:

In file included from mdwe_test.c:17:
./../kselftest_harness.h:1169:2: error: call to undeclared function
'asprintf'; ISO C99 and later do not support implicit function
declarations [-Wimplicit-function-declaration]
 1169 |         asprintf(&test_name, "%s%s%s.%s", f->name,
      |         ^
1 warning generated.

The gcc reports it as warning:

In file included from mdwe_test.c:17:
../kselftest_harness.h: In function ‘__run_test’:
../kselftest_harness.h:1169:9: warning: implicit declaration of function
‘asprintf’; did you mean ‘vsprintf’? [-Wimplicit-function-declaration]
 1169 |         asprintf(&test_name, "%s%s%s.%s", f->name,
      |         ^~~~~~~~
      |         vsprintf

Fix this by setting _GNU_SOURCE macro needed to get exposure to the
asprintf().

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/mm/mdwe_test.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/tools/testing/selftests/mm/mdwe_test.c b/tools/testing/selftests/mm/mdwe_test.c
index 200bedcdc32e9..1e01d3ddc11c5 100644
--- a/tools/testing/selftests/mm/mdwe_test.c
+++ b/tools/testing/selftests/mm/mdwe_test.c
@@ -7,6 +7,7 @@ 
 #include <linux/mman.h>
 #include <linux/prctl.h>
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/auxv.h>