[nginx] Removed casts from ngx_memcmp() macro.

Roman Arutyunyan arut at nginx.com
Tue Dec 6 15:26:36 UTC 2022

details:   https://hg.nginx.org/nginx/rev/2ffefe2f892e
changeset: 8109:2ffefe2f892e
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Wed Nov 30 18:01:53 2022 +0300
Removed casts from ngx_memcmp() macro.

Casts are believed to be not needed, since memcmp() has "const void *"
arguments since introduction of the "void" type in C89.  And on pre-C89
platforms nginx is unlikely to compile without warnings anyway, as there
are no casts in memcpy() and memmove() calls.

These casts were added in 1648:89a47f19b9ec without any details on why they
were added, and Igor does not remember details either.  The most plausible
explanation is that they were copied from ngx_strcmp() and were not really
needed even at that time.

Prodded by Alejandro Colomar.


 src/core/ngx_string.h |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 351d7f4e326f -r 2ffefe2f892e src/core/ngx_string.h
--- a/src/core/ngx_string.h	Wed Nov 30 18:01:43 2022 +0300
+++ b/src/core/ngx_string.h	Wed Nov 30 18:01:53 2022 +0300
@@ -145,7 +145,7 @@ ngx_copy(u_char *dst, u_char *src, size_
 /* msvc and icc7 compile memcmp() to the inline loop */
-#define ngx_memcmp(s1, s2, n)  memcmp((const char *) s1, (const char *) s2, n)
+#define ngx_memcmp(s1, s2, n)     memcmp(s1, s2, n)
 u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n);

More information about the nginx-devel mailing list