[nginx] Events: fixed warnings with -Wpedantic in epoll notify.

Maxim Dounin mdounin at mdounin.ru
Mon Aug 12 03:37:05 UTC 2024


details:   http://freenginx.org/hg/nginx/rev/0ad3dde83947
branches:  
changeset: 9311:0ad3dde83947
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Wed Aug 07 03:56:31 2024 +0300
description:
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...".

diffstat:

 src/event/modules/ngx_epoll_module.c |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (21 lines):

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