diff mbox series

[RFC] btrfs-progs: fix static_assert for older gcc

Message ID 9eaa8a7f31c2904784aac4c877df30b28ab908ae.1683206755.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series [RFC] btrfs-progs: fix static_assert for older gcc | expand

Commit Message

Anand Jain May 4, 2023, 1:56 p.m. UTC
Make is failing on gcc 8.5 with the following error. It looks like the
definition of static_assert has changed

[CC]   btrfs.o
In file included from ./kernel-shared/ctree.h:30,
         from kernel-shared/volumes.h:23,
         from btrfs.c:24:
./kernel-shared/accessors.h: In function 'btrfs_device_total_bytes':
./kernel-shared/accessors.h:118:58: error: expected ',' before ')' token
     sizeof(((struct btrfs_dev_item *)0))->total_bytes);

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 kernel-shared/accessors.h | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shared/accessors.h b/kernel-shared/accessors.h
index 667dcbb8cf47..c917169f447a 100644
--- a/kernel-shared/accessors.h
+++ b/kernel-shared/accessors.h
@@ -58,29 +58,31 @@  DECLARE_BTRFS_SETGET_BITS(16)
 DECLARE_BTRFS_SETGET_BITS(32)
 DECLARE_BTRFS_SETGET_BITS(64)
 
+#define _static_assert(x)	static_assert(x, "")
+
 #define BTRFS_SETGET_FUNCS(name, type, member, bits)			\
 static inline u##bits btrfs_##name(const struct extent_buffer *eb,	\
 				   const type *s)			\
 {									\
-	static_assert(sizeof(u##bits) == sizeof(((type *)0))->member);	\
+	_static_assert(sizeof(u##bits) == sizeof(((type *)0))->member);	\
 	return btrfs_get_##bits(eb, s, offsetof(type, member));		\
 }									\
 static inline void btrfs_set_##name(const struct extent_buffer *eb, type *s, \
 				    u##bits val)			\
 {									\
-	static_assert(sizeof(u##bits) == sizeof(((type *)0))->member);	\
+	_static_assert(sizeof(u##bits) == sizeof(((type *)0))->member);	\
 	btrfs_set_##bits(eb, s, offsetof(type, member), val);		\
 }									\
 static inline u##bits btrfs_token_##name(struct btrfs_map_token *token,	\
 					 const type *s)			\
 {									\
-	static_assert(sizeof(u##bits) == sizeof(((type *)0))->member);	\
+	_static_assert(sizeof(u##bits) == sizeof(((type *)0))->member);	\
 	return btrfs_get_token_##bits(token, s, offsetof(type, member));\
 }									\
 static inline void btrfs_set_token_##name(struct btrfs_map_token *token,\
 					  type *s, u##bits val)		\
 {									\
-	static_assert(sizeof(u##bits) == sizeof(((type *)0))->member);	\
+	_static_assert(sizeof(u##bits) == sizeof(((type *)0))->member);	\
 	btrfs_set_token_##bits(token, s, offsetof(type, member), val);	\
 }
 
@@ -114,7 +116,7 @@  static inline void btrfs_set_##name(type *s, u##bits val)		\
 static inline u64 btrfs_device_total_bytes(const struct extent_buffer *eb,
 					   struct btrfs_dev_item *s)
 {
-	static_assert(sizeof(u64) ==
+	_static_assert(sizeof(u64) ==
 		      sizeof(((struct btrfs_dev_item *)0))->total_bytes);
 	return btrfs_get_64(eb, s, offsetof(struct btrfs_dev_item,
 					    total_bytes));
@@ -128,7 +130,7 @@  static inline void btrfs_set_device_total_bytes(const struct extent_buffer *eb,
 						struct btrfs_dev_item *s,
 						u64 val)
 {
-	static_assert(sizeof(u64) ==
+	_static_assert(sizeof(u64) ==
 		      sizeof(((struct btrfs_dev_item *)0))->total_bytes);
 	btrfs_set_64(eb, s, offsetof(struct btrfs_dev_item, total_bytes), val);
 }