* [PATCH] scripts: include: break dependency of list.h on kernel.h
@ 2026-02-05 14:30 Ahmad Fatoum
2026-02-09 13:50 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-02-05 14:30 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
We already got rid of this dependency for the normal barebox build, so
break it up for the scripts/ build as well to avoid this nconf warning
on some distros:
In file included from scripts/kconfig/nconf.c:15:
scripts/kconfig/nconf.h:25:9: warning: ‘max’ redefined
25 | #define max(a, b) ({\
| ^~~
In file included from ./barebox/scripts/include/linux/list.h:5,
from ./barebox/scripts/include/list.h:5,
from scripts/kconfig/expr.h:15,
from scripts/kconfig/lkc.h:13,
from scripts/kconfig/nconf.c:14:
./barebox/scripts/include/linux/kernel.h:39:9: note: this is the location of the previous definition
39 | #define max(x, y) ({ \
| ^~~
scripts/kconfig/nconf.h:30:9: warning: ‘min’ redefined
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
scripts/include/linux/container_of.h | 18 ++++++++++++++++++
scripts/include/linux/kernel.h | 14 +-------------
scripts/include/linux/list.h | 2 +-
3 files changed, 20 insertions(+), 14 deletions(-)
create mode 100644 scripts/include/linux/container_of.h
diff --git a/scripts/include/linux/container_of.h b/scripts/include/linux/container_of.h
new file mode 100644
index 000000000000..ca0ec95667b9
--- /dev/null
+++ b/scripts/include/linux/container_of.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _SCRIPTS_LINUX_CONTAINER_OF_H
+#define _SCRIPTS_LINUX_CONTAINER_OF_H
+
+#ifndef container_of
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({ \
+ const typeof(((type *)0)->member) * __mptr = (ptr); \
+ (type *)((char *)__mptr - offsetof(type, member)); })
+#endif
+
+#endif /* _SCRIPTS_LINUX_CONTAINER_OF_H */
diff --git a/scripts/include/linux/kernel.h b/scripts/include/linux/kernel.h
index f3083ff3545d..672f681931ec 100644
--- a/scripts/include/linux/kernel.h
+++ b/scripts/include/linux/kernel.h
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
+#include <linux/container_of.h>
#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1)
@@ -20,19 +21,6 @@
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
-#ifndef container_of
-/**
- * container_of - cast a member of a structure out to the containing structure
- * @ptr: the pointer to the member.
- * @type: the type of the container struct this is embedded in.
- * @member: the name of the member within the struct.
- *
- */
-#define container_of(ptr, type, member) ({ \
- const typeof(((type *)0)->member) * __mptr = (ptr); \
- (type *)((char *)__mptr - offsetof(type, member)); })
-#endif
-
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
#ifndef max
diff --git a/scripts/include/linux/list.h b/scripts/include/linux/list.h
index d6b24f6b744d..d10e44469974 100644
--- a/scripts/include/linux/list.h
+++ b/scripts/include/linux/list.h
@@ -2,8 +2,8 @@
#define __TOOLS_LINUX_LIST_H
#include <linux/types.h>
-#include <linux/kernel.h>
#include <linux/compiler.h>
+#include <linux/container_of.h>
/*
* Simple doubly linked list implementation.
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] scripts: include: break dependency of list.h on kernel.h
2026-02-05 14:30 [PATCH] scripts: include: break dependency of list.h on kernel.h Ahmad Fatoum
@ 2026-02-09 13:50 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-02-09 13:50 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Thu, 05 Feb 2026 15:30:42 +0100, Ahmad Fatoum wrote:
> We already got rid of this dependency for the normal barebox build, so
> break it up for the scripts/ build as well to avoid this nconf warning
> on some distros:
>
> In file included from scripts/kconfig/nconf.c:15:
> scripts/kconfig/nconf.h:25:9: warning: ‘max’ redefined
> 25 | #define max(a, b) ({\
> | ^~~
> In file included from ./barebox/scripts/include/linux/list.h:5,
> from ./barebox/scripts/include/list.h:5,
> from scripts/kconfig/expr.h:15,
> from scripts/kconfig/lkc.h:13,
> from scripts/kconfig/nconf.c:14:
> ./barebox/scripts/include/linux/kernel.h:39:9: note: this is the location of the previous definition
> 39 | #define max(x, y) ({ \
> | ^~~
> scripts/kconfig/nconf.h:30:9: warning: ‘min’ redefined
>
> [...]
Applied, thanks!
[1/1] scripts: include: break dependency of list.h on kernel.h
https://git.pengutronix.de/cgit/barebox/commit/?id=c917e41c99c6 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-09 13:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-05 14:30 [PATCH] scripts: include: break dependency of list.h on kernel.h Ahmad Fatoum
2026-02-09 13:50 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox