From a4646b93139c61e490ffdfbae284fe84d9e7cdba Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sun, 17 Apr 2011 16:04:39 +0000 Subject: [PATCH] Allow using CMSG_NXTHDR with -Wcast-align. If various checks are omitted, the CMSG_NXTHDR macro expands to (struct cmsghdr *)((char *)(cmsg) + \ _ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len)) Although there is no alignment problem (assuming cmsg is properly aligned and _ALIGN is correct), this violates -Wcast-align on strict-alignment architectures. Therefore an intermediate cast to void * is appropriate here. There is no workaround other than not using -Wcast-align. MFC after: 2 weeks --- sys/sys/socket.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 6a5821988c2..7800c42b897 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -515,7 +515,7 @@ struct sockcred { _ALIGN(sizeof(struct cmsghdr)) > \ (char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \ (struct cmsghdr *)0 : \ - (struct cmsghdr *)((char *)(cmsg) + \ + (struct cmsghdr *)(void *)((char *)(cmsg) + \ _ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len))) /*