hos: config: exit the loop after matching cfg key

This commit is contained in:
CTCaer
2025-01-24 16:02:31 +02:00
committed by Christoph Baumann
parent 1a157a33f6
commit c8da71229a

View File

@@ -59,7 +59,7 @@ static int _config_kip1(launch_ctxt_t *ctxt, const char *value)
{ {
u32 size; u32 size;
if (!memcmp(value + strlen(value) - 1, "*", 1)) if (value[strlen(value) - 1] == '*')
{ {
char *dir = (char *)malloc(256); char *dir = (char *)malloc(256);
strcpy(dir, value); strcpy(dir, value);
@@ -120,9 +120,6 @@ static int _config_kip1(launch_ctxt_t *ctxt, const char *value)
int config_kip1patch(launch_ctxt_t *ctxt, const char *value) int config_kip1patch(launch_ctxt_t *ctxt, const char *value)
{ {
if (value == NULL)
return 0;
int len = strlen(value); int len = strlen(value);
if (!len) if (!len)
return 0; return 0;
@@ -314,10 +311,15 @@ static const cfg_handler_t _config_handlers[] = {
int parse_boot_config(launch_ctxt_t *ctxt) int parse_boot_config(launch_ctxt_t *ctxt)
{ {
if (!ctxt->cfg)
return 1;
// Check each config key.
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ctxt->cfg->kvs, link) LIST_FOREACH_ENTRY(ini_kv_t, kv, &ctxt->cfg->kvs, link)
{ {
for (u32 i = 0; _config_handlers[i].key; i++) for (u32 i = 0; _config_handlers[i].key; i++)
{ {
// If key matches, call its handler.
if (!strcmp(_config_handlers[i].key, kv->key)) if (!strcmp(_config_handlers[i].key, kv->key))
{ {
if (!_config_handlers[i].handler(ctxt, kv->val)) if (!_config_handlers[i].handler(ctxt, kv->val))
@@ -327,6 +329,8 @@ int parse_boot_config(launch_ctxt_t *ctxt)
return 0; return 0;
} }
break;
} }
} }
} }