]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
compress: Drop lz4 includes from compress.h
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 7 May 2025 09:43:44 +0000 (11:43 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 9 May 2025 09:33:33 +0000 (11:33 +0200)
The lz4 functions are only used in test-compress.c, so let's just
put the declarations and includes in there instead of having everyone
including compress.h pull in the lz4 headers.

src/basic/compress.c
src/basic/compress.h
src/test/test-compress.c

index 97c1e03fbf50ed71cb853a054e08b992c3dd7e02..5f71eb6853aed7ee25b4b181103b5b3dce7bf1a1 100644 (file)
@@ -9,7 +9,9 @@
 #include <unistd.h>
 
 #if HAVE_LZ4
+#include <lz4.h>
 #include <lz4hc.h>
+#include <lz4frame.h>
 #endif
 
 #if HAVE_XZ
@@ -47,8 +49,9 @@ static DLSYM_PROTOTYPE(LZ4F_decompress) = NULL;
 static DLSYM_PROTOTYPE(LZ4F_freeCompressionContext) = NULL;
 static DLSYM_PROTOTYPE(LZ4F_freeDecompressionContext) = NULL;
 static DLSYM_PROTOTYPE(LZ4F_isError) = NULL;
+static DLSYM_PROTOTYPE(LZ4_compress_HC) = NULL;
+/* These are used in test-compress.c so we don't make them static. */
 DLSYM_PROTOTYPE(LZ4_compress_default) = NULL;
-DLSYM_PROTOTYPE(LZ4_compress_HC) = NULL;
 DLSYM_PROTOTYPE(LZ4_decompress_safe) = NULL;
 DLSYM_PROTOTYPE(LZ4_decompress_safe_partial) = NULL;
 DLSYM_PROTOTYPE(LZ4_versionNumber) = NULL;
index c2f336e9d7d02b61afe6f0340810915a1e520784..dbd6bb385768c2309b91f54745cd3bc28e1ab84d 100644 (file)
@@ -6,11 +6,6 @@
 #include <stdint.h>
 #include <unistd.h>
 
-#if HAVE_LZ4
-#include <lz4.h>
-#include <lz4frame.h>
-#endif
-
 #include "dlfcn-util.h"
 
 typedef enum Compression {
@@ -73,11 +68,6 @@ int decompress_stream_lz4(int fdf, int fdt, uint64_t max_size);
 int decompress_stream_zstd(int fdf, int fdt, uint64_t max_size);
 
 #if HAVE_LZ4
-extern DLSYM_PROTOTYPE(LZ4_compress_default);
-extern DLSYM_PROTOTYPE(LZ4_decompress_safe);
-extern DLSYM_PROTOTYPE(LZ4_decompress_safe_partial);
-extern DLSYM_PROTOTYPE(LZ4_versionNumber);
-
 int dlopen_lz4(void);
 #endif
 
index 2d8732bddb1d8717d60a9be3e40a980882cd1a58..56a468ab88a3bbabec7870f003dbe8f50113ec66 100644 (file)
@@ -229,6 +229,11 @@ _unused_ static void test_compress_stream(const char *compression,
 #endif
 
 #if HAVE_LZ4
+extern DLSYM_PROTOTYPE(LZ4_compress_default);
+extern DLSYM_PROTOTYPE(LZ4_decompress_safe);
+extern DLSYM_PROTOTYPE(LZ4_decompress_safe_partial);
+extern DLSYM_PROTOTYPE(LZ4_versionNumber);
+
 static void test_lz4_decompress_partial(void) {
         char buf[20000], buf2[100];
         size_t buf_size = sizeof(buf), compressed;