]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: array - Make array_bsearch() const
authorMarco Bettini <marco.bettini@open-xchange.com>
Thu, 25 Jul 2024 15:40:41 +0000 (15:40 +0000)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:13 +0000 (12:34 +0200)
src/imap/imap-client.c
src/imap/imap-commands.c
src/imap/imap-commands.h
src/imap/imap-state.c
src/lib-smtp/smtp-server-command.c
src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
src/lib/array.c
src/lib/array.h
src/plugins/pop3-migration/pop3-migration-plugin.c
src/plugins/virtual/virtual-sync.c

index 4cd4ddab2477e40c7d47f951f12aae45ab2889e6..2ef89d55b0fb924d1c7b8e605ab16c3e84faff13 100644 (file)
@@ -1254,7 +1254,7 @@ client_command_failed_early(struct client_command_context **_cmd,
 static bool client_command_input(struct client_command_context *cmd)
 {
        struct client *client = cmd->client;
-       struct command *command;
+       const struct command *command;
        const char *tag, *name;
        int ret;
 
index cdf41b2ec3527ced328362c0ad3b6c8fa4927d9b..2dd05e2477c0394f9db8a450b956857df2a5aa76 100644 (file)
@@ -218,7 +218,7 @@ static int command_bsearch(const char *name, const struct command *cmd)
        return strcasecmp(name, cmd->name);
 }
 
-struct command *command_find(const char *name)
+const struct command *command_find(const char *name)
 {
        if (commands_unsorted) {
                array_sort(&imap_commands, command_cmp);
index 6c1c94d4fd3c33d319732fecc611d6a4dcb79ce7..b305ed0fdb62a6326c946a471cfd685c4b782a8e 100644 (file)
@@ -62,7 +62,7 @@ void command_stats_start(struct client_command_context *cmd);
    needed during command_exec(). */
 void command_stats_flush(struct client_command_context *cmd);
 
-struct command *command_find(const char *name);
+const struct command *command_find(const char *name);
 
 void commands_init(void);
 void commands_deinit(void);
index 13b6190a658e70c5a17c8c448614bdb0bb6333bc..fa795b1b758a4da12a9921b5443735412de5f34e 100644 (file)
@@ -785,7 +785,7 @@ void imap_state_import_idle_cmd_tag(struct client *client, const char *tag)
        if (client->state_import_idle_continue) {
                /* IDLE command continues */
                struct client_command_context *cmd;
-               struct command *command;
+               const struct command *command;
 
                cmd = client_command_alloc(client);
                cmd->tag = p_strdup(cmd->pool, tag);
index 9f2e1e6485e3b0c61f40c703c51debbf0231b191..6020787a06bc4e89a5c39f0803cd40ea779ec1a9 100644 (file)
@@ -74,7 +74,7 @@ smtp_server_command_bsearch(const char *name,
        return strcasecmp(name, cmd->name);
 }
 
-static struct smtp_server_command_reg *
+static const struct smtp_server_command_reg *
 smtp_server_command_find(struct smtp_server *server, const char *name)
 {
        if (server->commands_unsorted) {
index 8e1cd3aa387e9452cd58736f147a79a3a2d3a98a..e7ef1d9df520feaf5e6b1e4fb6966c7e911f8993 100644 (file)
@@ -338,7 +338,7 @@ static void rebuild_apply_map(struct mdbox_storage_rebuild_context *ctx)
 {
        struct mdbox_map *map = ctx->storage->map;
        const struct mail_index_header *hdr;
-       struct mdbox_rebuild_msg **pos;
+       struct mdbox_rebuild_msg *const *pos;
        struct mdbox_rebuild_msg search_msg, *search_msgp = &search_msg;
        struct dbox_mail_lookup_rec rec;
        uint32_t seq;
@@ -389,7 +389,7 @@ rebuild_lookup_map_uid(struct mdbox_storage_rebuild_context *ctx,
                       uint32_t map_uid)
 {
        struct mdbox_rebuild_msg search_msg, *search_msgp = &search_msg;
-       struct mdbox_rebuild_msg **pos;
+       struct mdbox_rebuild_msg *const *pos;
 
        search_msg.map_uid = map_uid;
        pos = array_bsearch(&ctx->msgs, &search_msgp,
index 44b91a504a02e07d32364379095640a1b3029d6b..6950248e3128dc5a3838c56e54e42ad682369c2c 100644 (file)
@@ -139,8 +139,8 @@ void array_sort_i(struct array *array, int (*cmp)(const void *, const void *))
              count, array->element_size, cmp);
 }
 
-void *array_bsearch_i(struct array *array, const void *key,
-                    int (*cmp)(const void *, const void *))
+const void *array_bsearch_i(const struct array *array, const void *key,
+                           int (*cmp)(const void *, const void *))
 {
        unsigned int count;
 
index 9debb37645cbef69a867cceef9f8a778ce9e7b32..55bd88bbdbfef23a143764a9b407da8a5a9d19c9 100644 (file)
@@ -410,8 +410,8 @@ void array_sort_i(struct array *array, int (*cmp)(const void *, const void *));
                        &(array)->arr, (const void *)key, \
                        (int (*)(const void *, const void *))cmp))
 
-void *array_bsearch_i(struct array *array, const void *key,
-                     int (*cmp)(const void *, const void *));
+const void *array_bsearch_i(const struct array *array, const void *key,
+                           int (*cmp)(const void *, const void *));
 static inline void *array_bsearch_modifiable_i(struct array *array, const void *key,
                                               int (*cmp)(const void *, const void *))
 {
@@ -419,7 +419,7 @@ static inline void *array_bsearch_modifiable_i(struct array *array, const void *
 }
 
 #define array_bsearch(array, key, cmp) \
-       ARRAY_TYPE_CAST_MODIFIABLE(array) \
+       ARRAY_TYPE_CAST_CONST(array) \
        ARRAY_SEARCH_CALL(bsearch, array, key, cmp)
 #define array_bsearch_modifiable(array, key, cmp) \
        ARRAY_TYPE_CAST_MODIFIABLE(array) \
index eea1aeac24a1aee2ab6593a9f86f8be1c4506f76..ee0abc36e3651eaf09678678b014997d7386beb3 100644 (file)
@@ -916,7 +916,8 @@ pop3_migration_get_special(struct mail *_mail, enum mail_fetch_field field,
        struct mail_private *mail = (struct mail_private *)_mail;
        union mail_module_context *mmail = POP3_MIGRATION_MAIL_CONTEXT(mail);
        struct pop3_migration_mailbox *mbox = POP3_MIGRATION_CONTEXT_REQUIRE(_mail->box);
-       struct imap_msg_map map_key, *map;
+       const struct imap_msg_map *map;
+       struct imap_msg_map map_key;
 
        if (field == MAIL_FETCH_UIDL_BACKEND ||
            field == MAIL_FETCH_POP3_ORDER) {
index ed07a75b1aae40cecb1427ff970d4602cf04dbae..4d7ca984a4c9e8def9f18aba4e2fdb663b8b9703 100644 (file)
@@ -761,7 +761,7 @@ virtual_sync_mailbox_box_update_flags(struct virtual_sync_context *ctx,
                                      const ARRAY_TYPE(seq_range) *uids_arr)
 {
        unsigned int i, uid, vseq;
-       struct virtual_backend_uidmap *vuid;
+       const struct virtual_backend_uidmap *vuid;
        struct seq_range_iter iter;
 
        i = 0;