From: Timo Sirainen Date: Wed, 8 Mar 2023 15:12:04 +0000 (+0200) Subject: lib-settings, global: Replace settings_parser_get_root_set() with settings_parser_get... X-Git-Tag: 2.4.0~2226 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf60768f681878dfcbbd056f4ae5fc73a9af0620;p=thirdparty%2Fdovecot%2Fcore.git lib-settings, global: Replace settings_parser_get_root_set() with settings_parser_get_set() There is only one root now, so the root parameter isn't necessary. --- diff --git a/src/config/config-request.c b/src/config/config-request.c index 9c6516a113..36028a100f 100644 --- a/src/config/config-request.c +++ b/src/config/config-request.c @@ -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; diff --git a/src/config/doveconf.c b/src/config/doveconf.c index 3bd03ba3bb..ab3d6caf18 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -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); diff --git a/src/config/test-config-parser.c b/src/config/test-config-parser.c index 12f1233182..4cad7187b4 100644 --- a/src/config/test-config-parser.c +++ b/src/config/test-config-parser.c @@ -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\\\""); diff --git a/src/lib-master/master-service-settings.c b/src/lib-master/master-service-settings.c index 52caae0041..0106539e79 100644 --- a/src/lib-master/master-service-settings.c +++ b/src/lib-master/master-service-settings.c @@ -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; diff --git a/src/lib-settings/settings-parser.c b/src/lib-settings/settings-parser.c index 885497b6dd..a93a4e69a7 100644 --- a/src/lib-settings/settings-parser.c +++ b/src/lib-settings/settings-parser.c @@ -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) diff --git a/src/lib-settings/settings-parser.h b/src/lib-settings/settings-parser.h index d9729e459f..2453e3dae5 100644 --- a/src/lib-settings/settings-parser.h +++ b/src/lib-settings/settings-parser.h @@ -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); diff --git a/src/lib-settings/test-settings-parser.c b/src/lib-settings/test-settings-parser.c index f7c2e83955..601b2996b2 100644 --- a/src/lib-settings/test-settings-parser.c +++ b/src/lib-settings/test-settings-parser.c @@ -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); diff --git a/src/stats/test-stats-common.c b/src/stats/test-stats-common.c index ac3350c122..bf6d39636e 100644 --- a/src/stats/test-stats-common.c +++ b/src/stats/test-stats-common.c @@ -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; }