aboutsummaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-07-12 23:32:17 +0200
committerFederico Angelilli <code@fedang.net>2024-07-12 23:32:17 +0200
commita60a1a755598240f5a7705070179bfa707ad4c56 (patch)
treeb2f3a909ad03f18dff4508080989944a9047da81 /src/config.c
parentc6dc8e969c84b1980dcebd5dc3a59d112fa61c53 (diff)
Minor fixes and refactor
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c60
1 files changed, 29 insertions, 31 deletions
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: