Mailing List Archive

[PATCH v2 1/6] gzip: drop unused define checks
Dropping the define checks for PKZIP_BUG_WORKAROUND and NOMEMCPY define as they
never are set.

Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
---
xen/common/gzip/inflate.c | 15 ---------------
1 file changed, 15 deletions(-)

diff --git a/xen/common/gzip/inflate.c b/xen/common/gzip/inflate.c
index 58f263d9e852..e95db2de4d9b 100644
--- a/xen/common/gzip/inflate.c
+++ b/xen/common/gzip/inflate.c
@@ -661,7 +661,6 @@ static int __init inflate_codes(
/* do the copy */
do {
n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e);
-#if !defined(NOMEMCPY) && !defined(DEBUG)
if (w - d >= e) /* (this test assumes unsigned comparison) */
{
memcpy(slide + w, slide + d, e);
@@ -669,7 +668,6 @@ static int __init inflate_codes(
d += e;
}
else /* do it slow to avoid memcpy() overlap */
-#endif /* !NOMEMCPY */
do {
slide[w++] = slide[d++];
Tracevv((stderr, "%c", slide[w-1]));
@@ -845,11 +843,7 @@ static int noinline __init inflate_dynamic(void)

DEBG("<dyn");

-#ifdef PKZIP_BUG_WORKAROUND
- ll = malloc(sizeof(*ll) * (288+32)); /* literal/length and distance code lengths */
-#else
ll = malloc(sizeof(*ll) * (286+30)); /* literal/length and distance code lengths */
-#endif

if (ll == NULL)
return 1;
@@ -869,11 +863,7 @@ static int noinline __init inflate_dynamic(void)
NEEDBITS(4)
nb = 4 + ((unsigned)b & 0xf); /* number of bit length codes */
DUMPBITS(4)
-#ifdef PKZIP_BUG_WORKAROUND
- if (nl > 288 || nd > 32)
-#else
if (nl > 286 || nd > 30)
-#endif
{
ret = 1; /* bad lengths */
goto out;
@@ -989,16 +979,11 @@ static int noinline __init inflate_dynamic(void)
DEBG("dyn5d ");
if (i == 1) {
error("incomplete distance tree");
-#ifdef PKZIP_BUG_WORKAROUND
- i = 0;
- }
-#else
huft_free(td);
}
huft_free(tl);
ret = i; /* incomplete code set */
goto out;
-#endif
}

DEBG("dyn6 ");
--
2.30.2
Re: [PATCH v2 1/6] gzip: drop unused define checks [ In reply to ]
On 17/04/2024 3:37 pm, Daniel P. Smith wrote:
> Dropping the define checks for PKZIP_BUG_WORKAROUND and NOMEMCPY define as they
> never are set.
>
> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>

It looks like ARCH_HAS_DECOMP_WDOG is another one that can go.

There's only a single instance, in inflate(), which I'm happy to fold on
commit.

~Andrew
Re: [PATCH v2 1/6] gzip: drop unused define checks [ In reply to ]
On 17.04.2024 16:37, Daniel P. Smith wrote:
> Dropping the define checks for PKZIP_BUG_WORKAROUND and NOMEMCPY define as they
> never are set.

You don't mention or otherwise touch DEBUG uses, yet ...

> --- a/xen/common/gzip/inflate.c
> +++ b/xen/common/gzip/inflate.c
> @@ -661,7 +661,6 @@ static int __init inflate_codes(
> /* do the copy */
> do {
> n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e);
> -#if !defined(NOMEMCPY) && !defined(DEBUG)

... you also don't replace this by "#ifndef DEBUG", but outright delete
the line.

Jan