[PATCH] gunzip: Fix len parameter in function signature

Tom Rini trini at konsulko.com
Wed Jan 28 15:27:16 CET 2026


On Wed, Jan 28, 2026 at 01:01:09PM +0100, Marek Vasut wrote:
> On 1/28/26 5:32 AM, Heinrich Schuchardt wrote:
> 
> Hello Heinrich,
> 
> > > diff --git a/include/gzip.h b/include/gzip.h
> > > index 304002ffc42..5396e3ffec7 100644
> > > --- a/include/gzip.h
> > > +++ b/include/gzip.h
> > > @@ -77,8 +77,8 @@ void gzwrite_progress_finish(int retcode, ulong totalwritten, ulong totalsize,
> > >   *		for files under 4GiB
> > >   * Return: 0 if OK, -1 on error
> > > p */
> > > -int gzwrite(unsigned char *src, int len, struct blk_desc *dev, ulong szwritebuf,
> > > -	    ulong startoffs, ulong szexpected);
> > > +int gzwrite(unsigned char *src, unsigned long len, struct blk_desc *dev,
> > > +	    ulong szwritebuf, ulong startoffs, ulong szexpected);
> > 
> > Ulong and unsigned long are essentially the same but using both in one function signature looks weird.
> > 
> > I would prefer size_t for the size of objects in memory and off_t for file sizes and positions in files.
> > 
> > Please, consider adjusting startoffs and szexpected, too.
> 
> OK
> 
> > > /**
> > >   * gzip()- Compress data into a buffer using the gzip algorithm
> > > diff --git a/lib/gunzip.c b/lib/gunzip.c
> > > index a05dcde9a75..040450c0e79 100644
> > > --- a/lib/gunzip.c
> > > +++ b/lib/gunzip.c
> > > @@ -116,11 +116,8 @@ void gzwrite_progress_finish(int returnval,
> > > 	}
> > > }
> > > 
> > > -int gzwrite(unsigned char *src, int len,
> > > -	    struct blk_desc *dev,
> > > -	    unsigned long szwritebuf,
> > > -	    ulong startoffs,
> > > -	    ulong szexpected)
> > > +int gzwrite(unsigned char *src, unsigned long len, struct blk_desc *dev,
> > > +	    ulong szwritebuf, ulong startoffs, ulong szexpected)
> > 
> > ditto
> > 
> > > {
> > > 	int i, flags;
> > > 	z_stream s;
> > > @@ -133,6 +130,12 @@ int gzwrite(unsigned char *src, int len,
> > > 	u32 payload_size;
> > > 	int iteration = 0;
> > > 
> > > +	if (len > 0xffffffff) {
> > > +		printf("%s: input size over 4 GiB in size not supported\n",
> > > +		       __func__);
> > 
> > Please, use log_err() for error output.
> I believe log_*() primitives are frowned upon ? Tom ?

My initial answer is that log_*() is better than just plain printf. I
think my high level complaint is that we have too many logging macros
that do the same thing and that should be looked at, at some point.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260128/d0ce78ab/attachment.sig>


More information about the U-Boot mailing list