Skip to content

Commit

Permalink
lib-storage: convert index to use container_of
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef 'Jeff' Sipek authored and Timo Sirainen committed Sep 18, 2017
1 parent ac254f6 commit 8749001
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 83 deletions.
8 changes: 4 additions & 4 deletions src/lib-storage/index/cydir/cydir-mail.c
Expand Up @@ -43,7 +43,7 @@ static int cydir_mail_stat(struct mail *mail, struct stat *st_r)

static int cydir_mail_get_received_date(struct mail *_mail, time_t *date_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
struct index_mail_data *data = &mail->data;
struct stat st;

Expand All @@ -60,7 +60,7 @@ static int cydir_mail_get_received_date(struct mail *_mail, time_t *date_r)

static int cydir_mail_get_save_date(struct mail *_mail, time_t *date_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
struct index_mail_data *data = &mail->data;
struct stat st;

Expand All @@ -77,7 +77,7 @@ static int cydir_mail_get_save_date(struct mail *_mail, time_t *date_r)

static int cydir_mail_get_physical_size(struct mail *_mail, uoff_t *size_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
struct index_mail_data *data = &mail->data;
struct stat st;

Expand All @@ -98,7 +98,7 @@ cydir_mail_get_stream(struct mail *_mail, bool get_body ATTR_UNUSED,
struct message_size *body_size,
struct istream **stream_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
struct istream *input;
const char *path;
int fd;
Expand Down
16 changes: 8 additions & 8 deletions src/lib-storage/index/imapc/imapc-mail.c
Expand Up @@ -118,7 +118,7 @@ static uint64_t imapc_mail_get_modseq(struct mail *_mail)

static int imapc_mail_get_received_date(struct mail *_mail, time_t *date_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
struct index_mail_data *data = &mail->data;

if (index_mail_get_received_date(_mail, date_r) == 0)
Expand All @@ -141,7 +141,7 @@ static int imapc_mail_get_received_date(struct mail *_mail, time_t *date_r)

static int imapc_mail_get_save_date(struct mail *_mail, time_t *date_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
struct index_mail_data *data = &mail->data;

if (data->save_date == (time_t)-1) {
Expand All @@ -155,7 +155,7 @@ static int imapc_mail_get_save_date(struct mail *_mail, time_t *date_r)
static int imapc_mail_get_physical_size(struct mail *_mail, uoff_t *size_r)
{
struct imapc_mailbox *mbox = IMAPC_MAILBOX(_mail->box);
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
struct index_mail_data *data = &mail->data;
struct istream *input;
uoff_t old_offset;
Expand Down Expand Up @@ -205,7 +205,7 @@ static int imapc_mail_get_physical_size(struct mail *_mail, uoff_t *size_r)

static int imapc_mail_get_virtual_size(struct mail *_mail, uoff_t *size_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
struct index_mail_data *data = &mail->data;

if (imapc_mail_get_physical_size(_mail, size_r) < 0)
Expand Down Expand Up @@ -416,7 +416,7 @@ imapc_mail_add_temp_wanted_fields(struct mail *_mail,
enum mail_fetch_field fields,
struct mailbox_header_lookup_ctx *headers)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);

index_mail_add_temp_wanted_fields(_mail, fields, headers);
if (_mail->seq != 0)
Expand Down Expand Up @@ -492,7 +492,7 @@ static int imapc_mail_get_hdr_hash(struct index_mail *imail)

static bool imapc_mail_get_cached_guid(struct mail *_mail)
{
struct index_mail *imail = (struct index_mail *)_mail;
struct index_mail *imail = INDEX_MAIL(_mail);
const enum index_cache_field cache_idx =
imail->ibox->cache_fields[MAIL_CACHE_GUID].idx;
string_t *str;
Expand All @@ -518,7 +518,7 @@ static bool imapc_mail_get_cached_guid(struct mail *_mail)

static int imapc_mail_get_guid(struct mail *_mail, const char **value_r)
{
struct index_mail *imail = (struct index_mail *)_mail;
struct index_mail *imail = INDEX_MAIL(_mail);
struct imapc_mailbox *mbox = IMAPC_MAILBOX(_mail->box);
const enum index_cache_field cache_idx =
imail->ibox->cache_fields[MAIL_CACHE_GUID].idx;
Expand Down Expand Up @@ -553,7 +553,7 @@ imapc_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
const char **value_r)
{
struct imapc_mailbox *mbox = IMAPC_MAILBOX(_mail->box);
struct index_mail *imail = (struct index_mail *)_mail;
struct index_mail *imail = INDEX_MAIL(_mail);
uint64_t num;

switch (field) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib-storage/index/imapc/imapc-save.c
Expand Up @@ -136,7 +136,7 @@ static void
imapc_save_add_to_index(struct imapc_save_context *ctx, uint32_t uid)
{
struct mail *_mail = ctx->ctx.dest_mail;
struct index_mail *imail = (struct index_mail *)_mail;
struct index_mail *imail = INDEX_MAIL(_mail);
uint32_t seq;

/* we'll temporarily append messages and at commit time expunge
Expand Down
10 changes: 5 additions & 5 deletions src/lib-storage/index/index-mail-binary.c
Expand Up @@ -240,7 +240,7 @@ static void
binary_parts_update(struct binary_ctx *ctx, const struct message_part *part,
struct message_binary_part **msg_bin_parts)
{
struct index_mail *mail = (struct index_mail *)ctx->mail;
struct index_mail *mail = INDEX_MAIL(ctx->mail);
struct binary_block *blocks;
struct message_binary_part bin_part;
unsigned int i, count;
Expand Down Expand Up @@ -279,7 +279,7 @@ binary_parts_update(struct binary_ctx *ctx, const struct message_part *part,

static void binary_parts_cache(struct binary_ctx *ctx)
{
struct index_mail *mail = (struct index_mail *)ctx->mail;
struct index_mail *mail = INDEX_MAIL(ctx->mail);
buffer_t *buf;

buf = buffer_create_dynamic(pool_datastack_create(), 128);
Expand Down Expand Up @@ -364,7 +364,7 @@ index_mail_read_binary_to_cache(struct mail *_mail,
bool include_hdr, const char *reason,
bool *binary_r, bool *converted_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
struct mail_binary_cache *cache = &_mail->box->storage->binary_cache;
struct binary_ctx ctx;
struct istream *is;
Expand Down Expand Up @@ -482,7 +482,7 @@ index_mail_get_binary_size(struct mail *_mail,
const struct message_part *part, bool include_hdr,
uoff_t *size_r, unsigned int *lines_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
struct message_part *all_parts, *msg_part;
const struct message_binary_part *bin_part, *root_bin_part;
uoff_t size, end_offset;
Expand Down Expand Up @@ -549,7 +549,7 @@ int index_mail_get_binary_stream(struct mail *_mail,
unsigned int *lines_r, bool *binary_r,
struct istream **stream_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
struct mail_binary_cache *cache = &_mail->box->storage->binary_cache;
struct istream *input;
bool binary, converted;
Expand Down
8 changes: 4 additions & 4 deletions src/lib-storage/index/index-mail-headers.c
Expand Up @@ -373,7 +373,7 @@ index_mail_parse_header_cb(struct message_header_line *hdr,
struct istream *
index_mail_cache_parse_init(struct mail *_mail, struct istream *input)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
struct istream *input2;

i_assert(mail->data.tee_stream == NULL);
Expand Down Expand Up @@ -788,7 +788,7 @@ index_mail_headers_decode(struct index_mail *mail, const char *const **_list,
int index_mail_get_headers(struct mail *_mail, const char *field,
bool decode_to_utf8, const char *const **value_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
bool retry = TRUE;
int ret;

Expand Down Expand Up @@ -822,7 +822,7 @@ int index_mail_get_headers(struct mail *_mail, const char *field,
int index_mail_get_first_header(struct mail *_mail, const char *field,
bool decode_to_utf8, const char **value_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
const char *const *list;
bool retry = TRUE;
int ret;
Expand Down Expand Up @@ -868,7 +868,7 @@ int index_mail_get_header_stream(struct mail *_mail,
struct mailbox_header_lookup_ctx *headers,
struct istream **stream_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
struct index_mail *mail = INDEX_MAIL(_mail);
struct istream *input;
string_t *dest;

Expand Down

0 comments on commit 8749001

Please sign in to comment.