From: Kevin McCarthy Date: Sat, 17 Jan 2015 22:42:28 +0000 (-0800) Subject: Fix the hcache type punning warning. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2cea210ec86ffe65fe2eac9f6055a149b1be10ba;p=neomutt Fix the hcache type punning warning. This patch fixes the type punning warning by switching from (safe but perhaps not elegant) casting to using a union. Thanks to Vincent Lefevre for his input and suggestion to use the union as a better solution to the problem! --- diff --git a/hcache.c b/hcache.c index 72fec569c..51f2f1a84 100644 --- a/hcache.c +++ b/hcache.c @@ -1135,7 +1135,10 @@ mutt_hcache_open(const char *path, const char *folder, hcache_namer_t namer) /* Calculate the current hcache version from dynamic configuration */ if (hcachever == 0x0) { - unsigned char digest[16]; + union { + unsigned char charval[16]; + unsigned int intval; + } digest; struct md5_ctx ctx; SPAM_LIST *spam; RX_LIST *nospam; @@ -1161,8 +1164,8 @@ mutt_hcache_open(const char *path, const char *folder, hcache_namer_t namer) } /* Get a hash and take its bytes as an (unsigned int) hash version */ - md5_finish_ctx(&ctx, digest); - hcachever = *((unsigned int *)digest); + md5_finish_ctx(&ctx, digest.charval); + hcachever = digest.intval; } h->db = NULL;