changeset 9421:927f43435c0a

Use NULL instead of 0 for null pointer constant. There were a few random places where 0 was being used as a null pointer constant. We have a NULL macro for this very purpose, use it. There is also some interest in actually deprecating the use of 0 as a null pointer constant in C. This was found with -Wzero-as-null-pointer-constant which was enabled for C in GCC 15 (not enabled with Wall or Wextra... yet). Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117059>
author Andrew Clayton <a.clayton@nginx.com>
date Wed, 21 May 2025 22:30:20 +0100
parents 666b706a30b3
children 44a05528fa46
files src/core/ngx_thread_pool.c src/event/ngx_event_openssl_cache.c src/event/quic/ngx_event_quic.c src/http/modules/ngx_http_gunzip_filter_module.c src/http/modules/ngx_http_ssi_filter_module.c src/os/unix/ngx_time.c
diffstat 6 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/ngx_thread_pool.c	Wed May 21 22:19:32 2025 +0100
+++ b/src/core/ngx_thread_pool.c	Wed May 21 22:30:20 2025 +0100
@@ -207,7 +207,7 @@
 
     *lock = 0;
 
-    pthread_exit(0);
+    pthread_exit(NULL);
 }
 
 
--- a/src/event/ngx_event_openssl_cache.c	Wed May 21 22:19:32 2025 +0100
+++ b/src/event/ngx_event_openssl_cache.c	Wed May 21 22:30:20 2025 +0100
@@ -707,7 +707,7 @@
             return NULL;
         }
 
-        pkey = ENGINE_load_private_key(engine, (char *) last, 0, 0);
+        pkey = ENGINE_load_private_key(engine, (char *) last, NULL, NULL);
 
         if (pkey == NULL) {
             *err = "ENGINE_load_private_key() failed";
--- a/src/event/quic/ngx_event_quic.c	Wed May 21 22:19:32 2025 +0100
+++ b/src/event/quic/ngx_event_quic.c	Wed May 21 22:30:20 2025 +0100
@@ -964,7 +964,7 @@
     qc = ngx_quic_get_connection(c);
 
     qc->error = 0;
-    qc->error_reason = 0;
+    qc->error_reason = NULL;
 
     c->log->action = "decrypting packet";
 
--- a/src/http/modules/ngx_http_gunzip_filter_module.c	Wed May 21 22:19:32 2025 +0100
+++ b/src/http/modules/ngx_http_gunzip_filter_module.c	Wed May 21 22:30:20 2025 +0100
@@ -304,7 +304,7 @@
 {
     int  rc;
 
-    ctx->zstream.next_in = Z_NULL;
+    ctx->zstream.next_in = NULL;
     ctx->zstream.avail_in = 0;
 
     ctx->zstream.zalloc = ngx_http_gunzip_filter_alloc;
--- a/src/http/modules/ngx_http_ssi_filter_module.c	Wed May 21 22:19:32 2025 +0100
+++ b/src/http/modules/ngx_http_ssi_filter_module.c	Wed May 21 22:30:20 2025 +0100
@@ -820,7 +820,7 @@
                 }
 
                 for (prm = cmd->params; prm->name.len; prm++) {
-                    if (prm->mandatory && params[prm->index] == 0) {
+                    if (prm->mandatory && params[prm->index] == NULL) {
                         ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                                       "mandatory \"%V\" parameter is absent "
                                       "in \"%V\" SSI command",
--- a/src/os/unix/ngx_time.c	Wed May 21 22:19:32 2025 +0100
+++ b/src/os/unix/ngx_time.c	Wed May 21 22:30:20 2025 +0100
@@ -43,7 +43,7 @@
     struct tm  *t;
     char        buf[4];
 
-    s = time(0);
+    s = time(NULL);
 
     t = localtime(&s);