config: verify: fix a number of incorrect nodes passed to err_prefix()

This commit is contained in:
Daniel Eklöf 2019-01-11 23:20:51 +01:00
parent a1e0ce2f87
commit d03565a545

View file

@ -109,7 +109,7 @@ verify_dict(keychain_t *chain, const struct yml_node *node,
{ {
const char *key = yml_value_as_string(it.key); const char *key = yml_value_as_string(it.key);
if (key == NULL) { if (key == NULL) {
LOG_ERR("%s: key must be a string", err_prefix(chain, node)); LOG_ERR("%s: key must be a string", err_prefix(chain, it.key));
return false; return false;
} }
@ -123,7 +123,7 @@ verify_dict(keychain_t *chain, const struct yml_node *node,
} }
if (attr == NULL) { if (attr == NULL) {
LOG_ERR("%s: invalid key: %s", err_prefix(chain, node), key); LOG_ERR("%s: invalid key: %s", err_prefix(chain, it.key), key);
return false; return false;
} }
@ -139,8 +139,7 @@ verify_dict(keychain_t *chain, const struct yml_node *node,
if (!info[i].required || exists[i]) if (!info[i].required || exists[i])
continue; continue;
LOG_ERR("%s: missing required key: %s", LOG_ERR("%s: missing required key: %s", err_prefix(chain, node), info[i].name);
err_prefix(chain, node), info[i].name);
return false; return false;
} }
@ -217,12 +216,15 @@ verify_decoration(keychain_t *chain, const struct yml_node *node)
const char *deco_name = yml_value_as_string(deco); const char *deco_name = yml_value_as_string(deco);
if (deco_name == NULL) { if (deco_name == NULL) {
LOG_ERR("%s: decoration name must be a string", err_prefix(chain, node)); LOG_ERR("%s: decoration name must be a string", err_prefix(chain, deco));
return false; return false;
} }
if (strcmp(deco_name, "stack") == 0) if (strcmp(deco_name, "stack") == 0) {
return verify_decoration_stack(chain_push(chain, deco_name), values); bool ret = verify_decoration_stack(chain_push(chain, deco_name), values);
chain_pop(chain);
return ret;
}
static const struct attr_info background[] = { static const struct attr_info background[] = {
{"color", true, &verify_color}, {"color", true, &verify_color},
@ -246,8 +248,8 @@ verify_decoration(keychain_t *chain, const struct yml_node *node)
if (strcmp(decos[i].name, deco_name) != 0) if (strcmp(decos[i].name, deco_name) != 0)
continue; continue;
if (!verify_dict(chain_push(chain, deco_name), values, if (!verify_dict(chain_push(chain, deco_name),
decos[i].attrs, decos[i].count)) values, decos[i].attrs, decos[i].count))
{ {
return false; return false;
} }
@ -257,7 +259,7 @@ verify_decoration(keychain_t *chain, const struct yml_node *node)
} }
LOG_ERR( LOG_ERR(
"%s: invalid decoration name: %s", err_prefix(chain, node), deco_name); "%s: invalid decoration name: %s", err_prefix(chain, deco), deco_name);
return false; return false;
} }
@ -296,7 +298,7 @@ verify_map_values(keychain_t *chain, const struct yml_node *node)
const char *key = yml_value_as_string(it.key); const char *key = yml_value_as_string(it.key);
if (key == NULL) { if (key == NULL) {
LOG_ERR("%s: key must be a string (a i3 workspace name)", LOG_ERR("%s: key must be a string (a i3 workspace name)",
err_prefix(chain, node)); err_prefix(chain, it.key));
return false; return false;
} }
@ -326,7 +328,7 @@ verify_particle_dictionary(keychain_t *chain, const struct yml_node *node)
const char *particle_name = yml_value_as_string(particle); const char *particle_name = yml_value_as_string(particle);
if (particle_name == NULL) { if (particle_name == NULL) {
LOG_ERR("%s: particle name must be a string", err_prefix(chain, node)); LOG_ERR("%s: particle name must be a string", err_prefix(chain, particle));
return false; return false;
} }
@ -412,7 +414,7 @@ verify_particle_dictionary(keychain_t *chain, const struct yml_node *node)
} }
LOG_ERR( LOG_ERR(
"%s: invalid particle name: %s", err_prefix(chain, node), particle_name); "%s: invalid particle name: %s", err_prefix(chain, particle), particle_name);
return false; return false;
} }
@ -447,7 +449,7 @@ verify_i3_content(keychain_t *chain, const struct yml_node *node)
const char *key = yml_value_as_string(it.key); const char *key = yml_value_as_string(it.key);
if (key == NULL) { if (key == NULL) {
LOG_ERR("%s: key must be a string (a i3 workspace name)", LOG_ERR("%s: key must be a string (a i3 workspace name)",
err_prefix(chain, node)); err_prefix(chain, it.key));
return false; return false;
} }
@ -475,7 +477,7 @@ verify_module(keychain_t *chain, const struct yml_node *node)
const char *mod_name = yml_value_as_string(module); const char *mod_name = yml_value_as_string(module);
if (mod_name == NULL) { if (mod_name == NULL) {
LOG_ERR("%s: module name must be a string", err_prefix(chain, node)); LOG_ERR("%s: module name must be a string", err_prefix(chain, module));
return false; return false;
} }
@ -582,7 +584,7 @@ verify_module(keychain_t *chain, const struct yml_node *node)
return true; return true;
} }
LOG_ERR("%s: invalid module name: %s", err_prefix(chain, node), mod_name); LOG_ERR("%s: invalid module name: %s", err_prefix(chain, module), mod_name);
return false; return false;
} }