From 8e170d29091464caead7b2c989a50bf0e6f1c605 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sat, 2 Apr 2016 18:51:16 -0400 Subject: compress: fix gcc warnings about void* used in arithmetic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit src/journal/compress.c: In function ‘compress_blob_lz4’: src/journal/compress.c:115:49: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] r = LZ4_compress_limitedOutput(src, dst + 8, src_size, (int) dst_alloc_size - 8); ^ src/journal/compress.c: In function ‘decompress_blob_xz’: src/journal/compress.c:179:35: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] s.next_out = *dst + used; ^ src/journal/compress.c: In function ‘decompress_blob_lz4’: src/journal/compress.c:218:37: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] r = LZ4_decompress_safe(src + 8, out, src_size - 8, size); ^ src/journal/compress.c: In function ‘decompress_startswith_xz’: src/journal/compress.c:294:38: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] s.next_out = *buffer + *buffer_size - s.avail_out; ^ src/journal/compress.c:294:53: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] s.next_out = *buffer + *buffer_size - s.avail_out; ^ src/journal/compress.c: In function ‘decompress_startswith_lz4’: src/journal/compress.c:327:45: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] r = LZ4_decompress_safe_partial(src + 8, *buffer, src_size - 8, ^ LZ4 and XZ functions use char* and unsigned char*, respectively, so keep void* in our internal APIs and add casts. --- src/journal/compress.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/journal') diff --git a/src/journal/compress.c b/src/journal/compress.c index c43849c46a..ba734b5561 100644 --- a/src/journal/compress.c +++ b/src/journal/compress.c @@ -112,7 +112,7 @@ int compress_blob_lz4(const void *src, uint64_t src_size, if (src_size < 9) return -ENOBUFS; - r = LZ4_compress_limitedOutput(src, dst + 8, src_size, (int) dst_alloc_size - 8); + r = LZ4_compress_limitedOutput(src, (char*)dst + 8, src_size, (int) dst_alloc_size - 8); if (r <= 0) return -ENOBUFS; @@ -176,7 +176,7 @@ int decompress_blob_xz(const void *src, uint64_t src_size, return -ENOMEM; s.avail_out = space - used; - s.next_out = *dst + used; + s.next_out = *(uint8_t**)dst + used; } *dst_size = space - s.avail_out; @@ -215,7 +215,7 @@ int decompress_blob_lz4(const void *src, uint64_t src_size, } else out = *dst; - r = LZ4_decompress_safe(src + 8, out, src_size - 8, size); + r = LZ4_decompress_safe((char*)src + 8, out, src_size - 8, size); if (r < 0 || r != size) return -EBADMSG; @@ -291,7 +291,7 @@ int decompress_startswith_xz(const void *src, uint64_t src_size, if (!(greedy_realloc(buffer, buffer_size, *buffer_size * 2, 1))) return -ENOMEM; - s.next_out = *buffer + *buffer_size - s.avail_out; + s.next_out = *(uint8_t**)buffer + *buffer_size - s.avail_out; } #else @@ -324,7 +324,7 @@ int decompress_startswith_lz4(const void *src, uint64_t src_size, if (!(greedy_realloc(buffer, buffer_size, ALIGN_8(prefix_len + 1), 1))) return -ENOMEM; - r = LZ4_decompress_safe_partial(src + 8, *buffer, src_size - 8, + r = LZ4_decompress_safe_partial((char*)src + 8, *buffer, src_size - 8, prefix_len + 1, *buffer_size); if (r >= 0) size = (unsigned) r; -- cgit v1.2.3-54-g00ecf