Re: [PATCH] lib/zlib: drop EQUAL macro
From: Zaslonko Mikhail
Date: Thu Feb 06 2025 - 12:57:46 EST
Hi Yury,
I think the initial idea was to keep the code similar to the userspace zlib for serviceability.
But since it leads to extra warnings, it's worth fixing.
Reviewed-by: Mikhail Zaslonko <zaslonko@xxxxxxxxxxxxx>
On 05.02.2025 22:29, Yury Norov wrote:
> The macro is pre-historic, and only exists to help those readers who
> don't know what memcmp() returns if memory areas differ. This is pretty
> well documented, so the macro looks excessive.
>
> Now that the only user of the macro depends on DEBUG_ZLIB config, GCC
> warns about unused macro if the library is built with W=2 against
> defconfig. So drop it for good.
>
> Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx>
> ---
> scripts/get_maintainer.pl failed to attribute this patch, so adding
> Andrew and recent active developers, and Joe Perches for the script.
>
> $ scripts/get_maintainer.pl 0001-zlib-drop-EQUAL-macro.patch
> Bad divisor in main::vcs_assign: 0
> "GitAuthor: Yury Norov" <yury.norov@xxxxxxxxx> (authored:1/1=100%,added_lines:1/1=100%,removed_lines:5/5=100%)
> linux-kernel@xxxxxxxxxxxxxxx (open list)
>
> lib/zlib_deflate/deflate.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/lib/zlib_deflate/deflate.c b/lib/zlib_deflate/deflate.c
> index 3a1d8d34182e..8fb2a3e17c0e 100644
> --- a/lib/zlib_deflate/deflate.c
> +++ b/lib/zlib_deflate/deflate.c
> @@ -151,9 +151,6 @@ static const config configuration_table[10] = {
> * meaning.
> */
>
> -#define EQUAL 0
> -/* result of memcmp for equal strings */
> -
> /* ===========================================================================
> * Update a hash value with the given input byte
> * IN assertion: all calls to UPDATE_HASH are made with consecutive
> @@ -713,8 +710,7 @@ static void check_match(
> )
> {
> /* check that the match is indeed a match */
> - if (memcmp((char *)s->window + match,
> - (char *)s->window + start, length) != EQUAL) {
> + if (memcmp((char *)s->window + match, (char *)s->window + start, length)) {
> fprintf(stderr, " start %u, match %u, length %d\n",
> start, match, length);
> do {