[PATCH] selftests: coredump: Fix compilation issue

Sahil Chandna posted 1 patch 1 month, 1 week ago
tools/testing/selftests/coredump/stackdump_test.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] selftests: coredump: Fix compilation issue
Posted by Sahil Chandna 1 month, 1 week ago
Building coredump selftests fails on x86 due to following issues:

1./usr/include/x86_64-linux-gnu/sys/mount.h:35:3: error: expected identifier before numeric constant
   35 |   MS_RDONLY = 1,                /* Mount read-only.  */
      |

<linux/fs.h> pulls in kernel-internal headers that conflict with
   glibc's <sys/mount.h>, causing this error.

2.stackdump_test.c:25:1: note: ‘offsetof’ is defined in header ‘<stddef.h>’; did you forget to ‘#include <stddef.h>’?

Missing <stddef.h> causes unresolved use of offsetof().

Fix this by:
  - dropping <linux/fs.h> and including <sys/mount.h>
  - including <stddef.h> for offsetof()

Signed-off-by: Sahil Chandna <chandna.sahil@gmail.com>
---
 tools/testing/selftests/coredump/stackdump_test.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/coredump/stackdump_test.c b/tools/testing/selftests/coredump/stackdump_test.c
index a4ac80bb1003..881565d28fa9 100644
--- a/tools/testing/selftests/coredump/stackdump_test.c
+++ b/tools/testing/selftests/coredump/stackdump_test.c
@@ -6,7 +6,7 @@
 #include <libgen.h>
 #include <limits.h>
 #include <linux/coredump.h>
-#include <linux/fs.h>
+#include <sys/mount.h>
 #include <linux/limits.h>
 #include <pthread.h>
 #include <string.h>
@@ -18,6 +18,7 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <unistd.h>
+#include <stddef.h>
 
 #include "../kselftest_harness.h"
 #include "../filesystems/wrappers.h"
-- 
2.34.1