From a60a1a755598240f5a7705070179bfa707ad4c56 Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Fri, 12 Jul 2024 23:32:17 +0200 Subject: Minor fixes and refactor --- src/config.c | 60 +++++++++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index 1f2698b..9a2bc42 100644 --- a/src/config.c +++ b/src/config.c @@ -254,11 +254,9 @@ static config_status_t config_read_block(const config_block_t *info, block_t *bl const char *section, const char *key, const char *value) { config_status_t status = config_read_entry(block_entries, block, type, section, key, value); - - if (status == CONFIG_INVALID) - return status; - - return config_read_entry(info->entries, result, type, section, key, value); + return status != CONFIG_UNKNOWN + ? status + : config_read_entry(info->entries, result, type, section, key, value); } void config_init(config_t *config) @@ -373,33 +371,33 @@ void config_read(config_t *config, FILE *file) &type, section, key, value); else if (entries != NULL) status = config_read_entry(entries, result, &type, section, key, value); + else + goto skip_pair; - if (block != NULL || entries != NULL) { - switch (status) { - case CONFIG_SUCCESS: - break; - - case CONFIG_INVALID: - errors++; - log_value_error("Invalid entry", - "s:section", section, - "s:key", key, - "s:value", value, - "s:type", type, - "i:line", ini.line); - break; - - case CONFIG_UNKNOWN: - log_value_warn("Unknown entry", - "s:section", section, - "s:key", key, - "s:value", value, - "i:line", ini.line); - break; - - default: - unreachable(); - } + switch (status) { + case CONFIG_SUCCESS: + break; + + case CONFIG_INVALID: + errors++; + log_value_error("Invalid entry", + "s:section", section, + "s:key", key, + "s:value", value, + "s:type", type, + "i:line", ini.line); + break; + + case CONFIG_UNKNOWN: + log_value_warn("Unknown entry", + "s:section", section, + "s:key", key, + "s:value", value, + "i:line", ini.line); + break; + + default: + unreachable(); } skip_pair: -- cgit v1.2.3