From: Neil Brown Date: Mon, 29 May 2006 02:06:32 +0000 (+0000) Subject: This is to avoid gcc warnings when building with strict-aliasing optimization X-Git-Tag: mdadm-2.5.1~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1ec2d6a74ca0a4d139563c2a2a08f7903355843;p=thirdparty%2Fmdadm.git This is to avoid gcc warnings when building with strict-aliasing optimization fix for another srict-aliasing problem, you can typecast a reference to a void pointer to anything, you cannot typecast a reference to a struct. From: Luca Berra Signed-off-by: Neil Brown --- diff --git a/dlink.h b/dlink.h index 15cab938..8e3f4cf9 100644 --- a/dlink.h +++ b/dlink.h @@ -4,16 +4,16 @@ struct __dl_head { - struct __dl_head * dh_prev; - struct __dl_head * dh_next; + void * dh_prev; + void * dh_next; }; #define dl_alloc(size) ((void*)(((char*)calloc(1,(size)+sizeof(struct __dl_head)))+sizeof(struct __dl_head))) #define dl_new(t) ((t*)dl_alloc(sizeof(t))) #define dl_newv(t,n) ((t*)dl_alloc(sizeof(t)*n)) -#define dl_next(p) *((void**)&(((struct __dl_head*)(p))[-1].dh_next)) -#define dl_prev(p) *((void**)&(((struct __dl_head*)(p))[-1].dh_prev)) +#define dl_next(p) *(&(((struct __dl_head*)(p))[-1].dh_next)) +#define dl_prev(p) *(&(((struct __dl_head*)(p))[-1].dh_prev)) void *dl_head(void); char *dl_strdup(char *);