Skip to contentSkip to conversation

utils: fix -Wcast-align warnings on sparc

PATCH New Patrick McHardy 1 participant 1 message Apr 9, 2014 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils: fix -Wcast-align warnings on sparc

The cast to char * in the container_of() marcro causes warnings for all list iteration helpers on sparc:

warning: cast increases required alignment of target type [-Wcast-align]

Fix by using a void * for address calculations.

---
 include/utils.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/utils.h +1 -1
index 854986f..88ee0c9 100644
@@ -44,7 +44,7 @@
 
 #define container_of(ptr, type, member) ({			\
 	typeof( ((type *)0)->member ) *__mptr = (ptr);		\
-	(type *)( (char *)__mptr - offsetof(type,member) );})
+	(type *)( (void *)__mptr - offsetof(type,member) );})
 
 #define field_sizeof(t, f)	(sizeof(((t *)NULL)->f))
 #define array_size(arr)		(sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
Signature · 1 line
1.9.0