From 49e7572059dade9fea4f5d730d214be797d4d354 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 29 Jun 2017 15:16:44 +0200 Subject: [PATCH] fix function-pointer storage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the C standard says that you're not allowed to cast a function pointer to something else 6.3.2.3 ยง8: A pointer to a function of one type may be converted to a pointer to a function of another type and back again --- src/common.h | 2 +- src/handler.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/common.h b/src/common.h index 2f1d8c6..ab06e6b 100644 --- a/src/common.h +++ b/src/common.h @@ -107,7 +107,7 @@ typedef struct _xmpp_handlist_t xmpp_handlist_t; struct _xmpp_handlist_t { /* common members */ int user_handler; - void *handler; + int (*handler)(); void *userdata; int enabled; /* handlers are added disabled and enabled after the * handler chain is processed to prevent stanzas from diff --git a/src/handler.c b/src/handler.c index b1f19fe..d71646f 100644 --- a/src/handler.c +++ b/src/handler.c @@ -229,7 +229,7 @@ static void _timed_handler_add(xmpp_conn_t * const conn, /* check if handler is already in the list */ for (item = conn->timed_handlers; item; item = item->next) { - if (item->handler == (void *)handler && item->userdata == userdata) { + if (item->handler == handler && item->userdata == userdata) { xmpp_warn(conn->ctx, "xmpp", "Timed handler already exists."); break; } @@ -241,7 +241,7 @@ static void _timed_handler_add(xmpp_conn_t * const conn, if (!item) return; item->user_handler = user_handler; - item->handler = (void *)handler; + item->handler = handler; item->userdata = userdata; item->enabled = 0; item->next = NULL; @@ -277,7 +277,7 @@ void xmpp_timed_handler_delete(xmpp_conn_t * const conn, prev = NULL; item = conn->timed_handlers; while (item) { - if (item->handler == (void *)handler) { + if (item->handler == handler) { if (prev) prev->next = item->next; else @@ -302,7 +302,7 @@ static void _id_handler_add(xmpp_conn_t * const conn, /* check if handler is already in the list */ item = (xmpp_handlist_t *)hash_get(conn->id_handlers, id); while (item) { - if (item->handler == (void *)handler && item->userdata == userdata) { + if (item->handler == handler && item->userdata == userdata) { xmpp_warn(conn->ctx, "xmpp", "Id handler already exists."); break; } @@ -315,7 +315,7 @@ static void _id_handler_add(xmpp_conn_t * const conn, if (!item) return; item->user_handler = user_handler; - item->handler = (void *)handler; + item->handler = handler; item->userdata = userdata; item->enabled = 0; item->next = NULL; @@ -358,7 +358,7 @@ void xmpp_id_handler_delete(xmpp_conn_t * const conn, while (item) { next = item->next; - if (item->handler == (void *)handler) { + if (item->handler == handler) { if (prev) prev->next = next; else { @@ -390,7 +390,7 @@ static void _handler_add(xmpp_conn_t * const conn, for (item = conn->handlers; item; item = item->next) { /* same handler function can process different stanzas and distinguish them according to userdata. */ - if (item->handler == (void *)handler && item->userdata == userdata) { + if (item->handler == handler && item->userdata == userdata) { xmpp_warn(conn->ctx, "xmpp", "Stanza handler already exists."); break; } @@ -402,7 +402,7 @@ static void _handler_add(xmpp_conn_t * const conn, if (!item) return; item->user_handler = user_handler; - item->handler = (void *)handler; + item->handler = handler; item->userdata = userdata; item->enabled = 0; item->next = NULL; @@ -462,7 +462,7 @@ void xmpp_handler_delete(xmpp_conn_t * const conn, prev = NULL; item = conn->handlers; while (item) { - if (item->handler == (void *)handler) { + if (item->handler == handler) { if (prev) prev->next = item->next; else