shada: Fix -Wstrict-aliasing gcc error

Also removes theoretically possible unaligned memory access when computing
be64toh() argument.
This commit is contained in:
ZyX 2015-08-14 08:21:30 +03:00
parent bcb60b0a64
commit 9afa45e639

View File

@ -3294,14 +3294,14 @@ static ShaDaReadResult msgpack_read_uint64(ShaDaReadDef *const sd_reader,
return kSDReadStatusNotShaDa; 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; ShaDaReadResult fl_ret;
if ((fl_ret = fread_len(sd_reader, (char *) &(buf[sizeof(uint64_t)-length]), if ((fl_ret = fread_len(sd_reader, &(buf_u8[sizeof(buf)-length]), length))
length))
!= kSDReadStatusSuccess) { != kSDReadStatusSuccess) {
return fl_ret; return fl_ret;
} }
*result = be64toh(*((uint64_t *) &(buf[0]))); *result = be64toh(buf);
} }
return kSDReadStatusSuccess; return kSDReadStatusSuccess;
} }