summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2024-02-06 10:48:38 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2024-02-06 16:04:27 +0100
commit19f44baf474da2a9292c8857ed28a5354e2ac12d (patch)
treefdb4313766914e78893749d47c66d26dafad66af /lib
parentddf44a1cbdc52c7ab406255c1a7b13543c8263d8 (diff)
downloadbarebox-19f44baf474da2a9292c8857ed28a5354e2ac12d.tar.gz
barebox-19f44baf474da2a9292c8857ed28a5354e2ac12d.tar.xz
decompress: change length arguments to long
In order to support decompression of files > 2GiB Linux has changed the prototypes of decompression functions from int uncompress(unsigned char *inbuf, int len, int(*fill)(void*, unsigned int), int(*flush)(void*, unsigned int), unsigned char *output, int *pos, void(*error_fn)(char *x)); to int uncompress(unsigned char *inbuf, long len, long(*fill)(void*, unsigned long), long(*flush)(void*, unsigned long), unsigned char *output, long *pos, void(*error_fn)(char *x)); Do likewise in barebox for easier code sharing with Linux. Link: https://lore.barebox.org/20240206094838.1987246-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/decompress_bunzip2.c16
-rw-r--r--lib/decompress_inflate.c10
-rw-r--r--lib/decompress_unlz4.c16
-rw-r--r--lib/decompress_unlzo.c8
-rw-r--r--lib/decompress_unxz.c8
-rw-r--r--lib/uncompress.c28
6 files changed, 43 insertions, 43 deletions
diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c
index ee2862bebb..2daeb9b38c 100644
--- a/lib/decompress_bunzip2.c
+++ b/lib/decompress_bunzip2.c
@@ -89,7 +89,7 @@ struct bunzip_data {
/* State for interrupting output loop */
int writeCopies, writePos, writeRunCountdown, writeCount, writeCurrent;
/* I/O tracking data (file handles, buffers, positions, etc.) */
- int (*fill)(void*, unsigned int);
+ long (*fill)(void*, unsigned long);
int inbufCount, inbufPos /*, outbufPos*/;
unsigned char *inbuf /*,*outbuf*/;
unsigned int inbufBitCount, inbufBits;
@@ -614,7 +614,7 @@ decode_next_byte:
goto decode_next_byte;
}
-static int nofill(void *buf, unsigned int len)
+static long nofill(void *buf, unsigned long len)
{
return -1;
}
@@ -622,8 +622,8 @@ static int nofill(void *buf, unsigned int len)
/* Allocate the structure, read file header. If in_fd ==-1, inbuf must contain
a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are
ignored, and data is read from file handle into temporary buffer. */
-static int start_bunzip(struct bunzip_data **bdp, void *inbuf, int len,
- int (*fill)(void*, unsigned int))
+static int start_bunzip(struct bunzip_data **bdp, void *inbuf, long len,
+ long (*fill)(void*, unsigned long))
{
struct bunzip_data *bd;
unsigned int i, j, c;
@@ -672,11 +672,11 @@ static int start_bunzip(struct bunzip_data **bdp, void *inbuf, int len,
/* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip2 data,
not end of file.) */
-int bunzip2(unsigned char *buf, int len,
- int(*fill)(void*, unsigned int),
- int(*flush)(void*, unsigned int),
+int bunzip2(unsigned char *buf, long len,
+ long(*fill)(void*, unsigned long),
+ long(*flush)(void*, unsigned long),
unsigned char *outbuf,
- int *pos,
+ long *pos,
void(*error)(char *x))
{
struct bunzip_data *bd;
diff --git a/lib/decompress_inflate.c b/lib/decompress_inflate.c
index 47bd3db131..507190938c 100644
--- a/lib/decompress_inflate.c
+++ b/lib/decompress_inflate.c
@@ -32,17 +32,17 @@
#define GZIP_IOBUF_SIZE (16*1024)
-static int nofill(void *buffer, unsigned int len)
+static long nofill(void *buffer, unsigned long len)
{
return -1;
}
/* Included from initramfs et al code */
-int gunzip(unsigned char *buf, int len,
- int(*fill)(void*, unsigned int),
- int(*flush)(void*, unsigned int),
+int gunzip(unsigned char *buf, long len,
+ long(*fill)(void*, unsigned long),
+ long(*flush)(void*, unsigned long),
unsigned char *out_buf,
- int *pos,
+ long *pos,
void(*error)(char *x)) {
u8 *zbuf;
struct z_stream_s *strm;
diff --git a/lib/decompress_unlz4.c b/lib/decompress_unlz4.c
index 2c04eac71c..a18e6591e9 100644
--- a/lib/decompress_unlz4.c
+++ b/lib/decompress_unlz4.c
@@ -38,10 +38,10 @@
#define LZ4_DEFAULT_UNCOMPRESSED_CHUNK_SIZE (8 << 20)
#define ARCHIVE_MAGICNUMBER 0x184C2102
-static inline int unlz4(u8 *input, int in_len,
- int (*fill) (void *, unsigned int),
- int (*flush) (void *, unsigned int),
- u8 *output, int *posp,
+static inline int unlz4(u8 *input, long in_len,
+ long (*fill) (void *, unsigned long),
+ long (*flush) (void *, unsigned long),
+ u8 *output, long *posp,
void (*error) (char *x))
{
int ret = -1;
@@ -180,11 +180,11 @@ exit_0:
return ret;
}
-STATIC int decompress_unlz4(unsigned char *buf, int in_len,
- int(*fill)(void*, unsigned int),
- int(*flush)(void*, unsigned int),
+STATIC int decompress_unlz4(unsigned char *buf, long in_len,
+ long(*fill)(void*, unsigned long),
+ long(*flush)(void*, unsigned long),
unsigned char *output,
- int *posp,
+ long *posp,
void(*error)(char *x)
)
{
diff --git a/lib/decompress_unlzo.c b/lib/decompress_unlzo.c
index ad7f977280..18168cb948 100644
--- a/lib/decompress_unlzo.c
+++ b/lib/decompress_unlzo.c
@@ -109,10 +109,10 @@ static inline int parse_header(u8 *input, int *skip, int in_len)
return 1;
}
-int decompress_unlzo(u8 *input, int in_len,
- int (*fill) (void *, unsigned int),
- int (*flush) (void *, unsigned int),
- u8 *output, int *posp,
+int decompress_unlzo(u8 *input, long in_len,
+ long (*fill) (void *, unsigned long),
+ long (*flush) (void *, unsigned long),
+ u8 *output, long *posp,
void (*error) (char *x))
{
u8 r = 0;
diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c
index ad6a5f20ba..7b8a9cd331 100644
--- a/lib/decompress_unxz.c
+++ b/lib/decompress_unxz.c
@@ -235,10 +235,10 @@ static void memzero(void *buf, size_t size)
* both input and output buffers are available as a single chunk, i.e. when
* fill() and flush() won't be used.
*/
-STATIC int decompress_unxz(unsigned char *in, int in_size,
- int (*fill)(void *dest, unsigned int size),
- int (*flush)(void *src, unsigned int size),
- unsigned char *out, int *in_used,
+STATIC int decompress_unxz(unsigned char *in, long in_size,
+ long (*fill)(void *dest, unsigned long size),
+ long (*flush)(void *src, unsigned long size),
+ unsigned char *out, long *in_used,
void (*error)(char *x))
{
struct xz_buf b;
diff --git a/lib/uncompress.c b/lib/uncompress.c
index bfe042fcf8..c23988fc02 100644
--- a/lib/uncompress.c
+++ b/lib/uncompress.c
@@ -27,18 +27,18 @@
#include <libfile.h>
static void *uncompress_buf;
-static unsigned int uncompress_size;
+static unsigned long uncompress_size;
void uncompress_err_stdout(char *x)
{
printf("%s\n", x);
}
-static int (*uncompress_fill_fn)(void*, unsigned int);
+static long (*uncompress_fill_fn)(void*, unsigned long);
-static int uncompress_fill(void *buf, unsigned int len)
+static long uncompress_fill(void *buf, unsigned long len)
{
- int total = 0;
+ long total = 0;
if (uncompress_size) {
int now = min(len, uncompress_size);
@@ -60,19 +60,19 @@ static int uncompress_fill(void *buf, unsigned int len)
return total;
}
-int uncompress(unsigned char *inbuf, int len,
- int(*fill)(void*, unsigned int),
- int(*flush)(void*, unsigned int),
+int uncompress(unsigned char *inbuf, long len,
+ long(*fill)(void*, unsigned long),
+ long(*flush)(void*, unsigned long),
unsigned char *output,
- int *pos,
+ long *pos,
void(*error_fn)(char *x))
{
enum filetype ft;
- int (*compfn)(unsigned char *inbuf, int len,
- int(*fill)(void*, unsigned int),
- int(*flush)(void*, unsigned int),
+ int (*compfn)(unsigned char *inbuf, long len,
+ long(*fill)(void*, unsigned long),
+ long(*flush)(void*, unsigned long),
unsigned char *output,
- int *pos,
+ long *pos,
void(*error)(char *x));
int ret;
char *err;
@@ -141,12 +141,12 @@ err:
static int uncompress_infd, uncompress_outfd;
-static int fill_fd(void *buf, unsigned int len)
+static long fill_fd(void *buf, unsigned long len)
{
return read_full(uncompress_infd, buf, len);
}
-static int flush_fd(void *buf, unsigned int len)
+static long flush_fd(void *buf, unsigned long len)
{
return write(uncompress_outfd, buf, len);
}