[PATCH 04 of 11] Events: fixed warnings with -Wpedantic in epoll notify

Maxim Dounin mdounin at mdounin.ru
Wed Aug 7 01:03:49 UTC 2024


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1722992191 -10800
#      Wed Aug 07 03:56:31 2024 +0300
# Node ID 0ad3dde839478e1cf715117b7544d5cef752d122
# Parent  ebebc1d680464f36a8a305443f1207965338bca3
Events: fixed warnings with -Wpedantic in epoll notify.

Added casts through uintptr_t to suppress "ISO C forbids assignment
between function pointer and 'void *'" warnings as seen with -Wpedantic
in ngx_epoll_notify() and ngx_epoll_notify_handler().

Additionally, it resolves "assignment type mismatch" warnings as seen
with Sun Studio on Linux, "pointer to function... "=" pointer to void"
and "pointer to void "=" pointer to function...".

diff --git a/src/event/modules/ngx_epoll_module.c b/src/event/modules/ngx_epoll_module.c
--- a/src/event/modules/ngx_epoll_module.c
+++ b/src/event/modules/ngx_epoll_module.c
@@ -452,7 +452,7 @@ ngx_epoll_notify_handler(ngx_event_t *ev
         }
     }
 
-    handler = ev->data;
+    handler = (ngx_event_handler_pt) (uintptr_t) ev->data;
     handler(ev);
 }
 
@@ -766,7 +766,7 @@ ngx_epoll_notify(ngx_event_handler_pt ha
 {
     static uint64_t inc = 1;
 
-    notify_event.data = handler;
+    notify_event.data = (void *) (uintptr_t) handler;
 
     if ((size_t) write(notify_fd, &inc, sizeof(uint64_t)) != sizeof(uint64_t)) {
         ngx_log_error(NGX_LOG_ALERT, notify_event.log, ngx_errno,



More information about the nginx-devel mailing list