* [PATCH] decompress: change length arguments to long @ 2024-02-06 9:48 Sascha Hauer 2024-02-06 11:16 ` Marco Felsch 2024-02-06 15:05 ` Sascha Hauer 0 siblings, 2 replies; 5+ messages in thread From: Sascha Hauer @ 2024-02-06 9:48 UTC (permalink / raw) To: Barebox List 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. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> --- commands/uimage.c | 2 +- common/uimage.c | 24 ++++++++++++------------ include/bunzip2.h | 8 ++++---- include/gunzip.h | 8 ++++---- include/image.h | 2 +- include/linux/decompress/unlz4.h | 8 ++++---- include/linux/xz.h | 8 ++++---- include/lzo.h | 8 ++++---- include/uncompress.h | 8 ++++---- lib/decompress_bunzip2.c | 16 ++++++++-------- lib/decompress_inflate.c | 10 +++++----- lib/decompress_unlz4.c | 16 ++++++++-------- lib/decompress_unlzo.c | 8 ++++---- lib/decompress_unxz.c | 8 ++++---- 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 @@ static int read_bunzip(struct bunzip_data *bd, char *outbuf, int len) 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 @@ static inline int unlz4(u8 *input, int in_len, 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 @@ int uncompress(unsigned char *inbuf, int len, 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); } -- 2.39.2 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] decompress: change length arguments to long 2024-02-06 9:48 [PATCH] decompress: change length arguments to long Sascha Hauer @ 2024-02-06 11:16 ` Marco Felsch 2024-02-06 11:59 ` Sascha Hauer 2024-02-06 15:05 ` Sascha Hauer 1 sibling, 1 reply; 5+ messages in thread From: Marco Felsch @ 2024-02-06 11:16 UTC (permalink / raw) To: Sascha Hauer; +Cc: Barebox List On 24-02-06, Sascha Hauer wrote: > 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. Thanks a lot. > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> > --- > commands/uimage.c | 2 +- > common/uimage.c | 24 ++++++++++++------------ > include/bunzip2.h | 8 ++++---- > include/gunzip.h | 8 ++++---- > include/image.h | 2 +- > include/linux/decompress/unlz4.h | 8 ++++---- > include/linux/xz.h | 8 ++++---- > include/lzo.h | 8 ++++---- > include/uncompress.h | 8 ++++---- > lib/decompress_bunzip2.c | 16 ++++++++-------- > lib/decompress_inflate.c | 10 +++++----- > lib/decompress_unlz4.c | 16 ++++++++-------- > lib/decompress_unlzo.c | 8 ++++---- > lib/decompress_unxz.c | 8 ++++---- > lib/uncompress.c | 28 ++++++++++++++-------------- I do miss the zstd here. Regards, Marco > 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 @@ static int read_bunzip(struct bunzip_data *bd, char *outbuf, int len) > 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 @@ static inline int unlz4(u8 *input, int in_len, > 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 @@ int uncompress(unsigned char *inbuf, int len, > > 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); > } > -- > 2.39.2 > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] decompress: change length arguments to long 2024-02-06 11:16 ` Marco Felsch @ 2024-02-06 11:59 ` Sascha Hauer 2024-02-06 12:09 ` Marco Felsch 0 siblings, 1 reply; 5+ messages in thread From: Sascha Hauer @ 2024-02-06 11:59 UTC (permalink / raw) To: Marco Felsch; +Cc: Barebox List On Tue, Feb 06, 2024 at 12:16:28PM +0100, Marco Felsch wrote: > On 24-02-06, Sascha Hauer wrote: > > 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. > > Thanks a lot. > > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> > > --- > > commands/uimage.c | 2 +- > > common/uimage.c | 24 ++++++++++++------------ > > include/bunzip2.h | 8 ++++---- > > include/gunzip.h | 8 ++++---- > > include/image.h | 2 +- > > include/linux/decompress/unlz4.h | 8 ++++---- > > include/linux/xz.h | 8 ++++---- > > include/lzo.h | 8 ++++---- > > include/uncompress.h | 8 ++++---- > > lib/decompress_bunzip2.c | 16 ++++++++-------- > > lib/decompress_inflate.c | 10 +++++----- > > lib/decompress_unlz4.c | 16 ++++++++-------- > > lib/decompress_unlzo.c | 8 ++++---- > > lib/decompress_unxz.c | 8 ++++---- > > lib/uncompress.c | 28 ++++++++++++++-------------- > > I do miss the zstd here. This patch is supposed to go before the zstd patch so that we can add zstd support with the correct prototypes. I have a patch for that already, should have sent it. Sascha > > Regards, > Marco > > > 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 @@ static int read_bunzip(struct bunzip_data *bd, char *outbuf, int len) > > 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 @@ static inline int unlz4(u8 *input, int in_len, > > 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 @@ int uncompress(unsigned char *inbuf, int len, > > > > 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); > > } > > -- > > 2.39.2 > > > > > > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] decompress: change length arguments to long 2024-02-06 11:59 ` Sascha Hauer @ 2024-02-06 12:09 ` Marco Felsch 0 siblings, 0 replies; 5+ messages in thread From: Marco Felsch @ 2024-02-06 12:09 UTC (permalink / raw) To: Sascha Hauer; +Cc: Barebox List On 24-02-06, Sascha Hauer wrote: > On Tue, Feb 06, 2024 at 12:16:28PM +0100, Marco Felsch wrote: > > On 24-02-06, Sascha Hauer wrote: > > > 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. > > > > Thanks a lot. > > > > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> > > > --- > > > commands/uimage.c | 2 +- > > > common/uimage.c | 24 ++++++++++++------------ > > > include/bunzip2.h | 8 ++++---- > > > include/gunzip.h | 8 ++++---- > > > include/image.h | 2 +- > > > include/linux/decompress/unlz4.h | 8 ++++---- > > > include/linux/xz.h | 8 ++++---- > > > include/lzo.h | 8 ++++---- > > > include/uncompress.h | 8 ++++---- > > > lib/decompress_bunzip2.c | 16 ++++++++-------- > > > lib/decompress_inflate.c | 10 +++++----- > > > lib/decompress_unlz4.c | 16 ++++++++-------- > > > lib/decompress_unlzo.c | 8 ++++---- > > > lib/decompress_unxz.c | 8 ++++---- > > > lib/uncompress.c | 28 ++++++++++++++-------------- > > > > I do miss the zstd here. > > This patch is supposed to go before the zstd patch so that we can add > zstd support with the correct prototypes. I have a patch for that > already, should have sent it. Ah okay, makes sense I just thought that you applied the zstd patches already :) In that case: Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> > > Sascha > > > > > Regards, > > Marco > > > > > 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 @@ static int read_bunzip(struct bunzip_data *bd, char *outbuf, int len) > > > 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 @@ static inline int unlz4(u8 *input, int in_len, > > > 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 @@ int uncompress(unsigned char *inbuf, int len, > > > > > > 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); > > > } > > > -- > > > 2.39.2 > > > > > > > > > > > > > -- > Pengutronix e.K. | | > Steuerwalder Str. 21 | http://www.pengutronix.de/ | > 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] decompress: change length arguments to long 2024-02-06 9:48 [PATCH] decompress: change length arguments to long Sascha Hauer 2024-02-06 11:16 ` Marco Felsch @ 2024-02-06 15:05 ` Sascha Hauer 1 sibling, 0 replies; 5+ messages in thread From: Sascha Hauer @ 2024-02-06 15:05 UTC (permalink / raw) To: Barebox List, Sascha Hauer On Tue, 06 Feb 2024 10:48:38 +0100, Sascha Hauer wrote: > 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)); > > [...] Applied, thanks! [1/1] decompress: change length arguments to long https://git.pengutronix.de/cgit/barebox/commit/?id=19f44baf474d (link may not be stable) Best regards, -- Sascha Hauer <s.hauer@pengutronix.de> ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-06 15:05 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-02-06 9:48 [PATCH] decompress: change length arguments to long Sascha Hauer 2024-02-06 11:16 ` Marco Felsch 2024-02-06 11:59 ` Sascha Hauer 2024-02-06 12:09 ` Marco Felsch 2024-02-06 15:05 ` Sascha Hauer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox