]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
xen/gunzip: Move window position into gunzip_state
authorDaniel P. Smith <dpsmith@apertussolutions.com>
Wed, 24 Apr 2024 16:34:18 +0000 (12:34 -0400)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 9 May 2024 17:19:49 +0000 (18:19 +0100)
Move the window position, outcnt/wp, into struct gunzip_state.  This removes
'outcnt' and it's alias 'wp'.

Consistently use the term "position" which is better than "pointer" given that
this is is a plain integer field.

Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/gzip/gunzip.c
xen/common/gzip/inflate.c

index 989256497356a489c3e2513db69eeaf1fc90c7d4..f2c3a5b6cdd1d68c58e2b9e8a398bfacf422f0bf 100644 (file)
@@ -8,6 +8,9 @@
 
 struct gunzip_state {
     unsigned char *window;
+
+    /* window position */
+    unsigned int wp;
 };
 
 static unsigned char *__initdata inbuf;
@@ -16,9 +19,6 @@ static unsigned int __initdata insize;
 /* Index of next byte to be processed in inbuf: */
 static unsigned int __initdata inptr;
 
-/* Bytes in output buffer: */
-static unsigned int __initdata outcnt;
-
 #define malloc(a)       xmalloc_bytes(a)
 #define free(a)         xfree(a)
 #define memzero(s, n)   memset((s), 0, (n))
@@ -73,15 +73,15 @@ static __init void flush_window(struct gunzip_state *s)
     unsigned char *in, ch;
 
     in = s->window;
-    for ( n = 0; n < outcnt; n++ )
+    for ( n = 0; n < s->wp; n++ )
     {
         ch = *in++;
         c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
     }
     crc = c;
 
-    bytes_out += (unsigned long)outcnt;
-    outcnt = 0;
+    bytes_out += s->wp;
+    s->wp = 0;
 }
 
 __init int gzip_check(char *image, unsigned long image_len)
index ccfb2c718ca6c4079017addedeae2b5173a1453b..651056ef243efe8d64382d33d4df9b108cd231ae 100644 (file)
@@ -160,8 +160,6 @@ static int inflate(struct gunzip_state *s);
  * "uch *slide;" and then malloc'ed in the latter case.  The definition
  * must be in unzip.h, included above.
  */
-/* unsigned wp;             current position in slide */
-#define wp outcnt
 
 /* Tables for deflate from PKZIP's appnote.txt. */
 static const unsigned border[] = {    /* Order of the bit length code lengths */
@@ -557,7 +555,7 @@ static int __init inflate_codes(
     /* make local copies of globals */
     b = bb;                       /* initialize bit buffer */
     k = bk;
-    w = wp;                       /* initialize window position */
+    w = s->wp;                    /* initialize window position */
 
     /* inflate the coded data */
     ml = mask_bits[bl];           /* precompute masks for speed */
@@ -580,7 +578,7 @@ static int __init inflate_codes(
             Tracevv((stderr, "%c", s->window[w-1]));
             if (w == WSIZE)
             {
-                wp = w;
+                s->wp = w;
                 flush_window(s);
                 w = 0;
             }
@@ -628,7 +626,7 @@ static int __init inflate_codes(
                     } while (--e);
                 if (w == WSIZE)
                 {
-                    wp = w;
+                    s->wp = w;
                     flush_window(s);
                     w = 0;
                 }
@@ -637,7 +635,7 @@ static int __init inflate_codes(
     }
 
     /* restore the globals from the locals */
-    wp = w;                       /* restore global window pointer */
+    s->wp = w;                    /* restore global window position */
     bb = b;                       /* restore global bit buffer */
     bk = k;
 
@@ -661,7 +659,7 @@ static int __init inflate_stored(struct gunzip_state *s)
     /* make local copies of globals */
     b = bb;                       /* initialize bit buffer */
     k = bk;
-    w = wp;                       /* initialize window position */
+    w = s->wp;                    /* initialize window position */
 
 
     /* go to byte boundary */
@@ -685,7 +683,7 @@ static int __init inflate_stored(struct gunzip_state *s)
         s->window[w++] = (uch)b;
         if (w == WSIZE)
         {
-            wp = w;
+            s->wp = w;
             flush_window(s);
             w = 0;
         }
@@ -693,7 +691,7 @@ static int __init inflate_stored(struct gunzip_state *s)
     }
 
     /* restore the globals from the locals */
-    wp = w;                       /* restore global window pointer */
+    s->wp = w;                    /* restore global window position */
     bb = b;                       /* restore global bit buffer */
     bk = k;
 
@@ -1014,7 +1012,7 @@ static int __init inflate(struct gunzip_state *s)
     int r;                /* result code */
 
     /* initialize window, bit buffer */
-    wp = 0;
+    s->wp = 0;
     bk = 0;
     bb = 0;