From 8cde86073a0b48e5c3c101864b6eb5bdf07525db Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Fri, 16 Dec 2011 05:14:24 +0100 Subject: [PATCH] gcc-4.6: correct strict aliasing errors. Use "union" to remove error: "error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]" Signed-off-by: Laurent Vivier --- libmacos/SerGetBuf.c | 2 +- libmacos/macos/files.h | 6 +++++- libmacos/macos/video.h | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libmacos/SerGetBuf.c b/libmacos/SerGetBuf.c index f775833..de9dc37 100644 --- a/libmacos/SerGetBuf.c +++ b/libmacos/SerGetBuf.c @@ -21,7 +21,7 @@ OSErr SerGetBuf(short refNum, long *count) res = PBStatusSync((ParmBlkPtr)¶m); - *count = *(long*)param.csParam; + *count = param.csParamLong; return res; } diff --git a/libmacos/macos/files.h b/libmacos/macos/files.h index 8ddf2bb..576df36 100644 --- a/libmacos/macos/files.h +++ b/libmacos/macos/files.h @@ -48,7 +48,11 @@ struct CntrlParam { COMMON_PARAMS int16_t ioCRefNum; int16_t csCode; - int16_t csParam[11]; + union { + int16_t csParam[11]; + long csParamLong; + void * csParamPtr; + }; }; typedef struct CntrlParam CntrlParam; typedef CntrlParam* CntrlParamPtr; diff --git a/libmacos/macos/video.h b/libmacos/macos/video.h index 54015f5..2f4c85c 100644 --- a/libmacos/macos/video.h +++ b/libmacos/macos/video.h @@ -83,7 +83,7 @@ static inline OSErr GetCurrentMode(short refNum, VDSwitchInfoRec *hwMode) param.csCode = cscGetCurMode; param.ioCRefNum = refNum; - *((VDSwitchInfoRec **)¶m.csParam[0]) = hwMode; + param.csParamPtr = hwMode; return PBStatusSync((ParmBlkPtr)¶m); }