From: Josef 'Jeff' Sipek Date: Mon, 28 Aug 2017 08:26:20 +0000 (+0300) Subject: lib-storage: convert pop3c to use container_of X-Git-Tag: 2.3.0.rc1~1094 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95d62f8d6d281cc488dc4f488d4388701e559012;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: convert pop3c to use container_of --- diff --git a/src/lib-storage/index/pop3c/pop3c-mail.c b/src/lib-storage/index/pop3c/pop3c-mail.c index a5d2b63136..5a63437b91 100644 --- a/src/lib-storage/index/pop3c/pop3c-mail.c +++ b/src/lib-storage/index/pop3c/pop3c-mail.c @@ -27,7 +27,7 @@ pop3c_mail_alloc(struct mailbox_transaction_context *t, static void pop3c_mail_close(struct mail *_mail) { struct pop3c_mail *pmail = (struct pop3c_mail *)_mail; - struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)_mail->box; + struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box); /* wait for any prefetch to finish before closing the mail */ while (pmail->prefetching) @@ -39,7 +39,7 @@ static void pop3c_mail_close(struct mail *_mail) static int pop3c_mail_get_received_date(struct mail *_mail, time_t *date_r) { - struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)_mail->box; + struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box); int tz; if (mbox->storage->set->pop3c_quick_received_date) { @@ -70,7 +70,7 @@ static int pop3c_mail_get_save_date(struct mail *_mail, time_t *date_r) static int pop3c_mail_get_physical_size(struct mail *_mail, uoff_t *size_r) { struct index_mail *mail = (struct index_mail *)_mail; - struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)_mail->box; + struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box); struct message_size hdr_size, body_size; struct istream *input; @@ -141,7 +141,7 @@ pop3c_mail_prefetch_done(enum pop3c_command_state state, static bool pop3c_mail_prefetch(struct mail *_mail) { struct pop3c_mail *pmail = (struct pop3c_mail *)_mail; - struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)_mail->box; + struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box); enum pop3c_capability capa; const char *cmd; @@ -172,7 +172,7 @@ pop3c_mail_get_stream(struct mail *_mail, bool get_body, { struct pop3c_mail *pmail = (struct pop3c_mail *)_mail; struct index_mail *mail = &pmail->imail; - struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)_mail->box; + struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box); enum pop3c_capability capa; const char *name, *cmd, *error; struct istream *input; @@ -245,7 +245,7 @@ static int pop3c_mail_get_special(struct mail *_mail, enum mail_fetch_field field, const char **value_r) { - struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)_mail->box; + struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box); switch (field) { case MAIL_FETCH_UIDL_BACKEND: diff --git a/src/lib-storage/index/pop3c/pop3c-storage.c b/src/lib-storage/index/pop3c/pop3c-storage.c index 87be081860..255b511e08 100644 --- a/src/lib-storage/index/pop3c/pop3c-storage.c +++ b/src/lib-storage/index/pop3c/pop3c-storage.c @@ -33,7 +33,7 @@ pop3c_storage_create(struct mail_storage *_storage, struct mail_namespace *ns, const char **error_r) { - struct pop3c_storage *storage = (struct pop3c_storage *)_storage; + struct pop3c_storage *storage = POP3C_STORAGE(_storage); storage->set = mail_namespace_get_driver_settings(ns, _storage); if (storage->set->pop3c_host[0] == '\0') { @@ -116,7 +116,7 @@ pop3c_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list, mbox->box.storage = storage; mbox->box.list = list; mbox->box.mail_vfuncs = &pop3c_mail_vfuncs; - mbox->storage = (struct pop3c_storage *)storage; + mbox->storage = POP3C_STORAGE(storage); index_storage_mailbox_alloc(&mbox->box, vname, flags, MAIL_INDEX_PREFIX); return &mbox->box; @@ -161,7 +161,7 @@ static void pop3c_login_callback(enum pop3c_command_state state, static int pop3c_mailbox_open(struct mailbox *box) { - struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box; + struct pop3c_mailbox *mbox = POP3C_MAILBOX(box); if (strcmp(box->name, "INBOX") != 0) { mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND, @@ -181,7 +181,7 @@ static int pop3c_mailbox_open(struct mailbox *box) static void pop3c_mailbox_close(struct mailbox *box) { - struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box; + struct pop3c_mailbox *mbox = POP3C_MAILBOX(box); if (mbox->uidl_pool != NULL) pool_unref(&mbox->uidl_pool); @@ -218,7 +218,7 @@ static int pop3c_mailbox_get_status(struct mailbox *box, enum mailbox_status_items items, struct mailbox_status *status_r) { - struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box; + struct pop3c_mailbox *mbox = POP3C_MAILBOX(box); if (index_storage_get_status(box, items, status_r) < 0) return -1; @@ -288,7 +288,7 @@ pop3c_save_cancel(struct mail_save_context *ctx) static bool pop3c_storage_is_inconsistent(struct mailbox *box) { - struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box; + struct pop3c_mailbox *mbox = POP3C_MAILBOX(box); return index_storage_is_inconsistent(box) || !pop3c_client_is_connected(mbox->client); diff --git a/src/lib-storage/index/pop3c/pop3c-storage.h b/src/lib-storage/index/pop3c/pop3c-storage.h index 0cb3657fc4..33d07d1ce8 100644 --- a/src/lib-storage/index/pop3c/pop3c-storage.h +++ b/src/lib-storage/index/pop3c/pop3c-storage.h @@ -37,6 +37,9 @@ struct pop3c_mail { bool prefetching_body:1; }; +#define POP3C_STORAGE(s) container_of(s, struct pop3c_storage, storage) +#define POP3C_MAILBOX(s) container_of(s, struct pop3c_mailbox, box) + struct mail * pop3c_mail_alloc(struct mailbox_transaction_context *t, enum mail_fetch_field wanted_fields, diff --git a/src/lib-storage/index/pop3c/pop3c-sync.c b/src/lib-storage/index/pop3c/pop3c-sync.c index 1bb9967357..edfe91fc6a 100644 --- a/src/lib-storage/index/pop3c/pop3c-sync.c +++ b/src/lib-storage/index/pop3c/pop3c-sync.c @@ -350,7 +350,7 @@ int pop3c_sync(struct pop3c_mailbox *mbox) struct mailbox_sync_context * pop3c_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) { - struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box; + struct pop3c_mailbox *mbox = POP3C_MAILBOX(box); int ret = 0; if ((flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0 &&