[LTP] [PATCH] openat2: Move includes to lapi, remove _GNU_SOURCE
Petr Vorel
pvorel@suse.cz
Wed Feb 4 13:43:23 CET 2026
Improve 767b3e519e. struct open_how is also used in lapi/openat2.h,
which is used by all openat2*.c tests. Therefore move <fcntl.h> to the
lapi header (and use lapi/fcntl.h instead).
Also remove _GNU_SOURCE which should not be needed.
While at it, move include "config.h" to the top.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi Li,
my points from the original patchset why not use _GNU_SOURCE:
glibc test tst-openat2.c [1] which includes <fcntl.h>, uses struct
open_how and test openat2() does not define it. Neither openat2() nor
struct open_how [2] are guarded by #ifdef __USE_GNU.
O_DIRECTORY is guarded by #ifdef __USE_XOPEN2K8 but this should be safe as we
compile with -std=gnu99.
Kind regards,
Petr
[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/tst-openat2.c
[2] https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/bits/openat2.h
include/lapi/openat2.h | 4 ++--
testcases/kernel/syscalls/openat2/openat201.c | 3 ---
testcases/kernel/syscalls/openat2/openat202.c | 3 ---
testcases/kernel/syscalls/openat2/openat203.c | 3 ---
4 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/include/lapi/openat2.h b/include/lapi/openat2.h
index 03327bdb77..b7e7eadb94 100644
--- a/include/lapi/openat2.h
+++ b/include/lapi/openat2.h
@@ -7,12 +7,12 @@
#ifndef LAPI_OPENAT2_H__
#define LAPI_OPENAT2_H__
+#include "config.h"
#include <sys/syscall.h>
#include <linux/types.h>
#include "lapi/syscalls.h"
-
-#include "config.h"
+#include "lapi/fcntl.h"
#ifndef HAVE_OPENAT2
/*
diff --git a/testcases/kernel/syscalls/openat2/openat201.c b/testcases/kernel/syscalls/openat2/openat201.c
index f4c80bde7b..7cee58930f 100644
--- a/testcases/kernel/syscalls/openat2/openat201.c
+++ b/testcases/kernel/syscalls/openat2/openat201.c
@@ -7,9 +7,6 @@
* Basic :manpage:`openat2(2)` test.
*/
-#define _GNU_SOURCE
-#include <fcntl.h>
-
#include "tst_test.h"
#include "lapi/openat2.h"
diff --git a/testcases/kernel/syscalls/openat2/openat202.c b/testcases/kernel/syscalls/openat2/openat202.c
index 7fa047da67..d0e8fe3b6e 100644
--- a/testcases/kernel/syscalls/openat2/openat202.c
+++ b/testcases/kernel/syscalls/openat2/openat202.c
@@ -7,9 +7,6 @@
* :manpage:`openat2(2)` tests with various resolve flags.
*/
-#define _GNU_SOURCE
-#include <fcntl.h>
-
#include "tst_test.h"
#include "lapi/openat2.h"
diff --git a/testcases/kernel/syscalls/openat2/openat203.c b/testcases/kernel/syscalls/openat2/openat203.c
index 904194334b..9695faa337 100644
--- a/testcases/kernel/syscalls/openat2/openat203.c
+++ b/testcases/kernel/syscalls/openat2/openat203.c
@@ -7,9 +7,6 @@
* Basic :manpage:`openat2(2)` test to check various failures.
*/
-#define _GNU_SOURCE
-#include <fcntl.h>
-
#include "tst_test.h"
#include "lapi/openat2.h"
--
2.51.0
More information about the ltp
mailing list