diff mbox series

[2/2] selftests/pidfd: fix building with clang-20

Message ID 20250311160706.75319-2-dmantipov@yandex.ru (mailing list archive)
State New
Headers show
Series [1/2] selftests/pid_namespace: fix building with clang-20 | expand

Commit Message

Dmitry Antipov March 11, 2025, 4:07 p.m. UTC
When using 'make LLVM=1 W=1 -C tools/testing/selftests/pidfd' with
clang-20, I've noticed the following:

pidfd_fdinfo_test.c:230:6: error: call to undeclared function 'mount';
ISO C99 and later do not support implicit function declarations
[-Wimplicit-function-declaration]
  230 |         r = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0);
      |             ^
pidfd_fdinfo_test.c:230:29: error: use of undeclared identifier 'MS_REC'
  230 |         r = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0);
      |                                    ^

and:

pidfd_setns_test.c:172:40: error: call to undeclared function 'ioctl';
ISO C99 and later do not support implicit function declarations
[-Wimplicit-function-declaration]
  172 |                 self->child_pidfd_derived_nsfds[i] = \
                               ioctl(self->pidfd, info->pidfd_ioctl, 0);
      |                        ^

So include '<sys/mount.h>' and 'sys/ioctl.h', respectively,
to add all of the required declarations.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | 1 +
 tools/testing/selftests/pidfd/pidfd_setns_test.c  | 1 +
 2 files changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c
index f062a986e382..f718aac75068 100644
--- a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c
@@ -13,6 +13,7 @@ 
 #include <syscall.h>
 #include <sys/wait.h>
 #include <sys/mman.h>
+#include <sys/mount.h>
 
 #include "pidfd.h"
 #include "../kselftest.h"
diff --git a/tools/testing/selftests/pidfd/pidfd_setns_test.c b/tools/testing/selftests/pidfd/pidfd_setns_test.c
index 222f8131283b..9b0cebe263bc 100644
--- a/tools/testing/selftests/pidfd/pidfd_setns_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_setns_test.c
@@ -16,6 +16,7 @@ 
 #include <unistd.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
+#include <sys/ioctl.h>
 #include <linux/ioctl.h>
 
 #include "pidfd.h"