]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: Add DSYNC_MAIL_CHANGE_TYPE_COUNT and verify its name array size
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sat, 3 Dec 2022 12:08:11 +0000 (14:08 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 12 Dec 2022 09:49:39 +0000 (11:49 +0200)
src/doveadm/dsync/dsync-ibc-stream.c
src/doveadm/dsync/dsync-mail.h
src/doveadm/dsync/dsync-mailbox-import.c

index 585e74117fbcc42cface2096c2adfb929bd1fe68..df624b618b73767ae485f0d1faf8dfeaf77c84d9 100644 (file)
@@ -1654,6 +1654,8 @@ dsync_ibc_stream_send_change(struct dsync_ibc *_ibc,
        case DSYNC_MAIL_CHANGE_TYPE_FLAG_CHANGE:
                type[0] = 'f';
                break;
+       case DSYNC_MAIL_CHANGE_TYPE_COUNT:
+               i_unreached();
        }
        i_assert(type[0] != '\0');
        dsync_serializer_encode_add(encoder, "type", type);
index fc0005915b48b98ea9f6d587681fefa2a76d491a..bcddda43336fcd9eb59ee132638aa7f7581a6b03 100644 (file)
@@ -40,7 +40,9 @@ struct dsync_mail_request {
 enum dsync_mail_change_type {
        DSYNC_MAIL_CHANGE_TYPE_SAVE,
        DSYNC_MAIL_CHANGE_TYPE_EXPUNGE,
-       DSYNC_MAIL_CHANGE_TYPE_FLAG_CHANGE
+       DSYNC_MAIL_CHANGE_TYPE_FLAG_CHANGE,
+
+       DSYNC_MAIL_CHANGE_TYPE_COUNT
 };
 
 #define KEYWORD_CHANGE_ADD '+'
index ed388d651f6d353e27e1af076c34a097a0248f35..9c69e9e3e4eccccc704a4e449491ef9dcf5fb7a3 100644 (file)
@@ -136,6 +136,8 @@ struct dsync_mailbox_importer {
 static const char *dsync_mail_change_type_names[] = {
        "save", "expunge", "flag-change"
 };
+static_assert_array_size(dsync_mail_change_type_names,
+                        DSYNC_MAIL_CHANGE_TYPE_COUNT);
 
 static bool dsync_mailbox_save_newmails(struct dsync_mailbox_importer *importer,
                                        const struct dsync_mail *mail,
@@ -1852,6 +1854,8 @@ int dsync_mailbox_import_change(struct dsync_mailbox_importer *importer,
                i_assert(importer->last_common_uid_found);
                dsync_mailbox_import_flag_change(importer, change);
                break;
+       case DSYNC_MAIL_CHANGE_TYPE_COUNT:
+               i_unreached();
        }
        return importer->failed ? -1 : 0;
 }