From: Pierre-Marc Fournier Date: Fri, 19 Jun 2009 21:28:29 +0000 (-0400) Subject: relay.h: fix strict aliasing warning X-Git-Tag: v1.9.1~961 X-Git-Url: http://git.lttng.org./?a=commitdiff_plain;h=957f86e7e03c9cce749ac96e65749209247e4382;p=lttng-ust.git relay.h: fix strict aliasing warning submitted by Jan Blunck --- diff --git a/libust/relay.h b/libust/relay.h index 630c4eac..ba7c1d63 100644 --- a/libust/relay.h +++ b/libust/relay.h @@ -215,16 +215,24 @@ static inline struct buf_page *ltt_relay_cache_page(struct rchan_buf *buf, //ust// #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS static inline void ltt_relay_do_copy(void *dest, const void *src, size_t len) { + union { + const void *src; + const u8 *src8; + const u16 *src16; + const u32 *src32; + const u64 *src64; + } u = { .src = src }; + switch (len) { case 0: break; - case 1: *(u8 *)dest = *(const u8 *)src; + case 1: *(u8 *)dest = *u.src8; break; - case 2: *(u16 *)dest = *(const u16 *)src; + case 2: *(u16 *)dest = *u.src16; break; - case 4: *(u32 *)dest = *(const u32 *)src; + case 4: *(u32 *)dest = *u.src32; break; //ust// #if (BITS_PER_LONG == 64) - case 8: *(u64 *)dest = *(const u64 *)src; + case 8: *(u64 *)dest = *u.src64; break; //ust// #endif default: