Skip to contentSkip to conversation

selftests/resctrl: Move _GNU_SOURCE define into Makefile

PATCH New Ilpo Järvinen 1 participant 1 message Sep 13, 2023

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

PATCH 1/1 selftests/resctrl: Move _GNU_SOURCE define into Makefile

Currently, _GNU_SOURCE is defined in resctrl.h. Defining _GNU_SOURCE has a large impact on what gets defined when including headers either before or after it. This can result in compile failures if .c file decides to include a standard header file before resctrl.h.

It is safer to define _GNU_SOURCE in Makefile so it is always defined regardless of in which order includes are done.

---
 tools/testing/selftests/resctrl/Makefile  | 2 +-
 tools/testing/selftests/resctrl/resctrl.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/resctrl/Makefile +1 -1
index 5073dbc96125..2deac2031de9 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2
+CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE
 CFLAGS += $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := resctrl_tests
tools/testing/selftests/resctrl/resctrl.h +0 -1
index 838d1a438f33..eff178befe4a 100644
@@ -1,5 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-#define _GNU_SOURCE
 #ifndef RESCTRL_H
 #define RESCTRL_H
 #include <stdio.h>
Signature · 1 line
2.30.2