[LTP] [PATCH 1/1] tst_minmax.h: Include <sys/param.h>

Petr Vorel pvorel@suse.cz
Thu Jan 26 18:53:02 CET 2023


It's always good to first include header which defines macros/structures
before define fallback. In this case it's needed to avoid redefinition:

$ make check-hugemmap15
CHECK testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c
hugemmap15.c: note: in included file:
/usr/include/sys/param.h:102:9: warning: preprocessor token MIN redefined
hugemmap15.c: note: in included file (through ../../../../../include/tst_test.h, testcases/kernel/mem/hugetlb/hugemmap/../lib/hugetlb.h):
../../../../../include/tst_minmax.h:9:10: this was the original definition
hugemmap15.c: note: in included file:
/usr/include/sys/param.h:103:9: warning: preprocessor token MAX redefined
hugemmap15.c: note: in included file (through ../../../../../include/tst_test.h, testcases/kernel/mem/hugetlb/hugemmap/../lib/hugetlb.h):
../../../../../include/tst_minmax.h:18:10: this was the original definition

Redefinitions is done because hugemmap15.c needs tst_test.h for
TST_TEST_TCONF(), but <sys/param.h> which defines MIN/MAX() is later
included.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi,

another trivial fix, which can wait till the release.

Kind regards,
Petr

 include/tst_minmax.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/tst_minmax.h b/include/tst_minmax.h
index 9d7d596fce..1597fbc978 100644
--- a/include/tst_minmax.h
+++ b/include/tst_minmax.h
@@ -1,10 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later
  * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
+ * Copyright (c) Linux Test Project, 2020-2023
  */
 
 #ifndef TST_MINMAX_H__
 #define TST_MINMAX_H__
 
+#include <sys/param.h>
+
 #ifndef MIN
 # define MIN(a, b) ({ \
 	typeof(a) _a = (a); \
-- 
2.39.1



More information about the ltp mailing list