[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v3 5/8] gzip: move input buffer handling into gunzip state
On 24.04.2024 18:34, Daniel P. Smith wrote: > --- a/xen/common/gzip/gunzip.c > +++ b/xen/common/gzip/gunzip.c > @@ -10,13 +10,12 @@ struct gunzip_state { > unsigned char *window; > /* window pointer: */ > unsigned int wp; > -}; > - > -static unsigned char *__initdata inbuf; > -static unsigned int __initdata insize; > > -/* Index of next byte to be processed in inbuf: */ > -static unsigned int __initdata inptr; > + unsigned char *inbuf; > + size_t insize; > + /* Index of next byte to be processed in inbuf: */ > + unsigned int inptr; I'm puzzled by the (suddenly) different types, seeing that ... > +}; > > #define malloc(a) xmalloc_bytes(a) > #define free(a) xfree(a) > @@ -51,14 +50,14 @@ static __init void error(const char *x) > panic("%s\n", x); > } > > -static __init uch get_byte(void) { > - if ( inptr >= insize ) > +static __init uch get_byte(struct gunzip_state *s) { > + if ( s->inptr >= s->insize ) ... both are compared with one another. > @@ -1129,29 +1129,29 @@ static int __init gunzip(struct gunzip_state *s) > error("Input has invalid flags"); > return -1; > } > - NEXTBYTE(); /* Get timestamp */ > - NEXTBYTE(); > - NEXTBYTE(); > - NEXTBYTE(); > + NEXTBYTE(s); /* Get timestamp */ > + NEXTBYTE(s); > + NEXTBYTE(s); > + NEXTBYTE(s); > > - NEXTBYTE(); /* Ignore extra flags for the moment */ > - NEXTBYTE(); /* Ignore OS type for the moment */ > + NEXTBYTE(s); /* Ignore extra flags for the moment */ > + NEXTBYTE(s); /* Ignore OS type for the moment */ > > if ((flags & EXTRA_FIELD) != 0) { > - unsigned len = (unsigned)NEXTBYTE(); > - len |= ((unsigned)NEXTBYTE())<<8; > - while (len--) (void)NEXTBYTE(); > + unsigned len = (unsigned)NEXTBYTE(s); > + len |= ((unsigned)NEXTBYTE(s))<<8; > + while (len--) (void)NEXTBYTE(s); Would you mind moving the body of this while() to its own line, as you touch this anyway? > } > > /* Get original file name if it was truncated */ > if ((flags & ORIG_NAME) != 0) { > /* Discard the old name */ > - while (NEXTBYTE() != 0) /* null */ ; > + while (NEXTBYTE(s) != 0) /* null */ ; > } > > /* Discard file comment if any */ > if ((flags & COMMENT) != 0) { > - while (NEXTBYTE() != 0) /* null */ ; > + while (NEXTBYTE(s) != 0) /* null */ ; > } For these two doing the same may help, too. Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |