public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/zlib: drop EQUAL macro
@ 2025-02-05 21:29 Yury Norov
  2025-02-06 17:53 ` Zaslonko Mikhail
  0 siblings, 1 reply; 2+ messages in thread
From: Yury Norov @ 2025-02-05 21:29 UTC (permalink / raw)
  To: Andrew Morton, Mikhail Zaslonko, Heiko Carstens, Ilya Leoshkevich,
	Sergey Senozhatsky, linux-kernel
  Cc: Yury Norov, Joe Perches

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@gmail.com>
---
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@gmail.com> (authored:1/1=100%,added_lines:1/1=100%,removed_lines:5/5=100%)
linux-kernel@vger.kernel.org (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 {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] lib/zlib: drop EQUAL macro
  2025-02-05 21:29 [PATCH] lib/zlib: drop EQUAL macro Yury Norov
@ 2025-02-06 17:53 ` Zaslonko Mikhail
  0 siblings, 0 replies; 2+ messages in thread
From: Zaslonko Mikhail @ 2025-02-06 17:53 UTC (permalink / raw)
  To: Yury Norov, Andrew Morton, Heiko Carstens, Ilya Leoshkevich,
	Sergey Senozhatsky, linux-kernel
  Cc: Joe Perches

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@linux.ibm.com>

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@gmail.com>
> ---
> 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@gmail.com> (authored:1/1=100%,added_lines:1/1=100%,removed_lines:5/5=100%)
> linux-kernel@vger.kernel.org (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 {


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-06 17:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-05 21:29 [PATCH] lib/zlib: drop EQUAL macro Yury Norov
2025-02-06 17:53 ` Zaslonko Mikhail

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox