[Pcsclite-cvs-commit] r4234 - in /trunk/PCSC/src: winscard_clnt.c winscard_msg.h winscard_svc.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Thu May 28 13:46:22 UTC 2009


Author: rousseau
Date: Thu May 28 13:46:22 2009
New Revision: 4234

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4234
Log:
use a union to avoid "warning: dereferencing pointer 'veStr' does break
strict-aliasing rules" warnings with gcc 4.4

Thanks to Stanislav Brabec for the patch

Modified:
    trunk/PCSC/src/winscard_clnt.c
    trunk/PCSC/src/winscard_msg.h
    trunk/PCSC/src/winscard_svc.c

Modified: trunk/PCSC/src/winscard_clnt.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_clnt.c?rev=4234&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Thu May 28 13:46:22 2009
@@ -481,7 +481,7 @@
 		msgStruct.command = 0;
 		msgStruct.date = time(NULL);
 
-		veStr = (version_struct *) msgStruct.data;
+		veStr = &msgStruct.veStr;
 		veStr->major = PROTOCOL_VERSION_MAJOR;
 		veStr->minor = PROTOCOL_VERSION_MINOR;
 

Modified: trunk/PCSC/src/winscard_msg.h
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_msg.h?rev=4234&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_msg.h (original)
+++ trunk/PCSC/src/winscard_msg.h Thu May 28 13:46:22 2009
@@ -31,6 +31,17 @@
 #endif
 
 	/**
+	 * @brief Information transmitted in \ref CMD_VERSION Messages.
+	 */
+	struct version_struct
+	{
+		int32_t major;	/**< IPC major \ref PROTOCOL_VERSION_MAJOR */
+		int32_t minor;	/**< IPC minor \ref PROTOCOL_VERSION_MINOR */
+		uint32_t rv;
+	};
+	typedef struct version_struct version_struct;
+
+	/**
 	 * @brief General structure for client/serve message data exchange.
 	 *
 	 * It is used in the calls of \c SHMMessageSend and \c SHMMessageReceive.
@@ -49,7 +60,11 @@
 		uint32_t command;	/** one of the \c pcsc_msg_commands */
 		uint64_t date;
 		unsigned char key[PCSCLITE_MSG_KEY_LEN]; /* 16 bytes */
-		unsigned char data[PCSCLITE_MAX_MESSAGE_SIZE];
+		union
+		{
+			unsigned char data[PCSCLITE_MAX_MESSAGE_SIZE];
+			struct version_struct veStr;
+		};
 	}
 	sharedSegmentMsg, *psharedSegmentMsg;
 
@@ -93,17 +108,6 @@
 		SCARD_CONTROL_EXTENDED = 0x12	/**< used by SCardControl() */
 	};
 
-	/**
-	 * @brief Information transmitted in \ref CMD_VERSION Messages.
-	 */
-	struct version_struct
-	{
-		int32_t major;	/**< IPC major \ref PROTOCOL_VERSION_MAJOR */
-		int32_t minor;	/**< IPC minor \ref PROTOCOL_VERSION_MINOR */
-		uint32_t rv;
-	};
-	typedef struct version_struct version_struct;
-
 	struct client_struct
 	{
 		uint32_t hContext;

Modified: trunk/PCSC/src/winscard_svc.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_svc.c?rev=4234&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_svc.c (original)
+++ trunk/PCSC/src/winscard_svc.c Thu May 28 13:46:22 2009
@@ -178,7 +178,7 @@
 				if (msgStruct.mtype == CMD_VERSION)
 				{
 					version_struct *veStr;
-					veStr = (version_struct *) msgStruct.data;
+					veStr = &msgStruct.veStr;
 
 					/* get the client protocol version */
 					psContext[dwContextIndex].protocol_major = veStr->major;




More information about the Pcsclite-cvs-commit mailing list