From: Timo Sirainen Date: Sat, 30 Nov 2019 16:14:21 +0000 (+0200) Subject: global: Don't use CALLBACK_TYPECHECK() in arithmetic with context X-Git-Tag: 2.3.10~189 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12633e60afed99b63754b0f57548a54b4d4b6bfe;p=thirdparty%2Fdovecot%2Fcore.git global: Don't use CALLBACK_TYPECHECK() in arithmetic with context This fails if the context type is incomplete. --- diff --git a/src/lib-http/http-client.h b/src/lib-http/http-client.h index e1b1f44982..181fd15183 100644 --- a/src/lib-http/http-client.h +++ b/src/lib-http/http-client.h @@ -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 diff --git a/src/lib-http/http-server.h b/src/lib-http/http-server.h index 84156803e2..eff9286606 100644 --- a/src/lib-http/http-server.h +++ b/src/lib-http/http-server.h @@ -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)))) /* diff --git a/src/lib-smtp/smtp-client-transaction.h b/src/lib-smtp/smtp-client-transaction.h index 428bb9ce0b..b8156b26a8 100644 --- a/src/lib-smtp/smtp-client-transaction.h +++ b/src/lib-smtp/smtp-client-transaction.h @@ -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- diff --git a/src/lib-sql/sql-api.h b/src/lib-sql/sql-api.h index 7e2a683b27..e98a155b73 100644 --- a/src/lib-sql/sql-api.h +++ b/src/lib-sql/sql-api.h @@ -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); diff --git a/src/lib/iostream-proxy.h b/src/lib/iostream-proxy.h index 4b7286cd47..5e8850f0e1 100644 --- a/src/lib/iostream-proxy.h +++ b/src/lib/iostream-proxy.h @@ -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); diff --git a/src/lib/iostream-pump.h b/src/lib/iostream-pump.h index 9cadd8ba05..95fdfb7e10 100644 --- a/src/lib/iostream-pump.h +++ b/src/lib/iostream-pump.h @@ -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 diff --git a/src/lib/lib-event.h b/src/lib/lib-event.h index 2e74a233d9..a2744c3618 100644 --- a/src/lib/lib-event.h +++ b/src/lib/lib-event.h @@ -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 *)))