From ef6b775f9fc21788c5992a2fb689ae37fc36db2c Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 7 Jun 2020 13:10:59 +0200 Subject: [PATCH] lz4/fpga_compress: avoid alignment problems fpga_compress.c:176:32: warning: cast from 'char *' to 'int *' increases required alignment from 1 to 4 [-Wcast-align] const int cmp_bytes = *(int*)(compressed_fpga_stream.next_in); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- tools/fpga_compress/fpga_compress.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/fpga_compress/fpga_compress.c b/tools/fpga_compress/fpga_compress.c index 5c5dc8cdb..7b5cdb2b2 100644 --- a/tools/fpga_compress/fpga_compress.c +++ b/tools/fpga_compress/fpga_compress.c @@ -173,7 +173,8 @@ static int zlib_decompress(FILE *infile, FILE *outfile) { int total_size = 0; while (compressed_fpga_stream.avail_in > 0) { - const int cmp_bytes = *(int*)(compressed_fpga_stream.next_in); + int cmp_bytes; + memcpy(&cmp_bytes, compressed_fpga_stream.next_in, sizeof(int)); compressed_fpga_stream.next_in += 4; compressed_fpga_stream.avail_in -= cmp_bytes + 4; const int decBytes = LZ4_decompress_safe_continue(compressed_fpga_stream.lz4StreamDecode, compressed_fpga_stream.next_in, outbuf, cmp_bytes, FPGA_RING_BUFFER_BYTES);