]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-settings, global: Replace settings_parser_get_root_set() with settings_parser_get...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 8 Mar 2023 15:12:04 +0000 (17:12 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 20 Nov 2023 12:20:55 +0000 (14:20 +0200)
There is only one root now, so the root parameter isn't necessary.

src/config/config-request.c
src/config/doveconf.c
src/config/test-config-parser.c
src/lib-master/master-service-settings.c
src/lib-settings/settings-parser.c
src/lib-settings/settings-parser.h
src/lib-settings/test-settings-parser.c
src/stats/test-stats-common.c

index 9c6516a113de4228376f13cb14a993d51ff6b015..36028a100fa5657889d3827e7c4968ae1acfb5a7 100644 (file)
@@ -488,7 +488,7 @@ int config_export_finish(struct config_export_context **_ctx,
                parser = &ctx->parsers[i];
 
                T_BEGIN {
-                       void *set = settings_parser_get_root_set(parser->parser, parser->root);
+                       void *set = settings_parser_get_set(parser->parser);
                        settings_export(ctx, parser->root, FALSE, set,
                                        settings_parser_get_changes(parser->parser));
                } T_END;
index 3bd03ba3bb9310f5ad555f0293805d6ae03c36e1..ab3d6caf188bf1f24eabf6053152fb1a534a59fb 100644 (file)
@@ -679,7 +679,7 @@ static const char *get_setting(const char *module, const char *name)
                if (strcmp(l->root->module_name, module) != 0)
                        continue;
 
-               set = settings_parser_get_root_set(l->parser, l->root);
+               set = settings_parser_get_set(l->parser);
                for (def = l->root->defines; def->key != NULL; def++) {
                        if (strcmp(def->key, name) == 0) {
                                value = CONST_PTR_OFFSET(set, def->offset);
index 12f12331827ae7fd3ac30db281e0d4f9ef446f91..4cad7187b46515d99e628ae56cf01678e6c73c64 100644 (file)
@@ -120,8 +120,7 @@ static void test_config_parser(void)
 
        /* get the parsed output */
        const struct test_settings *set =
-               settings_parser_get_root_set(config_module_parsers[0].parser,
-                                            config_module_parsers[0].root);
+               settings_parser_get_set(config_module_parsers[0].parser);
        test_assert_strcmp(set->key, "value");
        test_assert_strcmp(set->key2, "\\$escape \\escape \\\"escape\\\"");
        test_assert_strcmp(set->key3, "yetanother value value nothervalue right here");
@@ -137,8 +136,7 @@ static void test_config_parser(void)
 
        /* try again unexpanded */
        test_assert(config_parse_file(TEST_CONFIG_FILE, 0, &error) == 1);
-       set = settings_parser_get_root_set(config_module_parsers[0].parser,
-                                          config_module_parsers[0].root);
+       set = settings_parser_get_set(config_module_parsers[0].parser);
 
        test_assert_strcmp(set->key, "value");
        test_assert_strcmp(set->key2, "\\$escape \\escape \\\"escape\\\"");
index 52caae004135195dd0a7c53e9a6a8c0581efa000..0106539e79e3d4cd8df633ccac3081a97f598170 100644 (file)
@@ -1042,7 +1042,7 @@ int master_service_settings_instance_get(struct event *event,
                return -1;
        }
 
-       void *set = settings_parser_get_root_set(parser, info);
+       void *set = settings_parser_get_set(parser);
 
        pool_t *pool_p = PTR_OFFSET(set, info->pool_offset1 - 1);
        *pool_p = set_pool;
index 885497b6ddafc27068b45810d022175ac5db99b4..a93a4e69a7123b582389e057c351d0a3e21a938a 100644 (file)
@@ -245,14 +245,11 @@ void settings_parser_unref(struct setting_parser_context **_ctx)
        pool_unref(&ctx->parser_pool);
 }
 
-void *settings_parser_get_root_set(const struct setting_parser_context *ctx,
-                                  const struct setting_parser_info *root)
+void *settings_parser_get_set(const struct setting_parser_context *ctx)
 {
-       for (unsigned int i = 0; i < ctx->root_count; i++) {
-               if (ctx->roots[i].info == root)
-                       return ctx->roots[i].set_struct;
-       }
-       i_panic("Couldn't find settings for root %s", root->module_name);
+       i_assert(ctx->root_count == 1);
+
+       return ctx->roots[0].set_struct;
 }
 
 void *settings_parser_get_changes(struct setting_parser_context *ctx)
index d9729e459fe927b62a787998f6bb2167aca9b45b..2453e3dae55c83b8212f7627497df1acd5328087 100644 (file)
@@ -130,11 +130,8 @@ settings_parser_init(pool_t set_pool, const struct setting_parser_info *root,
 void settings_parser_ref(struct setting_parser_context *ctx);
 void settings_parser_unref(struct setting_parser_context **ctx);
 
-/* Returns settings for a specific root. The root is expected to exist, and it
-   must be the same pointer as given to settings_parser_init*(). If it doesn't,
-   the function panics. */
-void *settings_parser_get_root_set(const struct setting_parser_context *ctx,
-                                  const struct setting_parser_info *root);
+/* Returns the current settings. */
+void *settings_parser_get_set(const struct setting_parser_context *ctx);
 /* Return pointer to changes in the root setting structure. */
 void *settings_parser_get_changes(struct setting_parser_context *ctx);
 
index f7c2e8395539e8d9ba2502a3329e083bfcc2253b..601b2996b269f0cd4d53c55a9a0f13c9aad48f8f 100644 (file)
@@ -95,8 +95,7 @@ static void test_settings_parser(void)
        test_assert(settings_parser_check(ctx, pool, NULL));
 
        /* check what we got */
-       struct test_settings *settings =
-               settings_parser_get_root_set(ctx, &root);
+       struct test_settings *settings = settings_parser_get_set(ctx);
        test_assert(settings != NULL);
 
        test_assert(settings->bool_true == TRUE);
index ac3350c1224d0bc3c7015d63d0c9ef0c517a87cd..bf6d39636e1ea0901c2349e217a2072fe1c191a2 100644 (file)
@@ -33,8 +33,7 @@ static struct stats_settings *read_settings(const char *const settings[])
        if (!settings_parser_check(ctx, test_pool, &error))
                i_fatal("Failed to parse settings: %s",
                        error);
-       struct stats_settings *set =
-               settings_parser_get_root_set(ctx, &stats_setting_parser_info);
+       struct stats_settings *set = settings_parser_get_set(ctx);
        settings_parser_unref(&ctx);
        return set;
 }