Fix gunzip to work for any gziped uImage size
PATCH 1/1 Fix gunzip to work for any gziped uImage size
--- lib/gunzip.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)
lib/gunzip.c +10 -6
@@ -106,12 +106,16 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, s.avail_in = *lenp - offset; s.next_out = dst; s.avail_out = dstlen; - r =inflate (&s,Z_FINISH ); -if ((r !=Z_STREAM_END ) && (stoponerr==1 )) { -printf ("Error: inflate() returned %d\n" , r); -inflateEnd (&s); -return (-1 ); - } +do { + r =inflate (&s,Z_FINISH ); +if ((r !=Z_STREAM_END )&& (r !=Z_BUF_ERROR )&& (stoponerr==1 )) { +printf ("Error: inflate() returned %d\n" , r); +inflateEnd (&s); +return (-1 ); + } + s.avail_in = *lenp - offset - (int )(s.next_out - (unsigned char *)dst); + s.avail_out = dstlen; + }while (r ==Z_BUF_ERROR ); *lenp = s.next_out - (unsigned char *) dst;inflateEnd (&s);
Signature · 1 line
1.6.3.3
PATCH 1/1 Fix gunzip to work for any gziped uImage size
Catalin, greetings!
Some very minor code style issues that I noticed. All cosmetic.
Quoted 11 lines · Catalin Radu
Signed-off-by Catalin Radu <[email protected]>--- lib/gunzip.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)lib/gunzip.c +0
-0@@ -106,12 +106,16 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, s.avail_in = *lenp - offset;
lib/gunzip.c int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, · line 110
Quoted 10 lines
lib/gunzip.c +2
-6s.next_out = dst; s.avail_out = dstlen; - r =inflate (&s,Z_FINISH ); -if ((r !=Z_STREAM_END ) && (stoponerr==1 )) { -printf ("Error: inflate() returned %d\n" , r); -inflateEnd (&s); -return (-1 ); - } + do { + r = inflate(&s, Z_FINISH);
Space after function name?
lib/gunzip.c int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, · line 111
Quoted 1 line
lib/gunzip.c +1
-0+if ((r !=Z_STREAM_END )&& (r !=Z_BUF_ERROR )&& (stoponerr==1 )) {
Inconsistent spacing around && operator.
Parentheses around each condition are unnecessary (both "==" and "!=" bind tighter than "&&"), but I suppose that's basically personal preference (and the code being replaced did it that way.)
lib/gunzip.c int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, · line 113
Quoted 2 lines
lib/gunzip.c +2
-0+printf ("Error: inflate() returned %d\n" , r); +inflateEnd (&s);
Space after function name?
lib/gunzip.c int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, · line 114
Quoted 1 line
lib/gunzip.c +1
-0+return (-1 );
These parentheses are unnecessary. (Another question of taste:
"return" is a keyword, not a function.)
lib/gunzip.c int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, · line 120
Quoted 6 lines
lib/gunzip.c +4
-0+ } + s.avail_in = *lenp - offset - (int )(s.next_out - (unsigned char *)dst); + s.avail_out = dstlen; + }while (r ==Z_BUF_ERROR ); *lenp = s.next_out - (unsigned char *) dst;inflateEnd (&s);
Space after function name?
As I said, all totally trivial, but especially those "&& " caught my eye. :)
Best regards,
Tony
PATCH 1/1 Fix gunzip to work for any gziped uImage size
Quoted 67 lines · Anthony Foiani
Catalin, greetings!
Some very minor code style issues that I noticed. All cosmetic.
Quoted 12 lines · Catalin Radu
Signed-off-by Catalin Radu <[email protected]>--- lib/gunzip.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)lib/gunzip.c +0
-0@@ -106,12 +106,16 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, s.avail_in = *lenp - offset; s.next_out = dst;lib/gunzip.c int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, · line 111
Quoted 10 lines
lib/gunzip.c +2
-6s.avail_out = dstlen; - r =inflate (&s,Z_FINISH ); -if ((r !=Z_STREAM_END ) && (stoponerr==1 )) { -printf ("Error: inflate() returned %d\n" , r); -inflateEnd (&s); -return (-1 ); - } + do { + r = inflate(&s, Z_FINISH);Space after function name?
lib/gunzip.c int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, · line 121
Quoted 2 lines
lib/gunzip.c +1
-0+if ((r !=Z_STREAM_END )&& (r !=Z_BUF_ERROR )&& (stoponerr==1 )) {Inconsistent spacing around && operator.
Parentheses around each condition are unnecessary (both "==" and "!=" bind tighter than "&&"), but I suppose that's basically personal preference (and the code being replaced did it that way.)
lib/gunzip.c int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, · line 121
Quoted 3 lines
lib/gunzip.c +2
-0+printf ("Error: inflate() returned %d\n" , r); +inflateEnd (&s);Space after function name?
lib/gunzip.c int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, · line 114
Quoted 2 lines
lib/gunzip.c +1
-0+return (-1 );These parentheses are unnecessary. (Another question of taste:
"return" is a keyword, not a function.)lib/gunzip.c int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, · line 120
Quoted 7 lines
lib/gunzip.c +4
-0+ } + s.avail_in = *lenp - offset - (int )(s.next_out - (unsigned char *)dst); + s.avail_out = dstlen; + }while (r ==Z_BUF_ERROR );lib/gunzip.c +0
-0*lenp = s.next_out - (unsigned char *) dst;inflateEnd (&s);Space after function name?
Quoted 5 lines
As I said, all totally trivial, but especially those "&& " caught my eye. :)
Best regards,
Tony
Greetings Tony,
Thanks for the formatting observations. I will resend the re-formatted patch.
Regards,
Catalin