[PATCH 10/23] include: fix compiler warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This change has motivation to make -Wall -pedantic compiler options to
spit a little bit less noise, which with luck will increase change to
notice real issues.

Multiple of these:

warning: ISO C forbids braced-groups within expressions [-Wpedantic]

And nearly 300 times reported:

include/c.h:75:41: warning: struct has no named members [-Wpedantic]
 #define UL_BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 include/c.h    | 10 +++++-----
 include/list.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/c.h b/include/c.h
index e423e8b..0f6e5b2 100644
--- a/include/c.h
+++ b/include/c.h
@@ -37,7 +37,7 @@
 # define __must_be_array(a) \
 	UL_BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(__typeof__(a), __typeof__(&a[0])))
 
-# define ignore_result(x) ({ \
+# define ignore_result(x) __extension__ ({ \
 	__typeof__(x) __dummy __attribute__((__unused__)) = (x); (void) __dummy; \
 })
 
@@ -72,7 +72,7 @@
  * e.g. in a structure initializer (or wherever else comma expressions
  * aren't permitted).
  */
-#define UL_BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
+#define UL_BUILD_BUG_ON_ZERO(e) __extension__ (sizeof(struct { int:-!!(e); }))
 #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
 
 #ifndef ARRAY_SIZE
@@ -92,7 +92,7 @@
 #endif
 
 #ifndef min
-# define min(x, y) ({				\
+# define min(x, y) __extension__ ({		\
 	__typeof__(x) _min1 = (x);		\
 	__typeof__(y) _min2 = (y);		\
 	(void) (&_min1 == &_min2);		\
@@ -100,7 +100,7 @@
 #endif
 
 #ifndef max
-# define max(x, y) ({				\
+# define max(x, y) __extension__ ({		\
 	__typeof__(x) _max1 = (x);		\
 	__typeof__(y) _max2 = (y);		\
 	(void) (&_max1 == &_max2);		\
@@ -112,7 +112,7 @@
 #endif
 
 #ifndef container_of
-#define container_of(ptr, type, member) ({                       \
+#define container_of(ptr, type, member) __extension__ ({	 \
 	const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
 	(type *)( (char *)__mptr - offsetof(type,member) );})
 #endif
diff --git a/include/list.h b/include/list.h
index cfbdb16..3c08aa5 100644
--- a/include/list.h
+++ b/include/list.h
@@ -166,7 +166,7 @@ _INLINE_ void list_splice(struct list_head *list, struct list_head *head)
  * @type:	the type of the struct this is embedded in.
  * @member:	the name of the list_struct within the struct.
  */
-#define list_entry(ptr, type, member) ({              \
+#define list_entry(ptr, type, member) __extension__ ({              \
 	const typeof( ((type *)0)->member ) *__mptr = (ptr);   \
 	(type *)( (char *)__mptr - offsetof(type,member) );})
 
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux