]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Don't use CALLBACK_TYPECHECK() in arithmetic with context
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sat, 30 Nov 2019 16:14:21 +0000 (18:14 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 13 Dec 2019 13:14:23 +0000 (13:14 +0000)
This fails if the context type is incomplete.

src/lib-http/http-client.h
src/lib-http/http-server.h
src/lib-smtp/smtp-client-transaction.h
src/lib-sql/sql-api.h
src/lib/iostream-proxy.h
src/lib/iostream-pump.h
src/lib/lib-event.h

index e1b1f44982b969e3d554ddde40d44247c7f1116c..181fd15183eb3f6eb14b20734ff527b090b1662a 100644 (file)
@@ -428,7 +428,8 @@ void http_client_request_set_destroy_callback(struct http_client_request *req,
                                              void (*callback)(void *),
                                              void *context);
 #define http_client_request_set_destroy_callback(req, callback, context) \
-        http_client_request_set_destroy_callback(req, (void(*)(void*))callback, context - \
+        http_client_request_set_destroy_callback(req, (void(*)(void*))callback, \
+               TRUE ? context : \
                 CALLBACK_TYPECHECK(callback, void (*)(typeof(context))))
 
 /* submits request and blocks until the provided payload is sent. Multiple
index 84156803e20b720e9bf102d0118b074bde530398..eff92866067857ce04fbd99db70a37b0ada01d03 100644 (file)
@@ -189,7 +189,7 @@ void http_server_request_forward_payload(struct http_server_request *req,
 #define http_server_request_forward_payload(req, \
                output, max_size, callback, context) \
        http_server_request_forward_payload(req, output, max_size, \
-               (void(*)(void*))callback, context - \
+               (void(*)(void*))callback, TRUE ? context : \
                CALLBACK_TYPECHECK(callback, void (*)(typeof(context))))
 /* Forward the incoming request payload to the provided buffer in the
    background. Behaves identical to http_server_request_forward_payload()
@@ -200,7 +200,7 @@ void http_server_request_buffer_payload(struct http_server_request *req,
 #define http_server_request_buffer_payload(req, \
                buffer, max_size, callback, context) \
        http_server_request_buffer_payload(req, buffer, max_size, \
-               (void(*)(void*))callback, context - \
+               (void(*)(void*))callback, TRUE ? context : \
                CALLBACK_TYPECHECK(callback, void (*)(typeof(context))))
 /* Handle the incoming request payload by calling the callback each time
    more data is available. Payload reading automatically finishes when the
@@ -211,7 +211,7 @@ void http_server_request_handle_payload(struct http_server_request *req,
        void (*callback)(void *context), void *context);
 #define http_server_request_handle_payload(req, callback, context) \
        http_server_request_handle_payload(req,\
-               (void(*)(void*))callback, context - \
+               (void(*)(void*))callback, TRUE ? context : \
                CALLBACK_TYPECHECK(callback, void (*)(typeof(context))))
 
 /* Get the authentication credentials provided in this request. Returns 0 if
@@ -260,7 +260,8 @@ void http_server_request_set_destroy_callback(struct http_server_request *req,
                                              void (*callback)(void *),
                                              void *context);
 #define http_server_request_set_destroy_callback(req, callback, context) \
-       http_server_request_set_destroy_callback(req, (void(*)(void*))callback, context - \
+       http_server_request_set_destroy_callback(req, (void(*)(void*))callback, \
+               TRUE ? context : \
                CALLBACK_TYPECHECK(callback, void (*)(typeof(context))))
 
 /*
index 428bb9ce0b3a028493035f88155d74e72c362c2b..b8156b26a847fbce3a9836ebc702110cddf8b33b 100644 (file)
@@ -87,8 +87,8 @@ void smtp_client_transaction_start(struct smtp_client_transaction *trans,
        smtp_client_command_callback_t *mail_callback, void *context);
 #define smtp_client_transaction_start(trans, mail_callback, context) \
        smtp_client_transaction_start(trans, \
-               (smtp_client_command_callback_t *)mail_callback, \
-               context - CALLBACK_TYPECHECK(mail_callback, void (*)( \
+               (smtp_client_command_callback_t *)mail_callback, TRUE ? context : \
+               CALLBACK_TYPECHECK(mail_callback, void (*)( \
                        const struct smtp_reply *reply, typeof(context))))
 /* Start the transaction with a MAIL command. This function allows providing the
    parameters for the MAIL FROM command for when the transaction was created
@@ -106,8 +106,8 @@ void smtp_client_transaction_start_empty(
 #define smtp_client_transaction_start_empty(trans, mail_from, mail_params, \
                                            mail_callback, context) \
        smtp_client_transaction_start_empty(trans, mail_from, mail_params, \
-               (smtp_client_command_callback_t *)mail_callback, \
-               context - CALLBACK_TYPECHECK(mail_callback, void (*)( \
+               (smtp_client_command_callback_t *)mail_callback, TRUE ? context : \
+               CALLBACK_TYPECHECK(mail_callback, void (*)( \
                        const struct smtp_reply *reply, typeof(context))))
 
 /* Add an extra pipelined MAIL command to the transaction. The mail_callback is
@@ -230,7 +230,8 @@ void smtp_client_transaction_reset(
 #define smtp_client_transaction_reset(trans, reset_callback, reset_context) \
        smtp_client_transaction_reset(trans, \
                (smtp_client_command_callback_t *)reset_callback, \
-               reset_context - CALLBACK_TYPECHECK(reset_callback, void (*)( \
+               TRUE ? reset_context : \
+               CALLBACK_TYPECHECK(reset_callback, void (*)( \
                        const struct smtp_reply *reply, typeof(reset_context))))
 
 /* Enables mode in which all commands are submitted immediately and (non-
index 7e2a683b27b873a1868b3b1f86fe3182f9436a59..e98a155b7375b16d7b8887a864868c1ccc3f7361 100644 (file)
@@ -150,7 +150,7 @@ void sql_statement_query(struct sql_statement **stmt,
                         sql_query_callback_t *callback, void *context);
 #define sql_statement_query(stmt, callback, context) \
        sql_statement_query(stmt, \
-               (sql_query_callback_t *)callback, context - \
+               (sql_query_callback_t *)callback, TRUE ? context : \
                CALLBACK_TYPECHECK(callback, void (*)( \
                        struct sql_result *, typeof(context))))
 struct sql_result *sql_statement_query_s(struct sql_statement **stmt);
index 4b7286cd47a32bf4654e5964b09a6cc241bedd63..5e8850f0e125afb6787cb85cb07ff9c4a16634f6 100644 (file)
@@ -75,7 +75,8 @@ bool iostream_proxy_is_waiting_output(struct iostream_proxy *proxy,
 void iostream_proxy_set_completion_callback(struct iostream_proxy *proxy,
                                       iostream_proxy_callback_t *callback, void *context);
 #define iostream_proxy_set_completion_callback(proxy, callback, context) \
-       iostream_proxy_set_completion_callback(proxy, (iostream_proxy_callback_t *)callback, context - \
+       iostream_proxy_set_completion_callback(proxy, (iostream_proxy_callback_t *)callback, \
+               TRUE ? context : \
                CALLBACK_TYPECHECK(callback, void (*)(enum iostream_proxy_side side, enum iostream_proxy_status, typeof(context))))
 
 void iostream_proxy_ref(struct iostream_proxy *proxy);
index 9cadd8ba05e05cba9232cb48931ece8bac47da8c..95fdfb7e1023396fa9f64abdf890e569c8961e0d 100644 (file)
@@ -51,8 +51,8 @@ void iostream_pump_set_completion_callback(struct iostream_pump *pump,
                                           void *context);
 #define iostream_pump_set_completion_callback(pump, callback, context) \
        iostream_pump_set_completion_callback(pump, \
-               (iostream_pump_callback_t *)callback, \
-               context - CALLBACK_TYPECHECK(callback, \
+               (iostream_pump_callback_t *)callback, TRUE ? context : \
+               CALLBACK_TYPECHECK(callback, \
                        void (*)(enum iostream_pump_status, typeof(context))))
 
 /* Returns TRUE if the pump is currently only writing to the ostream. The input
index 2e74a233d9cfd01640da455a58f393f17de1eefb..a2744c361846b4db4459927a0251d849b3455050 100644 (file)
@@ -205,8 +205,9 @@ struct event *event_set_log_prefix_callback(struct event *event,
                                            event_log_prefix_callback_t *callback,
                                            void *context);
 #define event_set_log_prefix_callback(event, replace, callback, context) \
-       event_set_log_prefix_callback(event, replace, (event_log_prefix_callback_t*)callback, \
-               context - CALLBACK_TYPECHECK(callback, const char *(*)(typeof(context))))
+       event_set_log_prefix_callback(event, replace, \
+               (event_log_prefix_callback_t*)callback, TRUE ? context : \
+               CALLBACK_TYPECHECK(callback, const char *(*)(typeof(context))))
 
 /* Sets event message amendment callback */
 struct event *event_set_log_message_callback(struct event *event,
@@ -214,8 +215,8 @@ struct event *event_set_log_message_callback(struct event *event,
                                             void *context);
 #define event_set_log_message_callback(event, callback, context) \
        event_set_log_message_callback(event, \
-               (event_log_message_callback_t*)callback, \
-               context - CALLBACK_TYPECHECK(callback, \
+               (event_log_message_callback_t*)callback, TRUE ? context : \
+               CALLBACK_TYPECHECK(callback, \
                        const char *(*)(typeof(context), enum log_type, \
                                        const char *)))