Re: [PATCH 5/7] libsupport: remove the LIST_HEAD macro from list.h

Darrick J. Wong
2026-05-05T00:20:21Z

On Mon, May 04, 2026 at 07:32:59PM -0400, Theodore Ts'o wrote:
> The LIST_HEAD macro is defined by both the Linux kernel's list.h and
> <sys/queue.h> (originally from BSD). The problem is that on MacOS,
> some system header file pulls in <sys/queue.h> leading to a macro
> redefiniction conflict. Since we don't use LIST_HEAD in e2fsprogs,
> the simplest mitigation is to just comment out the definition of LIST_HEAD.
>
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
> Fixes: 37dafcc0894b ("libsupport: port the kernel list.h to libsupport")

Sounds fine to me.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
> lib/support/list.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/lib/support/list.h b/lib/support/list.h
> index 0e00e446d..0ec8de525 100644
> --- a/lib/support/list.h
> +++ b/lib/support/list.h
> @@ -36,8 +36,17 @@ static inline void list_head_destroy(struct list_head *list)
>
> #define LIST_HEAD_INIT(name) { &(name), &(name) }
>
> +#if 0
> +/*
> + * This conflicts with the LIST_HEAD defined in <sys/queue.h>. We
> + * don't include it in e2fsprogs, but some systems' header files might
> + * pull it in, leading to the macro redefinition conflict.
> + * Fortunately, we also don't need LIST_HEAD in e2fsprogs, so just
> + * drop this convenience macro.
> + */
> #define LIST_HEAD(name) \
> struct list_head name = LIST_HEAD_INIT(name)
> +#endif
>
> /**
> * INIT_LIST_HEAD - Initialize a list_head structure
> --
> 2.53.0
>
>