comparison libpurple/protocols/msn/directconn.c @ 30544:ef7303c25751

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.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 28 May 2010 21:26:57 +0000
parents 7f564cf26ea3
children f7e1d5d397b6
comparison
equal deleted inserted replaced
30543:ee1af22b7242 30544:ef7303c25751
48 48
49 static void 49 static void
50 msn_dc_calculate_nonce_hash(MsnDirectConnNonceType type, 50 msn_dc_calculate_nonce_hash(MsnDirectConnNonceType type,
51 const guchar nonce[16], gchar nonce_hash[37]) 51 const guchar nonce[16], gchar nonce_hash[37])
52 { 52 {
53 guint32 *tmp;
53 guchar digest[20]; 54 guchar digest[20];
54 55
55 if (type == DC_NONCE_SHA1) { 56 if (type == DC_NONCE_SHA1) {
56 PurpleCipher *cipher = purple_ciphers_find_cipher("sha1"); 57 PurpleCipher *cipher = purple_ciphers_find_cipher("sha1");
57 PurpleCipherContext *context = purple_cipher_context_new(cipher, NULL); 58 PurpleCipherContext *context = purple_cipher_context_new(cipher, NULL);
60 purple_cipher_context_destroy(context); 61 purple_cipher_context_destroy(context);
61 } else if (type == DC_NONCE_PLAIN) { 62 } else if (type == DC_NONCE_PLAIN) {
62 memcpy(digest, nonce, 16); 63 memcpy(digest, nonce, 16);
63 } 64 }
64 65
66 /* TODO: Somebody please tell me why this first one causes a warning,
67 but the others don't! */
68 tmp = (guint32 *)&digest[0];
69
65 g_sprintf(nonce_hash, 70 g_sprintf(nonce_hash,
66 "%08X-%04X-%04X-%04X-%08X%04X", 71 "%08X-%04X-%04X-%04X-%08X%04X",
67 GUINT32_FROM_LE(*((guint32 *)(digest + 0))), 72 GUINT32_FROM_LE(*tmp),
68 GUINT16_FROM_LE(*((guint16 *)(digest + 4))), 73 GUINT16_FROM_LE(*((guint16 *)(digest + 4))),
69 GUINT16_FROM_LE(*((guint16 *)(digest + 6))), 74 GUINT16_FROM_LE(*((guint16 *)(digest + 6))),
70 GUINT16_FROM_BE(*((guint16 *)(digest + 8))), 75 GUINT16_FROM_BE(*((guint16 *)(digest + 8))),
71 GUINT32_FROM_BE(*((guint32 *)(digest + 10))), 76 GUINT32_FROM_BE(*((guint32 *)(digest + 10))),
72 GUINT16_FROM_BE(*((guint16 *)(digest + 14))) 77 GUINT16_FROM_BE(*((guint16 *)(digest + 14)))