From: Ben Pfaff Date: Fri, 7 May 2010 00:04:11 +0000 (-0700) Subject: util: Fix GCC false-positive warning for CONTAINER_OF. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26adc8ddd75df99c17bf4bbe8dac5562213866bc;p=openvswitch 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. --- 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" {