]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: Remove filter parameter from functions where callers only used empty filters
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 25 Apr 2023 14:07:09 +0000 (17:07 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 20 Nov 2023 12:21:56 +0000 (14:21 +0200)
Some of the function names no longer make sense, but these will be fixed by
later commits.

src/config/config-dump-full.c
src/config/config-filter.c
src/config/config-filter.h
src/config/config-request.c
src/config/config-request.h
src/config/doveconf.c

index edbe3aa9e9013f7b0f6635e8a3b927d9b72b6011..27c20aae382d98bd4cc974d924023279ea5bb920 100644 (file)
@@ -208,9 +208,7 @@ config_dump_full_sections(struct config_filter_context *config_filter,
        struct config_export_context *export_ctx;
        int ret = 0;
 
-       struct config_filter empty_filter;
-       i_zero(&empty_filter);
-       filters = config_filter_find_subset(config_filter, &empty_filter);
+       filters = config_filter_find_subset(config_filter);
 
        /* first filter should be the global one */
        i_assert(filters[0] != NULL && filters[0]->filter.service == NULL);
@@ -264,7 +262,6 @@ int config_dump_full(struct config_filter_context *config_filter,
                     const char **import_environment_r)
 {
        struct config_export_context *export_ctx;
-       struct config_filter empty_filter;
        const char *error;
        unsigned int section_idx = 0;
        int fd = -1;
@@ -283,8 +280,7 @@ int config_dump_full(struct config_filter_context *config_filter,
                                CONFIG_DUMP_SCOPE_CHANGED, flags,
                                config_dump_full_callback, &dump_ctx);
        }
-       i_zero(&empty_filter);
-       if (config_export_by_filter(export_ctx, config_filter, &empty_filter) < 0) {
+       if (config_export_by_filter(export_ctx, config_filter) < 0) {
                config_export_free(&export_ctx);
                str_free(&dump_ctx.delayed_output);
                return -1;
@@ -326,7 +322,6 @@ int config_dump_full(struct config_filter_context *config_filter,
        }
        struct ostream *output = dump_ctx.output;
 
-       i_zero(&empty_filter);
        o_stream_cork(output);
 
        *import_environment_r =
index 2660dec5405bd2f56504f6fbec1bd2d1c64bfb56..be80cfa81543c57b7b9c0995ab8d077974e46514 100644 (file)
@@ -177,22 +177,12 @@ config_filter_parser_cmp_rev(struct config_filter_parser *const *p1,
 }
 
 static struct config_filter_parser *const *
-config_filter_find_all(struct config_filter_context *ctx, pool_t pool,
-                      const struct config_filter *filter)
+config_filter_find_all(struct config_filter_context *ctx, pool_t pool)
 {
        ARRAY_TYPE(config_filter_parsers) matches;
-       unsigned int i;
 
        p_array_init(&matches, pool, 8);
-       for (i = 0; ctx->parsers[i] != NULL; i++) {
-               const struct config_filter *mask = &ctx->parsers[i]->filter;
-
-               if (!config_filter_match_service(mask, filter))
-                       continue;
-
-               if (config_filter_match_rest(mask, filter))
-                       array_push_back(&matches, &ctx->parsers[i]);
-       }
+       array_push_back(&matches, &ctx->parsers[0]);
 
        array_sort(&matches, config_filter_parser_cmp);
        array_append_zero(&matches);
@@ -200,33 +190,15 @@ config_filter_find_all(struct config_filter_context *ctx, pool_t pool,
 }
 
 struct config_filter_parser *const *
-config_filter_find_subset(struct config_filter_context *ctx,
-                         const struct config_filter *filter)
+config_filter_find_subset(struct config_filter_context *ctx)
 {
        ARRAY_TYPE(config_filter_parsers) matches;
-       struct config_filter tmp_mask;
        unsigned int i;
 
        t_array_init(&matches, 8);
-       for (i = 0; ctx->parsers[i] != NULL; i++) {
-               const struct config_filter *mask = &ctx->parsers[i]->filter;
-
-               if (filter->service != NULL) {
-                       if (!config_filter_match_service(mask, filter))
-                               continue;
-               }
-
-               tmp_mask = *mask;
-               if (filter->local_name == NULL)
-                       tmp_mask.local_name = NULL;
-               if (filter->local_bits == 0)
-                       tmp_mask.local_bits = 0;
-               if (filter->remote_bits == 0)
-                       tmp_mask.remote_bits = 0;
+       for (i = 0; ctx->parsers[i] != NULL; i++)
+               array_push_back(&matches, &ctx->parsers[i]);
 
-               if (config_filter_match_rest(&tmp_mask, filter))
-                       array_push_back(&matches, &ctx->parsers[i]);
-       }
        array_sort(&matches, config_filter_parser_cmp_rev);
        array_append_zero(&matches);
        return array_front(&matches);
@@ -275,7 +247,6 @@ config_module_parser_apply_changes(struct config_module_parser *dest,
 }
 
 int config_filter_parsers_get(struct config_filter_context *ctx, pool_t pool,
-                             const struct config_filter *filter,
                              struct config_module_parser **parsers_r,
                              const char **error_r)
 {
@@ -289,7 +260,7 @@ int config_filter_parsers_get(struct config_filter_context *ctx, pool_t pool,
           with an error. Merging SET_STRLIST types requires
           settings_parser_apply_changes() to work a bit unintuitively by
           letting the destination settings override the source settings. */
-       src = config_filter_find_all(ctx, pool, filter);
+       src = config_filter_find_all(ctx, pool);
 
        /* all of them should have the same number of parsers.
           duplicate our initial parsers from the first match */
index 551e9cbc60ca581de675b3bd1a7835c6f73e87fa..c955dec4065e47c2b92c70f00c0ad7474c609da0 100644 (file)
@@ -39,15 +39,13 @@ config_filter_get_errors(struct config_filter_context *ctx);
 
 /* Build new parsers from all existing ones matching the given filter. */
 int config_filter_parsers_get(struct config_filter_context *ctx, pool_t pool,
-                             const struct config_filter *filter,
                              struct config_module_parser **parsers_r,
                              const char **error_r) ATTR_NULL(3);
 void config_filter_parsers_free(struct config_module_parser *parsers);
 
 /* Return a list of filters that are a subset of the given filter. */
 struct config_filter_parser *const *
-config_filter_find_subset(struct config_filter_context *ctx,
-                         const struct config_filter *filter);
+config_filter_find_subset(struct config_filter_context *ctx);
 
 /* Returns TRUE if filter matches mask. */
 bool config_filter_match(const struct config_filter *mask,
index b52455e42a36247c51335e2e23df28e52a551e1e..99fea441f35d593b256fdd8b788e726cf156beab 100644 (file)
@@ -398,12 +398,11 @@ config_export_init(enum config_dump_scope scope,
 }
 
 int config_export_by_filter(struct config_export_context *ctx,
-                           struct config_filter_context *config_filter,
-                           const struct config_filter *filter)
+                           struct config_filter_context *config_filter)
 {
        const char *error;
 
-       if (config_filter_parsers_get(config_filter, ctx->pool, filter,
+       if (config_filter_parsers_get(config_filter, ctx->pool,
                                      &ctx->dup_parsers, &error) < 0) {
                i_error("%s", error);
                return -1;
index 90e8d4af23731adddcb1d5532b1fb4fb0c083e6f..6dd3d61eccf2a4a31aeafd04af8152863b5f785e 100644 (file)
@@ -39,8 +39,7 @@ config_export_init(enum config_dump_scope scope,
                   config_request_callback_t *callback, void *context)
        ATTR_NULL(1, 5);
 int config_export_by_filter(struct config_export_context *ctx,
-                           struct config_filter_context *config_filter,
-                           const struct config_filter *filter);
+                           struct config_filter_context *config_filter);
 void config_export_set_parsers(struct config_export_context *ctx,
                               const struct config_module_parser *parsers);
 unsigned int config_export_get_parser_count(struct config_export_context *ctx);
index 5684f7487733dcba6235a8811015e8652e7b7b6c..152e9bd4acfd17eeee788b08cbca1216e61cc017 100644 (file)
@@ -537,12 +537,11 @@ static void
 config_dump_human_sections(struct ostream *output,
                           bool hide_passwords)
 {
-       struct config_filter empty_filter = {};
        struct config_filter_parser *const *filters;
        struct config_dump_human_context *ctx;
        unsigned int indent;
 
-       filters = config_filter_find_subset(config_filter, &empty_filter);
+       filters = config_filter_find_subset(config_filter);
 
        /* first filter should be the global one */
        i_assert(filters[0] != NULL && filters[0]->filter.service == NULL);
@@ -565,7 +564,6 @@ config_dump_human(enum config_dump_scope scope, const char *setting_name_filter,
                  bool hide_passwords)
 {
        struct config_dump_human_context *ctx;
-       struct config_filter empty_filter = {};
        struct ostream *output;
        const char *str;
        int ret = 0;
@@ -575,7 +573,7 @@ config_dump_human(enum config_dump_scope scope, const char *setting_name_filter,
        o_stream_cork(output);
 
        ctx = config_dump_human_init(scope);
-       if ((ret = config_export_by_filter(ctx->export_ctx, config_filter, &empty_filter)) < 0)
+       if ((ret = config_export_by_filter(ctx->export_ctx, config_filter)) < 0)
                config_export_free(&ctx->export_ctx);
        else
                config_dump_human_output(ctx, output, 0, setting_name_filter, hide_passwords);
@@ -600,14 +598,13 @@ config_dump_one(bool hide_key,
                bool hide_passwords)
 {
        struct config_dump_human_context *ctx;
-       struct config_filter empty_filter = {};
        const char *str;
        size_t len;
        unsigned int section_idx = 0;
        bool dump_section = FALSE;
 
        ctx = config_dump_human_init(scope);
-       if (config_export_by_filter(ctx->export_ctx, config_filter, &empty_filter) < 0) {
+       if (config_export_by_filter(ctx->export_ctx, config_filter) < 0) {
                config_export_free(&ctx->export_ctx);
                return -1;
        }
@@ -970,14 +967,12 @@ int main(int argc, char *argv[])
                ret2 = -1;
        } else if (simple_output) {
                struct config_export_context *ctx;
-               struct config_filter empty_filter = {};
                unsigned int section_idx = 0;
 
                ctx = config_export_init(scope, 0,
                                         config_request_simple_stdout,
                                         setting_name_filters);
-               if ((ret2 = config_export_by_filter(ctx, config_filter,
-                                                   &empty_filter)) < 0)
+               if ((ret2 = config_export_by_filter(ctx, config_filter)) < 0)
                        config_export_free(&ctx);
                else {
                        if (config_export_all_parsers(&ctx, &section_idx) < 0)