From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Tue, 06 Feb 2024 10:49:38 +0100 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rXI59-005Uhy-2F for lore@lore.pengutronix.de; Tue, 06 Feb 2024 10:49:38 +0100 Received: from bombadil.infradead.org ([2607:7c80:54:3::133]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rXI59-0001Rk-K7 for lore@pengutronix.de; Tue, 06 Feb 2024 10:49:36 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=hkB5pSt3Frrr+aupKCrGxwk9hNKm+pvzIInIPcYt9CE=; b=saIDcocPbWC/QKimOnVHlBxEkC sm8Qq1MoOHx+6io1acjR3ZNuArmSaFnrn7RBtORV5VEjI4/ydwnE6zw8YwbH7uvss4Nu+Ahg0bjJr JZB71v1hKINrll8D70RSV5Oe5uMi0NsxvVJ4/YUhL//OOEQ5g2HTKfwhOv4WsDyCt5cxAMUUbsv2I 0GDTyyQOCKIlXhrJLe+Wc9kJ5UrpwVHY8WWNpKjxCm32L/LewHmad1fEM7DS9yr1DkiorIqZxU5yC 9bi9d94bxZtTASVpPcBibrwel7IPubBcrLtaIVWo4F5+aKWXf3sXP7B7+rZgf53kcWWIpPVKb5grl ahFdFW9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXI4M-00000006o5z-3KoS; Tue, 06 Feb 2024 09:48:46 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXI4J-00000006o4F-1fdG for barebox@lists.infradead.org; Tue, 06 Feb 2024 09:48:45 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rXI4F-0001LX-Ny; Tue, 06 Feb 2024 10:48:39 +0100 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rXI4F-004nSi-BE; Tue, 06 Feb 2024 10:48:39 +0100 Received: from localhost ([::1] helo=dude02.red.stw.pengutronix.de) by dude02.red.stw.pengutronix.de with esmtp (Exim 4.96) (envelope-from ) id 1rXI4F-008KyX-0k; Tue, 06 Feb 2024 10:48:39 +0100 From: Sascha Hauer To: Barebox List Date: Tue, 6 Feb 2024 10:48:38 +0100 Message-Id: <20240206094838.1987246-1-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240206_014843_775188_82C7353B X-CRM114-Status: GOOD ( 18.43 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:3::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-5.2 required=4.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Subject: [PATCH] decompress: change length arguments to long X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.whiteo.stw.pengutronix.de) 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 --- 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 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