]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: Move most boolean fields in config_parser_context to flags enum
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 26 Mar 2025 10:04:38 +0000 (12:04 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 14 Oct 2025 11:28:44 +0000 (11:28 +0000)
Preserve expand_values since it's used all over the place.

src/config/config-parser-private.h
src/config/config-parser.c
src/config/old-set-parser.c

index 082c1c02e6c72f424567d3a0d7f14e067bf4f366..960947e2b30ce33fc0c1c540a6bb2a675b694e43 100644 (file)
@@ -81,6 +81,7 @@ HASH_TABLE_DEFINE_TYPE(include_group, const char *,
 struct config_parser_context {
        pool_t pool;
        const char *path;
+       enum config_parse_flags flags;
 
        ARRAY_TYPE(config_path) seen_paths;
        HASH_TABLE_TYPE(config_key) all_keys;
@@ -109,10 +110,6 @@ struct config_parser_context {
        struct config_filter_context *filter;
        bool dump_defaults:1;
        bool expand_values:1;
-       bool hide_errors:1;
-       bool delay_errors:1;
-       bool hide_obsolete_warnings:1;
-       bool ignore_unknown:1;
        /* All config_filter_parsers have reverse_default_sibling set. */
        bool reverse_parsers_set:1;
 };
index d69db348541df17cac57b58909aa3c1305eddeb9..15e27f3a456e022e6aeb4b92e2d061e1377c78b0 100644 (file)
@@ -349,7 +349,7 @@ config_apply_error(struct config_parser_context *ctx, const char *key)
 {
        struct config_parser_key *config_key;
 
-       if (!ctx->delay_errors)
+       if ((ctx->flags & CONFIG_PARSE_FLAG_DELAY_ERRORS) == 0)
                return -1;
 
        /* Couldn't get value for the setting, but we're delaying error
@@ -1321,7 +1321,7 @@ again:
        }
        ctx->cur_section->filter_parser = orig_filter_parser;
        if (ret == 0) {
-               if (ctx->ignore_unknown)
+               if ((ctx->flags & CONFIG_PARSE_FLAG_IGNORE_UNKNOWN) != 0)
                        return 0;
                config_set_unknown_key_error(ctx, key);
                return -1;
@@ -1826,7 +1826,7 @@ config_filter_parser_check(struct config_parser_context *ctx,
                if (!ok) {
                        /* be sure to assert-crash early if error is missing */
                        i_assert(error != NULL);
-                       if (!ctx->delay_errors) {
+                       if ((ctx->flags & CONFIG_PARSE_FLAG_DELAY_ERRORS) == 0) {
                                /* the errors are still slightly delayed so
                                   we get the full list of them. */
                                error = p_strdup(new_config->pool, error);
@@ -3216,7 +3216,7 @@ void config_parser_apply_line(struct config_parser_context *ctx,
                        break;
                }
                if (hash_table_lookup(ctx->all_keys, key) == NULL) {
-                       if (ctx->ignore_unknown)
+                       if ((ctx->flags & CONFIG_PARSE_FLAG_IGNORE_UNKNOWN) != 0)
                                break;
                        if (attempts != NULL)
                                str_append(attempts, " not found either.)");
@@ -3373,10 +3373,7 @@ int config_parse_file(const char *path, enum config_parse_flags flags,
        ctx.pool = pool_alloconly_create(MEMPOOL_GROWING"config file parser", 1024*256);
        ctx.path = path;
        ctx.dump_defaults = dump_defaults;
-       ctx.hide_obsolete_warnings =
-               (flags & CONFIG_PARSE_FLAG_HIDE_OBSOLETE_WARNINGS) != 0;
-       ctx.delay_errors = (flags & CONFIG_PARSE_FLAG_DELAY_ERRORS) != 0;
-       ctx.ignore_unknown = (flags & CONFIG_PARSE_FLAG_IGNORE_UNKNOWN) != 0;
+       ctx.flags = flags;
        hash_table_create(&ctx.all_keys, ctx.pool, 500, str_hash, strcmp);
        p_array_init(&ctx.seen_paths, ctx.pool, 8);
        if (fd != -1) {
index ee2cb513c99fd821e4908a8474df8f614daf4a5a..e957d6d9252699f029e976ebc430b5e6ba5a652e 100644 (file)
@@ -13,7 +13,7 @@ obsolete(struct config_parser_context *ctx, const char *str, ...)
        static bool seen_obsoletes = FALSE;
        va_list args;
 
-       if (ctx->hide_obsolete_warnings)
+       if ((ctx->flags & CONFIG_PARSE_FLAG_HIDE_OBSOLETE_WARNINGS) != 0)
                return;
 
        if (!seen_obsoletes) {