[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xen/gunzip: Move window position into gunzip_state



commit 461eacc76b539f0631828c44e4c2ed38fbe3fe91
Author:     Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
AuthorDate: Wed Apr 24 12:34:18 2024 -0400
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Thu May 9 18:19:49 2024 +0100

    xen/gunzip: Move window position into gunzip_state
    
    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@xxxxxxxxxxxxxxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/common/gzip/gunzip.c  | 12 ++++++------
 xen/common/gzip/inflate.c | 18 ++++++++----------
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/xen/common/gzip/gunzip.c b/xen/common/gzip/gunzip.c
index 9892564973..f2c3a5b6cd 100644
--- a/xen/common/gzip/gunzip.c
+++ b/xen/common/gzip/gunzip.c
@@ -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)
diff --git a/xen/common/gzip/inflate.c b/xen/common/gzip/inflate.c
index ccfb2c718c..651056ef24 100644
--- a/xen/common/gzip/inflate.c
+++ b/xen/common/gzip/inflate.c
@@ -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;
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.