diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-06 10:48:38 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-06 16:04:27 +0100 |
commit | 19f44baf474da2a9292c8857ed28a5354e2ac12d (patch) | |
tree | fdb4313766914e78893749d47c66d26dafad66af | |
parent | ddf44a1cbdc52c7ab406255c1a7b13543c8263d8 (diff) | |
download | barebox-19f44baf474d.tar.gz barebox-19f44baf474d.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>
-rw-r--r-- | commands/uimage.c | 2 | ||||
-rw-r--r-- | common/uimage.c | 24 | ||||
-rw-r--r-- | include/bunzip2.h | 8 | ||||
-rw-r--r-- | include/gunzip.h | 8 | ||||
-rw-r--r-- | include/image.h | 2 | ||||
-rw-r--r-- | include/linux/decompress/unlz4.h | 8 | ||||
-rw-r--r-- | include/linux/xz.h | 8 | ||||
-rw-r--r-- | include/lzo.h | 8 | ||||
-rw-r--r-- | include/uncompress.h | 8 | ||||
-rw-r--r-- | lib/decompress_bunzip2.c | 16 | ||||
-rw-r--r-- | lib/decompress_inflate.c | 10 | ||||
-rw-r--r-- | lib/decompress_unlz4.c | 16 | ||||
-rw-r--r-- | lib/decompress_unlzo.c | 8 | ||||
-rw-r--r-- | lib/decompress_unxz.c | 8 | ||||
-rw-r--r-- | lib/uncompress.c | 28 |
15 files changed, 81 insertions, 81 deletions
diff --git a/commands/uimage.c b/commands/uimage.c index 588519e3f3..72b827b5b2 100644 --- a/commands/uimage.c +++ b/commands/uimage.c @@ -13,7 +13,7 @@ static int uimage_fd; -static int uimage_flush(void *buf, unsigned int len) +static long uimage_flush(void *buf, unsigned long len) { return write_full(uimage_fd, buf, len); } diff --git a/common/uimage.c b/common/uimage.c index 3c9a79d910..cc9e5e510a 100644 --- a/common/uimage.c +++ b/common/uimage.c @@ -218,23 +218,23 @@ EXPORT_SYMBOL(uimage_close); static int uimage_fd; -static int uimage_fill(void *buf, unsigned int len) +static long uimage_fill(void *buf, unsigned long len) { return read_full(uimage_fd, buf, len); } -static int uncompress_copy(unsigned char *inbuf_unused, int len, - int(*fill)(void*, unsigned int), - int(*flush)(void*, unsigned int), +static int uncompress_copy(unsigned char *inbuf_unused, long len, + long(*fill)(void*, unsigned long), + long(*flush)(void*, unsigned long), unsigned char *outbuf_unused, - int *pos, + long *pos, void(*error_fn)(char *x)) { int ret; void *buf = xmalloc(PAGE_SIZE); while (len) { - int now = min(len, PAGE_SIZE); + int now = min_t(long, len, PAGE_SIZE); ret = fill(buf, now); if (ret < 0) goto err; @@ -295,17 +295,17 @@ EXPORT_SYMBOL(uimage_verify); * Load a uimage, flushing output to flush function */ int uimage_load(struct uimage_handle *handle, unsigned int image_no, - int(*flush)(void*, unsigned int)) + long(*flush)(void*, unsigned long)) { image_header_t *hdr = &handle->header; struct uimage_handle_data *iha; int ret; loff_t off; - int (*uncompress_fn)(unsigned char *inbuf, int len, - int(*fill)(void*, unsigned int), - int(*flush)(void*, unsigned int), + int (*uncompress_fn)(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)); if (image_no >= handle->nb_data_entries) @@ -336,7 +336,7 @@ static void *uimage_buf; static size_t uimage_size; static struct resource *uimage_resource; -static int uimage_sdram_flush(void *buf, unsigned int len) +static long uimage_sdram_flush(void *buf, unsigned long len) { if (uimage_size + len > resource_size(uimage_resource)) { resource_size_t start = uimage_resource->start; diff --git a/include/bunzip2.h b/include/bunzip2.h index 55404ff846..d9edaf3a01 100644 --- a/include/bunzip2.h +++ b/include/bunzip2.h @@ -2,10 +2,10 @@ #ifndef DECOMPRESS_BUNZIP2_H #define DECOMPRESS_BUNZIP2_H -int bunzip2(unsigned char *inbuf, int len, - int(*fill)(void*, unsigned int), - int(*flush)(void*, unsigned int), +int bunzip2(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)); #endif diff --git a/include/gunzip.h b/include/gunzip.h index 0a959d5eb7..d3ec31166a 100644 --- a/include/gunzip.h +++ b/include/gunzip.h @@ -2,10 +2,10 @@ #ifndef GUNZIP_H #define GUNZIP_H -int gunzip(unsigned char *inbuf, int len, - int(*fill)(void*, unsigned int), - int(*flush)(void*, unsigned int), +int gunzip(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)); #endif diff --git a/include/image.h b/include/image.h index b593ae30ef..b4c69d9a02 100644 --- a/include/image.h +++ b/include/image.h @@ -300,7 +300,7 @@ struct uimage_handle *uimage_open(const char *filename); void uimage_close(struct uimage_handle *handle); int uimage_verify(struct uimage_handle *handle); int uimage_load(struct uimage_handle *handle, unsigned int image_no, - int(*flush)(void*, unsigned int)); + long(*flush)(void*, unsigned long)); void uimage_print_contents(struct uimage_handle *handle); ssize_t uimage_get_size(struct uimage_handle *handle, unsigned int image_no); struct resource *uimage_load_to_sdram(struct uimage_handle *handle, diff --git a/include/linux/decompress/unlz4.h b/include/linux/decompress/unlz4.h index 0ad189d2d9..fb6d499d1b 100644 --- a/include/linux/decompress/unlz4.h +++ b/include/linux/decompress/unlz4.h @@ -3,10 +3,10 @@ #ifndef DECOMPRESS_UNLZ4_H #define DECOMPRESS_UNLZ4_H -int decompress_unlz4(unsigned char *inbuf, int len, - int(*fill)(void*, unsigned int), - int(*flush)(void*, unsigned int), +int decompress_unlz4(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)); #endif diff --git a/include/linux/xz.h b/include/linux/xz.h index 77e80ce4b1..6480877f86 100644 --- a/include/linux/xz.h +++ b/include/linux/xz.h @@ -264,10 +264,10 @@ XZ_EXTERN void xz_crc32_init(void); XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc); #endif -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)); #endif diff --git a/include/lzo.h b/include/lzo.h index f46f38b0ed..72bac97cc7 100644 --- a/include/lzo.h +++ b/include/lzo.h @@ -47,10 +47,10 @@ STATIC int lzo1x_decompress_safe(const unsigned char *src, size_t src_len, #define LZO_E_NOT_YET_IMPLEMENTED (-9) #define LZO_E_INVALID_ARGUMENT (-10) -STATIC int decompress_unlzo(u8 *input, int in_len, - int (*fill) (void *, unsigned int), - int (*flush) (void *, unsigned int), - u8 *output, int *posp, +STATIC 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)); #endif diff --git a/include/uncompress.h b/include/uncompress.h index 72ba1dfda6..69ba18000e 100644 --- a/include/uncompress.h +++ b/include/uncompress.h @@ -2,11 +2,11 @@ #ifndef __UNCOMPRESS_H #define __UNCOMPRESS_H -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)); int uncompress_fd_to_fd(int infd, int outfd, 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); } |