Skip to contentSkip to conversation

selftests/coredump: drop unused <linux/fs.h> include

PATCH New Nikolai Dokutovich 1 participant 2 messages Nov 21

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 selftests/coredump: drop unused <linux/fs.h> include

<linux/fs.h> pulls in <linux/mount.h>, which defines the MS_* flags as macros. <sys/mount.h> declares the same flags as enum constants, so having <linux/fs.h> earlier in the file makes the macros expand inside the enum declaration and the build fails:

/usr/include/x86_64-linux-gnu/sys/mount.h:35:3:
error: expected identifier before numeric constant

The include is not used by this test. Drop it.

Seen with glibc 2.35 on Ubuntu 22.04.

Fixes 59cd658eaf40 ("selftests/coredump: add coredump server selftests")
---
 tools/testing/selftests/coredump/stackdump_test.c | 1 -
 1 file changed, 1 deletion(-)
tools/testing/selftests/coredump/stackdump_test.c +0 -1
index 1ec88937a1c2..8a681e486c3e 100644
@@ -6,7 +6,6 @@
 #include <libgen.h>
 #include <limits.h>
 #include <linux/coredump.h>
-#include <linux/fs.h>
 #include <linux/limits.h>
 #include <pthread.h>
 #include <string.h>
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 selftests/coredump: include <stddef.h> for offsetof

Both files use offsetof() without including <stddef.h>. offsetof() is a macro; without the header it is not expanded, so its first argument is parsed as a function argument and the type name fails to compile:

coredump_test_helpers.c:1309:26:
error: expected expression before struct

Include <stddef.h> in the two files that use offsetof().

Fixes c71147f42bff ("selftests/coredump: split out common helpers")
Fixes c09ea6659e50 ("selftests/coredump: split out coredump socket tests")
---
 tools/testing/selftests/coredump/coredump_socket_test.c  | 1 +
 tools/testing/selftests/coredump/coredump_test_helpers.c | 1 +
 2 files changed, 2 insertions(+)
tools/testing/selftests/coredump/coredump_socket_test.c +1 -0
index ec73bb690bbc..c17f3c88a00b 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 
+#include <stddef.h>
 #include <sys/stat.h>
 #include <sys/epoll.h>
 #include <sys/socket.h>
tools/testing/selftests/coredump/coredump_test_helpers.c +1 -0
index 072ab8624808..85bf5cdf4c4a 100644
@@ -15,6 +15,7 @@
 #include <poll.h>
 #include <pthread.h>
 #include <stdbool.h>
+#include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
Signature · 1 line
2.34.1