[PATCH v2 11/11] xfsprogs: Prefix LIST_... macros to XFS_LIST_...

Jan Tulak
2015-08-03T14:40:36Z

OS X has two conflicting LIST_ macros:
- LIST_HEAD
- LIST_HEAD_INIT

These results in tons of warnings like:

In file included from init.c:22:
In file included from ./libxfs_priv.h:63:
../include/xfs/list.h:32:9: warning: 'LIST_HEAD' macro redefined
[-Wmacro-redefined]
\#define LIST_HEAD(name) \

These macros are included from sys/queue.h through
sys/mount.h and possibly through more system libraries.
So far, I didn't found a way how to prevent the inclusion.

Attempted solution was to avoid including with
-D_SYS_QUEUE_H_ for the compiler, but this resulted in
another error:

In file included from crc32.c:36:
In file included from ../include/xfs/platform_defs.h:79:
In file included from ../include/xfs/darwin.h:26:
In file included from /usr/include/sys/mount.h:76:
In file included from /usr/include/sys/attr.h:42:
/usr/include/sys/ucred.h:90:2: error: type name requires a specifier or
qualifier
TAILQ_ENTRY(ucred) cr_link; /* never modify this without KAUTH_CRE...

I tried renaming. This works, but it doesn't look like
a good solution. So this patch is still not final.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
include/list.h | 6 +++---
repair/phase6.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/list.h b/include/list.h
index 3f087a4..7e9f748 100644
--- a/include/list.h
+++ b/include/list.h
@@ -27,10 +27,10 @@ struct list_head {
struct list_head *prev;
};

-#define LIST_HEAD_INIT(name) { &(name), &(name) }
+#define XFS_LIST_HEAD_INIT(name) { &(name), &(name) }

-#define LIST_HEAD(name) \
- struct list_head name = LIST_HEAD_INIT(name)
+#define XFS_LIST_HEAD(name) \
+ struct list_head name = XFS_LIST_HEAD_INIT(name)

#define INIT_LIST_HEAD(list) list_head_init(list)
static inline void list_head_init(struct list_head *list)
diff --git a/repair/phase6.c b/repair/phase6.c
index 9a5cba7..87732e1 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -49,7 +49,7 @@ typedef struct dotdot_update {
int ino_offset;
} dotdot_update_t;

-static LIST_HEAD(dotdot_update_list);
+static XFS_LIST_HEAD(dotdot_update_list);
static int dotdot_update;

static void
--
2.4.3