|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v3 8/8] gzip: move crc state into gunzip state
On 24.04.2024 18:34, Daniel P. Smith wrote:
> Move the crc and its state into struct gunzip_state. In the process, expand
> the
> only use of CRC_VALUE as it is hides what is being compared.
Andrew mentioned uint32_t only for the description, but I think you want
(maybe even need) to go further and actually use that type also, e.g.
> --- a/xen/common/gzip/gunzip.c
> +++ b/xen/common/gzip/gunzip.c
> @@ -20,6 +20,9 @@ struct gunzip_state {
>
> unsigned long bb; /* bit buffer */
> unsigned int bk; /* bits in bit buffer */
> +
> + uint32_t crc_32_tab[256];
> + uint32_t crc;
> };
... not just here, but also ...
> @@ -72,7 +75,7 @@ static __init void flush_window(struct gunzip_state *s)
> * The window is equal to the output buffer therefore only need to
> * compute the crc.
> */
> - unsigned long c = crc;
> + unsigned int c = s->crc;
... here.
> --- a/xen/common/gzip/inflate.c
> +++ b/xen/common/gzip/inflate.c
> @@ -1032,16 +1032,12 @@ static int __init inflate(struct gunzip_state *s)
> *
> **********************************************************************/
>
> -static ulg __initdata crc_32_tab[256];
> -static ulg __initdata crc; /* initialized in makecrc() so it'll reside in
> bss */
> -#define CRC_VALUE (crc ^ 0xffffffffUL)
Note how this is _not_ same as ~0u, also ...
> @@ -1069,11 +1065,11 @@ static void __init makecrc(void)
> if (k & 1)
> c ^= e;
> }
> - crc_32_tab[i] = c;
> + s->crc_32_tab[i] = c;
> }
>
> /* this is initialized here so this code could reside in ROM */
> - crc = (ulg)0xffffffffUL; /* shift register contents */
> + s->crc = (ulg)~0u; /* shift register contents */
... applicable here then: sizeof(int) >= 4, not ==.
As Andrew indicates, the cast previously wasn't needed here. Keeping it is
at best misleading, when s->crc isn't of that type anymore.
Finally please stick to upper-case number suffixes; see all the related Misra
changes, which (iirc) put in place only upper-case ones.
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |