summaryrefslogtreecommitdiff
path: root/kern
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-05-23 18:23:45 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-05-23 18:23:45 +0200
commit96ade86f9f410cee6377f60530bcc3aa89b20402 (patch)
treebc41452e63602449af74218cf42b89232430a382 /kern
parent417ca3833d651a89dc55462739f9dbb9f7af7866 (diff)
kern: avoid breaking the strict-aliasing rules
* kern/exception.c (exception_parse_reply): Use `BAD_TYPECHECK'.
Diffstat (limited to 'kern')
-rw-r--r--kern/exception.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/kern/exception.c b/kern/exception.c
index 6e84c0a..6cb3bfb 100644
--- a/kern/exception.c
+++ b/kern/exception.c
@@ -48,6 +48,7 @@
#include <kern/sched.h>
#include <kern/sched_prim.h>
#include <kern/exception.h>
+#include <kern/macros.h>
#include <mach/machine/vm_types.h>
#if MACH_KDB
@@ -754,6 +755,12 @@ exception_raise(
}
}
+/* Macro used by MIG to cleanly check the type. */
+#define BAD_TYPECHECK(type, check) unlikely (({\
+ union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\
+ _t.t = *(type); _c.t = *(check);_t.w != _c.w; }))
+
+/* Type descriptor for the return code. */
mach_msg_type_t exc_RetCode_proto = {
/* msgt_name = */ MACH_MSG_TYPE_INTEGER_32,
/* msgt_size = */ 32,
@@ -786,7 +793,7 @@ exception_parse_reply(ipc_kmsg_t kmsg)
MACH_MSGH_BITS(MACH_MSG_TYPE_PORT_SEND_ONCE, 0)) ||
(msg->Head.msgh_size != sizeof *msg) ||
(msg->Head.msgh_id != MACH_EXCEPTION_REPLY_ID) ||
- (* (int *) &msg->RetCodeType != * (int *) &exc_RetCode_proto)) {
+ (BAD_TYPECHECK(&msg->RetCodeType, &exc_RetCode_proto))) {
/*
* Bozo user sent us a misformatted reply.
*/