From: Josef 'Jeff' Sipek Date: Mon, 28 Aug 2017 08:51:34 +0000 (+0300) Subject: lib-storage: convert raw to use container_of X-Git-Tag: 2.3.0.rc1~1092 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8af1a286fb27446eeb0e7a8764cd3ed8d35ff2ac;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: convert raw to use container_of --- diff --git a/src/lib-storage/index/raw/raw-mail.c b/src/lib-storage/index/raw/raw-mail.c index 9f7c19054a..a98c0e2e57 100644 --- a/src/lib-storage/index/raw/raw-mail.c +++ b/src/lib-storage/index/raw/raw-mail.c @@ -11,7 +11,7 @@ static int raw_mail_stat(struct mail *mail) { - struct raw_mailbox *mbox = (struct raw_mailbox *)mail->box; + struct raw_mailbox *mbox = RAW_MAILBOX(mail->box); const struct stat *st; if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE) { @@ -39,7 +39,7 @@ static int raw_mail_stat(struct mail *mail) static int raw_mail_get_received_date(struct mail *_mail, time_t *date_r) { struct index_mail *mail = (struct index_mail *)_mail; - struct raw_mailbox *mbox = (struct raw_mailbox *)_mail->box; + struct raw_mailbox *mbox = RAW_MAILBOX(_mail->box); if (mbox->mtime == (time_t)-1) { if (raw_mail_stat(_mail) < 0) @@ -53,7 +53,7 @@ static int raw_mail_get_received_date(struct mail *_mail, time_t *date_r) static int raw_mail_get_save_date(struct mail *_mail, time_t *date_r) { struct index_mail *mail = (struct index_mail *)_mail; - struct raw_mailbox *mbox = (struct raw_mailbox *)_mail->box; + struct raw_mailbox *mbox = RAW_MAILBOX(_mail->box); if (mbox->ctime == (time_t)-1) { if (raw_mail_stat(_mail) < 0) @@ -67,7 +67,7 @@ static int raw_mail_get_save_date(struct mail *_mail, time_t *date_r) static int raw_mail_get_physical_size(struct mail *_mail, uoff_t *size_r) { struct index_mail *mail = (struct index_mail *)_mail; - struct raw_mailbox *mbox = (struct raw_mailbox *)_mail->box; + struct raw_mailbox *mbox = RAW_MAILBOX(_mail->box); if (mbox->size == (uoff_t)-1) { if (raw_mail_stat(_mail) < 0) @@ -99,7 +99,7 @@ static int raw_mail_get_special(struct mail *_mail, enum mail_fetch_field field, const char **value_r) { - struct raw_mailbox *mbox = (struct raw_mailbox *)_mail->box; + struct raw_mailbox *mbox = RAW_MAILBOX(_mail->box); switch (field) { case MAIL_FETCH_FROM_ENVELOPE: diff --git a/src/lib-storage/index/raw/raw-storage.c b/src/lib-storage/index/raw/raw-storage.c index ed4904ec62..8c46cc5020 100644 --- a/src/lib-storage/index/raw/raw-storage.c +++ b/src/lib-storage/index/raw/raw-storage.c @@ -140,14 +140,14 @@ raw_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list, index_storage_mailbox_alloc(&mbox->box, vname, flags, "dovecot.index"); mbox->mtime = mbox->ctime = (time_t)-1; - mbox->storage = (struct raw_storage *)storage; + mbox->storage = RAW_STORAGE(storage); mbox->size = (uoff_t)-1; return &mbox->box; } static int raw_mailbox_open(struct mailbox *box) { - struct raw_mailbox *mbox = (struct raw_mailbox *)box; + struct raw_mailbox *mbox = RAW_MAILBOX(box); const char *path; int fd; diff --git a/src/lib-storage/index/raw/raw-storage.h b/src/lib-storage/index/raw/raw-storage.h index b1384b8da1..124ca7ed0e 100644 --- a/src/lib-storage/index/raw/raw-storage.h +++ b/src/lib-storage/index/raw/raw-storage.h @@ -22,6 +22,9 @@ struct raw_mailbox { bool have_filename:1; }; +#define RAW_STORAGE(s) container_of(s, struct raw_storage, storage) +#define RAW_MAILBOX(s) container_of(s, struct raw_mailbox, box) + extern struct mail_vfuncs raw_mail_vfuncs; struct mail_user * diff --git a/src/lib-storage/index/raw/raw-sync.c b/src/lib-storage/index/raw/raw-sync.c index e7c68954b3..c552462296 100644 --- a/src/lib-storage/index/raw/raw-sync.c +++ b/src/lib-storage/index/raw/raw-sync.c @@ -57,7 +57,7 @@ static int raw_sync(struct raw_mailbox *mbox) struct mailbox_sync_context * raw_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) { - struct raw_mailbox *mbox = (struct raw_mailbox *)box; + struct raw_mailbox *mbox = RAW_MAILBOX(box); int ret = 0; if (!mbox->synced)