svn commit: r220742 - head/sys/sys
Jilles Tjoelker
jilles at FreeBSD.org
Sun Apr 17 16:04:39 UTC 2011
Author: jilles
Date: Sun Apr 17 16:04:39 2011
New Revision: 220742
URL: http://svn.freebsd.org/changeset/base/220742
Log:
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
Modified:
head/sys/sys/socket.h
Modified: head/sys/sys/socket.h
==============================================================================
--- head/sys/sys/socket.h Sun Apr 17 15:09:04 2011 (r220741)
+++ head/sys/sys/socket.h Sun Apr 17 16:04:39 2011 (r220742)
@@ -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)))
/*
More information about the svn-src-head
mailing list