dovecot-2.2: lib: Code cleanup - check io_loop_context_add/remov...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Sep 25 12:16:03 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/e588792b4f20
changeset: 17839:e588792b4f20
user: Timo Sirainen <tss at iki.fi>
date: Thu Sep 25 15:15:20 2014 +0300
description:
lib: Code cleanup - check io_loop_context_add/remove_callbacks() callback parameters.
diffstat:
src/lib-storage/mail-storage-service.c | 8 ++------
src/lib/ioloop.c | 2 ++
src/lib/ioloop.h | 10 ++++++++++
src/plugins/stats/stats-plugin.c | 6 ++----
4 files changed, 16 insertions(+), 10 deletions(-)
diffs (91 lines):
diff -r 33c434858f41 -r e588792b4f20 src/lib-storage/mail-storage-service.c
--- a/src/lib-storage/mail-storage-service.c Thu Sep 25 13:40:54 2014 +0300
+++ b/src/lib-storage/mail-storage-service.c Thu Sep 25 15:15:20 2014 +0300
@@ -695,17 +695,13 @@
return 0;
}
-static void mail_storage_service_io_activate(void *context)
+static void mail_storage_service_io_activate(struct mail_storage_service_user *user)
{
- struct mail_storage_service_user *user = context;
-
i_set_failure_prefix("%s", user->log_prefix);
}
-static void mail_storage_service_io_deactivate(void *context)
+static void mail_storage_service_io_deactivate(struct mail_storage_service_user *user)
{
- struct mail_storage_service_user *user = context;
-
i_set_failure_prefix("%s", user->service_ctx->default_log_prefix);
}
diff -r 33c434858f41 -r e588792b4f20 src/lib/ioloop.c
--- a/src/lib/ioloop.c Thu Sep 25 13:40:54 2014 +0300
+++ b/src/lib/ioloop.c Thu Sep 25 15:15:20 2014 +0300
@@ -674,6 +674,7 @@
i_free(ctx);
}
+#undef io_loop_context_add_callbacks
void io_loop_context_add_callbacks(struct ioloop_context *ctx,
io_callback_t *activate,
io_callback_t *deactivate, void *context)
@@ -688,6 +689,7 @@
array_append(&ctx->callbacks, &cb, 1);
}
+#undef io_loop_context_remove_callbacks
void io_loop_context_remove_callbacks(struct ioloop_context *ctx,
io_callback_t *activate,
io_callback_t *deactivate, void *context)
diff -r 33c434858f41 -r e588792b4f20 src/lib/ioloop.h
--- a/src/lib/ioloop.h Thu Sep 25 13:40:54 2014 +0300
+++ b/src/lib/ioloop.h Thu Sep 25 15:15:20 2014 +0300
@@ -142,10 +142,20 @@
void io_loop_context_add_callbacks(struct ioloop_context *ctx,
io_callback_t *activate,
io_callback_t *deactivate, void *context);
+#define io_loop_context_add_callbacks(ctx, activate, deactivate, context) \
+ io_loop_context_add_callbacks(ctx, 1 ? (io_callback_t *)activate : \
+ CALLBACK_TYPECHECK(activate, void (*)(typeof(context))) + \
+ CALLBACK_TYPECHECK(deactivate, void (*)(typeof(context))), \
+ (io_callback_t *)deactivate, context)
/* Remove callbacks with the given callbacks and context. */
void io_loop_context_remove_callbacks(struct ioloop_context *ctx,
io_callback_t *activate,
io_callback_t *deactivate, void *context);
+#define io_loop_context_remove_callbacks(ctx, activate, deactivate, context) \
+ io_loop_context_remove_callbacks(ctx, 1 ? (io_callback_t *)activate : \
+ CALLBACK_TYPECHECK(activate, void (*)(typeof(context))) + \
+ CALLBACK_TYPECHECK(deactivate, void (*)(typeof(context))), \
+ (io_callback_t *)deactivate, context)
/* Returns the current context set to ioloop. */
struct ioloop_context *io_loop_get_current_context(struct ioloop *ioloop);
diff -r 33c434858f41 -r e588792b4f20 src/plugins/stats/stats-plugin.c
--- a/src/plugins/stats/stats-plugin.c Thu Sep 25 13:40:54 2014 +0300
+++ b/src/plugins/stats/stats-plugin.c Thu Sep 25 15:15:20 2014 +0300
@@ -201,9 +201,8 @@
user_trans_stats_get(suser, &stats_r->trans_stats);
}
-static void stats_io_activate(void *context)
+static void stats_io_activate(struct mail_user *user)
{
- struct mail_user *user = context;
struct stats_user *suser = STATS_USER_CONTEXT(user);
if (stats_user_count == 1) {
@@ -519,9 +518,8 @@
session_stats_refresh(user);
}
-static void stats_io_deactivate(void *context)
+static void stats_io_deactivate(struct mail_user *user)
{
- struct mail_user *user = context;
struct stats_user *suser = STATS_USER_CONTEXT(user);
unsigned int last_update_secs;
More information about the dovecot-cvs
mailing list