On 5/9/24 12:57 PM, Edward Liaw wrote:
lib.mk will add -D_GNU_SOURCE to CFLAGS by default. This will make it unnecessary to add #define _GNU_SOURCE in the source code.
Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX") Suggested-by: John Hubbard jhubbard@nvidia.com Signed-off-by: Edward Liaw edliaw@google.com
tools/testing/selftests/Makefile | 4 ++-- tools/testing/selftests/lib.mk | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)
Hi Edward,
This looks good, with one small refactoring opportunity remaining, though:
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index f0431e6cb67e..9039f3709aff 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -170,11 +170,11 @@ ifneq ($(KBUILD_OUTPUT),) # $(realpath ...) resolves symlinks abs_objtree := $(realpath $(abs_objtree)) BUILD := $(abs_objtree)/kselftest
- KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_objtree}/usr/include
- KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include else BUILD := $(CURDIR) abs_srctree := $(shell cd $(top_srcdir) && pwd)
- KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_srctree}/usr/include
- KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include
As mentioned in [1] (but there are a lot of patches to manage here, and I think it got overlooked), you could factor out the duplicated -D_GNU_SOURCE items into a single place:
[1] https://lore.kernel.org/all/ac8c217e-4109-4ca7-a7dd-fc4fc8b0a4de@nvidia.com/
thanks,