]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-settings: Move seen_filter to struct settings_apply_ctx
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 22 Oct 2024 12:32:35 +0000 (15:32 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:39:59 +0000 (10:39 +0200)
Simplifies the following changes.

src/lib-settings/settings.c

index 1432bbde1b99b97587711b2acca639cb95ef1298..dd308c2aade38d27dea3f84e89c4b557fd543c55 100644 (file)
@@ -136,6 +136,7 @@ struct settings_apply_ctx {
        const char *filter_value;
        const char *filter_name;
        bool filter_name_required;
+       bool seen_filter;
 
        struct setting_parser_context *parser;
        struct settings_mmap_pool *mpool;
@@ -786,7 +787,6 @@ settings_mmap_apply(struct settings_apply_ctx *ctx, const char **error_r)
        /* So through the filters in reverse sorted order, so we always set the
           setting just once, never overriding anything. A filter for the base
           settings is expected to always exist. */
-       bool seen_filter = FALSE;
        for (uint32_t i = block->filter_count; i > 0; ) {
                i--;
                uint32_t event_filter_idx = be32_to_cpu_unaligned(
@@ -823,7 +823,7 @@ settings_mmap_apply(struct settings_apply_ctx *ctx, const char **error_r)
                        }
                        filter_offset += strlen(filter_error) + 1;
 
-                       if (ctx->filter_name != NULL && !seen_filter &&
+                       if (ctx->filter_name != NULL && !ctx->seen_filter &&
                            event_filter != EVENT_FILTER_MATCH_ALWAYS) {
                                bool op_not;
                                const char *value =
@@ -835,7 +835,7 @@ settings_mmap_apply(struct settings_apply_ctx *ctx, const char **error_r)
                                   removed wildcard escapes. */
                                if (value != NULL && !op_not &&
                                    strcmp(ctx->filter_name, value) == 0)
-                                       seen_filter = TRUE;
+                                       ctx->seen_filter = TRUE;
                        }
 
                        /* Apply overrides specific to this filter before the
@@ -852,7 +852,7 @@ settings_mmap_apply(struct settings_apply_ctx *ctx, const char **error_r)
                        if (ret < 0)
                                return -1;
                        if (ret > 0)
-                               seen_filter = TRUE;
+                               ctx->seen_filter = TRUE;
 
                        if (settings_mmap_apply_blob(ctx, block,
                                        filter_offset, filter_end_offset,
@@ -860,7 +860,7 @@ settings_mmap_apply(struct settings_apply_ctx *ctx, const char **error_r)
                                return -1;
                }
        }
-       return seen_filter ? 1 : 0;
+       return ctx->seen_filter ? 1 : 0;
 
 }