details:   
https://github.com/nginx/nginx/commit/4eaecc5e8aa7bbaf9e58bf56560a8b1e67d0a8b7
branches:  master
commit:    4eaecc5e8aa7bbaf9e58bf56560a8b1e67d0a8b7
user:      Andrew Clayton <a.clay...@nginx.com>
date:      Wed, 21 May 2025 22:30:20 +0100
description:
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>

---
 src/core/ngx_thread_pool.c                       | 2 +-
 src/event/ngx_event_openssl_cache.c              | 2 +-
 src/event/quic/ngx_event_quic.c                  | 2 +-
 src/http/modules/ngx_http_gunzip_filter_module.c | 2 +-
 src/http/modules/ngx_http_ssi_filter_module.c    | 2 +-
 src/os/unix/ngx_time.c                           | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/core/ngx_thread_pool.c b/src/core/ngx_thread_pool.c
index 7fb0f7f8d..7bf90e958 100644
--- a/src/core/ngx_thread_pool.c
+++ b/src/core/ngx_thread_pool.c
@@ -207,7 +207,7 @@ ngx_thread_pool_exit_handler(void *data, ngx_log_t *log)
 
     *lock = 0;
 
-    pthread_exit(0);
+    pthread_exit(NULL);
 }
 
 
diff --git a/src/event/ngx_event_openssl_cache.c 
b/src/event/ngx_event_openssl_cache.c
index 18efc73d0..42f5e1c9f 100644
--- a/src/event/ngx_event_openssl_cache.c
+++ b/src/event/ngx_event_openssl_cache.c
@@ -707,7 +707,7 @@ ngx_ssl_cache_pkey_create(ngx_ssl_cache_key_t *id, char 
**err, void *data)
             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";
diff --git a/src/event/quic/ngx_event_quic.c b/src/event/quic/ngx_event_quic.c
index 8df487773..6a59aaf93 100644
--- a/src/event/quic/ngx_event_quic.c
+++ b/src/event/quic/ngx_event_quic.c
@@ -964,7 +964,7 @@ ngx_quic_handle_payload(ngx_connection_t *c, 
ngx_quic_header_t *pkt)
     qc = ngx_quic_get_connection(c);
 
     qc->error = 0;
-    qc->error_reason = 0;
+    qc->error_reason = NULL;
 
     c->log->action = "decrypting packet";
 
diff --git a/src/http/modules/ngx_http_gunzip_filter_module.c 
b/src/http/modules/ngx_http_gunzip_filter_module.c
index 5d170a1ba..22e75e300 100644
--- a/src/http/modules/ngx_http_gunzip_filter_module.c
+++ b/src/http/modules/ngx_http_gunzip_filter_module.c
@@ -304,7 +304,7 @@ ngx_http_gunzip_filter_inflate_start(ngx_http_request_t *r,
 {
     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;
diff --git a/src/http/modules/ngx_http_ssi_filter_module.c 
b/src/http/modules/ngx_http_ssi_filter_module.c
index c862be05a..65ca03440 100644
--- a/src/http/modules/ngx_http_ssi_filter_module.c
+++ b/src/http/modules/ngx_http_ssi_filter_module.c
@@ -820,7 +820,7 @@ ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t 
*in)
                 }
 
                 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",
diff --git a/src/os/unix/ngx_time.c b/src/os/unix/ngx_time.c
index cc760b2eb..c97bae2ed 100644
--- a/src/os/unix/ngx_time.c
+++ b/src/os/unix/ngx_time.c
@@ -43,7 +43,7 @@ ngx_timezone_update(void)
     struct tm  *t;
     char        buf[4];
 
-    s = time(0);
+    s = time(NULL);
 
     t = localtime(&s);
 
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to