From cc3f26c993f3831ade948bdebbd01eb8164cd014 Mon Sep 17 00:00:00 2001 From: Duarte Nunes Date: Thu, 24 Nov 2016 10:23:39 +0100 Subject: [PATCH] lz4: Conditionally use LZ4_compress_default() Since not all distributions have a version of LZ4 with LZ4_compress_default(), we use it conditionally. This is specially important beginning with version 1.7.3 of LZ4, which deprecates the LZ4_compress() function in favour of LZ4_compress_default() and thus prevents Scylla from compiling due to the deprecated warning. Signed-off-by: Duarte Nunes Message-Id: <20161124092339.23017-1-duarte@scylladb.com> --- sstables/compress.cc | 4 ++++ transport/server.cc | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/sstables/compress.cc b/sstables/compress.cc index cda3a30be1..211be48caa 100644 --- a/sstables/compress.cc +++ b/sstables/compress.cc @@ -121,7 +121,11 @@ size_t compress_lz4(const char* input, size_t input_len, output[1] = (input_len >> 8) & 0xFF; output[2] = (input_len >> 16) & 0xFF; output[3] = (input_len >> 24) & 0xFF; +#ifdef HAVE_LZ4_COMPRESS_DEFAULT + auto ret = LZ4_compress_default(input, output + 4, input_len, LZ4_compressBound(input_len)); +#else auto ret = LZ4_compress(input, output + 4, input_len); +#endif if (ret == 0) { throw std::runtime_error("LZ4 compression failure: LZ4_compress() failed"); } diff --git a/transport/server.cc b/transport/server.cc index 7158226fb7..2282ee9998 100644 --- a/transport/server.cc +++ b/transport/server.cc @@ -1504,7 +1504,11 @@ std::vector cql_server::response::compress_lz4(const std::vector& bo output[1] = (input_len >> 16) & 0xFF; output[2] = (input_len >> 8) & 0xFF; output[3] = input_len & 0xFF; +#ifdef HAVE_LZ4_COMPRESS_DEFAULT + auto ret = LZ4_compress_default(input, output + 4, input_len, LZ4_compressBound(input_len)); +#else auto ret = LZ4_compress(input, output + 4, input_len); +#endif if (ret == 0) { throw std::runtime_error("CQL frame LZ4 compression failure"); }