[LTP] [PATCH] openat2: Move includes to lapi, remove _GNU_SOURCE

Petr Vorel pvorel@suse.cz
Thu Feb 5 11:25:10 CET 2026


> On Thu, Feb 05, 2026 at 02:08:42PM +0800, Li Wang wrote:
> > On Wed, Feb 04, 2026 at 01:43:23PM +0100, Petr Vorel wrote:
> > > 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

> > Interesting, I haven't figure out why it can be built within glibc itself.

> I think that becuase it uses '-D_GNU_SOURCE' cflags has already globally
> enabled the GNU extension (equivalent to '#define _GNU_SOURCE'), which is
> done uniformly by glibc's build system.

Interesting, I did not know they compile tree with _GNU_SOURCE.

>  glibc/Makerules: ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -D_GNU_SOURCE \
> 			-DIS_IN_build -include $(common-objpfx)config.h

Yes, -D is equivalent to #define.  IMHO it's better to use #define _GNU_SOURCE
(more obvious than command line switch).

> To verify this, when I add the '-D_GNU_SOURCE' cflgs in the LTP/openat20*.c
> compliation, it build succeed as well:

>  # gcc -I../../../../include -I../../../../include \
>    -I../../../../include/old/ -Wformat -Werror=format-security \
>    -Werror=implicit-function-declaration -Werror=return-type -fno-common \
>    -g -O2 -fno-strict-aliasing -pipe -Wall -W -Wold-style-definition \
>    -D_GNU_SOURCE \
>    -std=gnu99 -L../../../../lib openat202.c  -lltp -o openat202

> So, to this patch, we need to add the _GNU_SOURCE definition.

Thanks for investigating, I'm sorry for bothering with it.

Kind regards,
Petr


More information about the ltp mailing list