[PATCH] erofs-utils: lib: don't include <lzma.h> and <zlib.h> in external headers
Gao Xiang
hsiangkao at linux.alibaba.com
Fri Aug 30 16:55:42 AEST 2024
Applications don't need internal header dependencies.
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
include/erofs/tar.h | 12 +-----------
lib/tar.c | 15 ++++++++++++---
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/include/erofs/tar.h b/include/erofs/tar.h
index 6fa72eb..42fbb00 100644
--- a/include/erofs/tar.h
+++ b/include/erofs/tar.h
@@ -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 {
diff --git a/lib/tar.c b/lib/tar.c
index a9b425e..7e89b92 100644
--- 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);
--
2.39.3 (Apple Git-146)
More information about the Linux-erofs
mailing list