From 26adc8ddd75df99c17bf4bbe8dac5562213866bc Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 6 May 2010 17:04:11 -0700 Subject: [PATCH] util: Fix GCC false-positive warning for CONTAINER_OF. On sparc, GCC would issue the following warning for every use of CONTAINER_OF: warning: cast increases required alignment of target type This is a false positive: assuming that the data structure that it is applied to was allocated properly, the use of CONTAINER_OF to reach it is valid. And if it was not allocated properly, then code that accesses it other ways will have trouble too. --- lib/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.h b/lib/util.h index 9df6db58..0e9353db 100644 --- a/lib/util.h +++ b/lib/util.h @@ -80,7 +80,7 @@ extern const char *program_name; /* Given POINTER, the address of the given MEMBER in a STRUCT object, returns the STRUCT object. */ #define CONTAINER_OF(POINTER, STRUCT, MEMBER) \ - ((STRUCT *) ((char *) (POINTER) - offsetof (STRUCT, MEMBER))) + ((STRUCT *) (void *) ((char *) (POINTER) - offsetof (STRUCT, MEMBER))) #ifdef __cplusplus extern "C" { -- 2.30.2