Module Name:    src
Committed By:   roy
Date:           Sun Jan 29 18:33:07 UTC 2012

Modified Files:
        src/sys/sys: socket.h

Log Message:
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.

Taken from FreeBSD commit r220742 by jilles


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/sys/socket.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/sys/socket.h
diff -u src/sys/sys/socket.h:1.105 src/sys/sys/socket.h:1.106
--- src/sys/sys/socket.h:1.105	Wed Jan 25 00:28:35 2012
+++ src/sys/sys/socket.h	Sun Jan 29 18:33:07 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: socket.h,v 1.105 2012/01/25 00:28:35 christos Exp $	*/
+/*	$NetBSD: socket.h,v 1.106 2012/01/29 18:33:07 roy Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -544,7 +544,7 @@ struct cmsghdr {
 			    __CMSG_ALIGN(sizeof(struct cmsghdr)) > \
 	    (((char *)(mhdr)->msg_control) + (mhdr)->msg_controllen)) ? \
 	    (struct cmsghdr *)0 : \
-	    (struct cmsghdr *)((char *)(cmsg) + \
+	    (struct cmsghdr *)(void *)((char *)(cmsg) + \
 	        __CMSG_ALIGN((cmsg)->cmsg_len)))
 
 /*

Reply via email to