Skip to content

Commit

Permalink
snarf: Contexts are now required or checked
Browse files Browse the repository at this point in the history
Satisfies static analyzers
  • Loading branch information
cmouse authored and mrannanj committed Feb 20, 2018
1 parent 1e9fdc8 commit 5f6be61
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/plugins/snarf/snarf-plugin.c
Expand Up @@ -10,6 +10,8 @@

#define SNARF_CONTEXT(obj) \
MODULE_CONTEXT(obj, snarf_storage_module)
#define SNARF_CONTEXT_REQUIRE(obj) \
MODULE_CONTEXT_REQUIRE(obj, snarf_storage_module)

struct snarf_mail_storage {
union mail_storage_module_context module_ctx;
Expand Down Expand Up @@ -102,7 +104,7 @@ static int snarf(struct mailbox *srcbox, struct mailbox *destbox)
static struct mailbox_sync_context *
snarf_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
{
struct snarf_mailbox *sbox = SNARF_CONTEXT(box);
struct snarf_mailbox *sbox = SNARF_CONTEXT_REQUIRE(box);

(void)snarf(sbox->snarf_box, box);
/* close the mailbox so that we don't have to keep it locked */
Expand All @@ -112,7 +114,7 @@ snarf_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)

static void snarf_mailbox_free(struct mailbox *box)
{
struct snarf_mailbox *sbox = SNARF_CONTEXT(box);
struct snarf_mailbox *sbox = SNARF_CONTEXT_REQUIRE(box);

mailbox_free(&sbox->snarf_box);
sbox->module_ctx.super.free(box);
Expand Down Expand Up @@ -172,7 +174,7 @@ snarf_mailbox_alloc(struct mail_storage *storage,
struct mailbox_list *list,
const char *vname, enum mailbox_flags flags)
{
struct snarf_mail_storage *sstorage = SNARF_CONTEXT(storage);
struct snarf_mail_storage *sstorage = SNARF_CONTEXT_REQUIRE(storage);
struct mail_namespace *ns = mailbox_list_get_namespace(list);
struct mailbox *box;
struct mailbox_list *snarf_list;
Expand Down

0 comments on commit 5f6be61

Please sign in to comment.