erofs-utils: lib: don't include <lzma.h> and <zlib.h> in external headers
authorGao Xiang <hsiangkao@linux.alibaba.com>
Fri, 30 Aug 2024 06:55:42 +0000 (14:55 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 4 Sep 2024 02:30:58 +0000 (10:30 +0800)
Applications don't need internal header dependencies.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20240830065542.94908-1-hsiangkao@linux.alibaba.com
include/erofs/tar.h
lib/tar.c

index 6fa72eb3ad273222d10fa03d509190fac2c118ce..42fbb00d20ed2a9dd97b289d0d0a5209bab31e73 100644 (file)
@@ -7,9 +7,6 @@ extern "C"
 {
 #endif
 
-#if defined(HAVE_ZLIB)
-#include <zlib.h>
-#endif
 #include <sys/stat.h>
 
 #include "internal.h"
@@ -28,14 +25,7 @@ struct erofs_pax_header {
 #define EROFS_IOS_DECODER_GZIP         1
 #define EROFS_IOS_DECODER_LIBLZMA      2
 
-#ifdef HAVE_LIBLZMA
-#include <lzma.h>
-struct erofs_iostream_liblzma {
-       u8 inbuf[32768];
-       lzma_stream strm;
-       int fd;
-};
-#endif
+struct erofs_iostream_liblzma;
 
 struct erofs_iostream {
        union {
index a9b425ec4cc0462f5d5485300ef86388681dadef..7e89b9290fd499ed3c7289af90d4b3037f4bab32 100644 (file)
--- a/lib/tar.c
+++ b/lib/tar.c
@@ -3,9 +3,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
-#if defined(HAVE_ZLIB)
-#include <zlib.h>
-#endif
 #include "erofs/print.h"
 #include "erofs/cache.h"
 #include "erofs/diskbuf.h"
@@ -15,6 +12,9 @@
 #include "erofs/xattr.h"
 #include "erofs/blobchunk.h"
 #include "erofs/rebuild.h"
+#if defined(HAVE_ZLIB)
+#include <zlib.h>
+#endif
 
 /* This file is a tape/volume header.  Ignore it on extraction.  */
 #define GNUTYPE_VOLHDR 'V'
@@ -39,6 +39,15 @@ struct tar_header {
        char padding[12];       /* 500-512 (pad to exactly the 512 byte) */
 };
 
+#ifdef HAVE_LIBLZMA
+#include <lzma.h>
+struct erofs_iostream_liblzma {
+       u8 inbuf[32768];
+       lzma_stream strm;
+       int fd;
+};
+#endif
+
 void erofs_iostream_close(struct erofs_iostream *ios)
 {
        free(ios->buffer);