Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Allow using CMSG_NXTHDR with -Wcast-align.
details: https://anonhg.NetBSD.org/src/rev/b0458e01cbf5
branches: trunk
changeset: 773248:b0458e01cbf5
user: roy <roy%NetBSD.org@localhost>
date: Sun Jan 29 18:33:07 2012 +0000
description:
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
diffstat:
sys/sys/socket.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diffs (18 lines):
diff -r 9d93b51c0cde -r b0458e01cbf5 sys/sys/socket.h
--- a/sys/sys/socket.h Sun Jan 29 18:29:11 2012 +0000
+++ b/sys/sys/socket.h Sun Jan 29 18:33:07 2012 +0000
@@ -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 @@
__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)))
/*
Home |
Main Index |
Thread Index |
Old Index