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
This commit is contained in:
Jilles Tjoelker 2011-04-17 16:04:39 +00:00
parent 322ffb5ca9
commit a4646b9313
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=220742

View File

@ -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)))
/*