From 9afa45e6391eda5aeeed13475e65071558b5b59c Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 14 Aug 2015 08:21:30 +0300 Subject: [PATCH] shada: Fix -Wstrict-aliasing gcc error Also removes theoretically possible unaligned memory access when computing be64toh() argument. --- src/nvim/shada.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nvim/shada.c b/src/nvim/shada.c index f44594f372..b98aa2f258 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -3294,14 +3294,14 @@ static ShaDaReadResult msgpack_read_uint64(ShaDaReadDef *const sd_reader, return kSDReadStatusNotShaDa; } } - uint8_t buf[sizeof(uint64_t)] = {0, 0, 0, 0, 0, 0, 0, 0}; + uint64_t buf = 0; + char *buf_u8 = (char *) &buf; ShaDaReadResult fl_ret; - if ((fl_ret = fread_len(sd_reader, (char *) &(buf[sizeof(uint64_t)-length]), - length)) + if ((fl_ret = fread_len(sd_reader, &(buf_u8[sizeof(buf)-length]), length)) != kSDReadStatusSuccess) { return fl_ret; } - *result = be64toh(*((uint64_t *) &(buf[0]))); + *result = be64toh(buf); } return kSDReadStatusSuccess; }