For some reason, this line creates the following warning:

Fri, 28 May 2010 21:26:57 +0000

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Fri, 28 May 2010 21:26:57 +0000
changeset 30373
015cf7cacf23
parent 30367
f91771ab2eb1
child 30374
e9df8757ff89
child 30375
1efe4c9de187

For some reason, this line creates the following warning:
directconn.c:67: warning: dereferencing type-punned pointer will break strict-aliasing rules

I don't understand why it only happens for this line, and not the ones
after it. At least this change stops the warning. If anyone knows how to
properly fix it, or whether it's a bug in GCC or something, please let
me know.

libpurple/protocols/msn/directconn.c file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/msn/directconn.c	Fri May 28 20:51:29 2010 +0000
+++ b/libpurple/protocols/msn/directconn.c	Fri May 28 21:26:57 2010 +0000
@@ -50,6 +50,7 @@
 msn_dc_calculate_nonce_hash(MsnDirectConnNonceType type,
                             const guchar nonce[16], gchar nonce_hash[37])
 {
+	guint32 *tmp;
 	guchar digest[20];
 
 	if (type == DC_NONCE_SHA1) {
@@ -62,9 +63,13 @@
 		memcpy(digest, nonce, 16);
 	}
 
+	/* TODO: Somebody please tell me why this first one causes a warning,
+	         but the others don't! */
+	tmp = (guint32 *)&digest[0];
+
 	g_sprintf(nonce_hash,
 	          "%08X-%04X-%04X-%04X-%08X%04X",
-	          GUINT32_FROM_LE(*((guint32 *)(digest + 0))),
+	          GUINT32_FROM_LE(*tmp),
 	          GUINT16_FROM_LE(*((guint16 *)(digest + 4))),
 	          GUINT16_FROM_LE(*((guint16 *)(digest + 6))),
 	          GUINT16_FROM_BE(*((guint16 *)(digest + 8))),

mercurial