[RFC PATCH v2 6/7] HACK: Allow the use of generic decompress with gzip outside __init

From: Jonathan McDowell
Date: Thu Jul 28 2022 - 10:10:56 EST


The generic decompression support is only available in the __init
section. Hack this out for now with gzip for testing. Longer term this
needs rethought in a similar fashion to the cpio support.

Signed-off-by: Jonathan McDowell <noodles@xxxxxx>
---
lib/decompress.c | 4 ++--
lib/decompress_inflate.c | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/decompress.c b/lib/decompress.c
index ab3fc90ffc64..89a5709e454a 100644
--- a/lib/decompress.c
+++ b/lib/decompress.c
@@ -48,7 +48,7 @@ struct compress_format {
decompress_fn decompressor;
};

-static const struct compress_format compressed_formats[] __initconst = {
+static const struct compress_format compressed_formats[] = {
{ {0x1f, 0x8b}, "gzip", gunzip },
{ {0x1f, 0x9e}, "gzip", gunzip },
{ {0x42, 0x5a}, "bzip2", bunzip2 },
@@ -60,7 +60,7 @@ static const struct compress_format compressed_formats[] __initconst = {
{ {0, 0}, NULL, NULL }
};

-decompress_fn __init decompress_method(const unsigned char *inbuf, long len,
+decompress_fn decompress_method(const unsigned char *inbuf, long len,
const char **name)
{
const struct compress_format *cf;
diff --git a/lib/decompress_inflate.c b/lib/decompress_inflate.c
index 6130c42b8e59..b245d6e5f8a6 100644
--- a/lib/decompress_inflate.c
+++ b/lib/decompress_inflate.c
@@ -33,6 +33,10 @@

#define GZIP_IOBUF_SIZE (16*1024)

+/* HACK */
+#undef INIT
+#define INIT
+
static long INIT nofill(void *buffer, unsigned long len)
{
return -1;
--
2.30.2