ucm: replace uc_error with snd_error calls

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2025-11-07 15:46:16 +01:00
parent 11235095bf
commit 9ab488b86c
9 changed files with 319 additions and 296 deletions

View file

@ -182,8 +182,9 @@ static int read_tlv_file(unsigned int **res,
}
sz = st.st_size;
if (sz > 16 * 1024 * 1024 || sz < 8 || sz % 4) {
uc_error("File size should be less than 16 MB "
snd_error(UCM, "File size should be less than 16 MB "
"and multiple of 4");
err = -EINVAL;
goto __fail;
}
@ -201,7 +202,7 @@ static int read_tlv_file(unsigned int **res,
/* Check if the tlv file specifies valid size. */
tlv = (struct snd_ctl_tlv *)(*res);
if (tlv->length + 2 * sizeof(unsigned int) != sz) {
uc_error("Invalid tlv size: %d", tlv->length);
snd_error(UCM, "Invalid tlv size: %d", tlv->length);
err = -EINVAL;
free(*res);
*res = NULL;
@ -229,7 +230,7 @@ static int binary_file_parse(snd_ctl_elem_value_t *dst,
type = snd_ctl_elem_info_get_type(info);
if (type != SND_CTL_ELEM_TYPE_BYTES) {
uc_error("only support byte type!");
snd_error(UCM, "only support byte type!");
err = -EINVAL;
goto __fail;
}
@ -245,7 +246,7 @@ static int binary_file_parse(snd_ctl_elem_value_t *dst,
sz = st.st_size;
count = snd_ctl_elem_info_get_count(info);
if (sz != count || sz > sizeof(dst->value.bytes)) {
uc_error("invalid parameter size %d!", sz);
snd_error(UCM, "invalid parameter size %d!", sz);
err = -EINVAL;
goto __fail;
}
@ -308,11 +309,11 @@ static const char *parse_uint(const char *p, const char *prefix, size_t len,
p += len;
v = strtol(p, &end, 0);
if (*end != '\0' && *end != ' ' && *end != ',') {
uc_error("unable to parse '%s'", prefix);
snd_error(UCM, "unable to parse '%s'", prefix);
return NULL;
}
if ((unsigned int)v < min || (unsigned int)v > max) {
uc_error("value '%s' out of range %u-%u %(%ld)", min, max, v);
snd_error(UCM, "value '%s' out of range %u-%u %(%ld)", min, max, v);
return NULL;
}
*rval = v;
@ -399,7 +400,7 @@ next:
*pos = p;
return 0;
er:
uc_error("unknown syntax '%s'", p);
snd_error(UCM, "unknown syntax '%s'", p);
return -EINVAL;
}
@ -428,7 +429,7 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type)
snd_ctl_elem_info_set_id(info2, id);
err = parse_cset_new_info(info2, pos, &pos);
if (err < 0 || !*pos) {
uc_error("undefined or wrong id config for cset-new", cset);
snd_error(UCM, "undefined or wrong id config for cset-new", cset);
err = -EINVAL;
goto __fail;
}
@ -437,12 +438,12 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type)
}
if (!*pos) {
if (type != SEQUENCE_ELEMENT_TYPE_CTL_REMOVE) {
uc_error("undefined value for cset >%s<", cset);
snd_error(UCM, "undefined value for cset >%s<", cset);
err = -EINVAL;
goto __fail;
}
} else if (type == SEQUENCE_ELEMENT_TYPE_CTL_REMOVE) {
uc_error("extra value for ctl-remove >%s<", cset);
snd_error(UCM, "extra value for ctl-remove >%s<", cset);
err = -EINVAL;
goto __fail;
}
@ -454,7 +455,7 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type)
if (err >= 0) {
err = snd_ctl_elem_remove(ctl, id);
if (err < 0) {
uc_error("unable to remove control");
snd_error(UCM, "unable to remove control");
err = -EINVAL;
goto __fail;
}
@ -463,7 +464,7 @@ static int execute_cset(snd_ctl_t *ctl, const char *cset, unsigned int type)
goto __ok;
err = __snd_ctl_add_elem_set(ctl, info2, info2->owner, info2->count);
if (err < 0) {
uc_error("unable to create new control");
snd_error(UCM, "unable to create new control");
goto __fail;
}
/* new id copy */
@ -574,7 +575,7 @@ static int execute_sysw(const char *sysw)
free(s);
if (ignore_error)
return 0;
uc_error("unable to open '%s' for write", path);
snd_error(UCM, "unable to open '%s' for write", path);
return -EINVAL;
}
wlen = write(fd, value, len);
@ -585,7 +586,7 @@ static int execute_sysw(const char *sysw)
goto __end;
if (wlen != (ssize_t)len) {
uc_error("unable to write '%s' to '%s': %s", value, path, strerror(myerrno));
snd_error(UCM, "unable to write '%s' to '%s': %s", value, path, strerror(myerrno));
free(s);
return -EINVAL;
}
@ -619,14 +620,14 @@ static int execute_cfgsave(snd_use_case_mgr_t *uc_mgr, const char *filename)
}
err = snd_config_search(config, root, &config);
if (err < 0) {
uc_error("Unable to find subtree '%s'", root);
snd_error(UCM, "Unable to find subtree '%s'", root);
goto _err;
}
}
err = snd_output_stdio_open(&out, file, "w+");
if (err < 0) {
uc_error("unable to open file '%s': %s", file, snd_strerror(err));
snd_error(UCM, "unable to open file '%s': %s", file, snd_strerror(err));
goto _err;
}
if (!config || snd_config_is_empty(config)) {
@ -641,7 +642,7 @@ static int execute_cfgsave(snd_use_case_mgr_t *uc_mgr, const char *filename)
}
snd_output_close(out);
if (err < 0) {
uc_error("unable to save configuration: %s", snd_strerror(err));
snd_error(UCM, "unable to save configuration: %s", snd_strerror(err));
goto _err;
}
_err:
@ -691,13 +692,13 @@ static int run_device_sequence(snd_use_case_mgr_t *uc_mgr, struct use_case_verb
snd_trace(UCM, "device sequence '%s/%s': %s", verb->name, name, uc_mgr_enable_str(enable));
if (verb == NULL) {
uc_error("error: enadev2 / disdev2 must be executed inside the verb context");
snd_error(UCM, "error: enadev2 / disdev2 must be executed inside the verb context");
return -ENOENT;
}
device = find_device(uc_mgr, verb, name, 0);
if (device == NULL) {
uc_error("error: unable to find device '%s'\n", name);
snd_error(UCM, "error: unable to find device '%s'\n", name);
return -ENOENT;
}
@ -717,7 +718,7 @@ static int run_device_all_sequence(snd_use_case_mgr_t *uc_mgr, struct use_case_v
snd_trace(UCM, "disable all devices sequence for '%s'", verb->name);
if (verb == NULL) {
uc_error("error: disdevall must be executed inside the verb context");
snd_error(UCM, "error: disdevall must be executed inside the verb context");
return -ENOENT;
}
@ -757,7 +758,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
int err = 0;
if (uc_mgr->sequence_hops > 100) {
uc_error("error: too many inner sequences!");
snd_error(UCM, "error: too many inner sequences!");
return -EINVAL;
}
uc_mgr->sequence_hops++;
@ -781,7 +782,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
* its parent's cdev stored by ucm manager.
*/
if (uc_mgr->cdev == NULL) {
uc_error("cdev is not defined!");
snd_error(UCM, "cdev is not defined!");
return err;
}
@ -797,7 +798,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
value_list2,
value_list3);
if (err < 0 && err != -ENOENT) {
uc_error("cdev is not defined!");
snd_error(UCM, "cdev is not defined!");
return err;
}
err = get_value3(uc_mgr, &capture_ctl, "CaptureCTL",
@ -806,12 +807,12 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
value_list3);
if (err < 0 && err != -ENOENT) {
free(playback_ctl);
uc_error("cdev is not defined!");
snd_error(UCM, "cdev is not defined!");
return err;
}
if (playback_ctl == NULL &&
capture_ctl == NULL) {
uc_error("cdev is not defined!");
snd_error(UCM, "cdev is not defined!");
return -EINVAL;
}
if (playback_ctl != NULL &&
@ -819,7 +820,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
strcmp(playback_ctl, capture_ctl) != 0) {
free(playback_ctl);
free(capture_ctl);
uc_error("cdev is not equal for playback and capture!");
snd_error(UCM, "cdev is not equal for playback and capture!");
return -EINVAL;
}
if (playback_ctl != NULL) {
@ -832,14 +833,14 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
if (ctl == NULL) {
err = uc_mgr_open_ctl(uc_mgr, &ctl_list, cdev, 1);
if (err < 0) {
uc_error("unable to open ctl device '%s'", cdev);
snd_error(UCM, "unable to open ctl device '%s'", cdev);
goto __fail;
}
ctl = ctl_list->ctl;
}
err = execute_cset(ctl, s->data.cset, s->type);
if (err < 0) {
uc_error("unable to execute cset '%s'", s->data.cset);
snd_error(UCM, "unable to execute cset '%s'", s->data.cset);
goto __fail;
}
break;
@ -858,7 +859,7 @@ static int execute_sequence(snd_use_case_mgr_t *uc_mgr,
ignore_error = s->data.exec[0] == '-';
err = uc_mgr_exec(s->data.exec + (ignore_error ? 1 : 0));
if (ignore_error == false && err != 0) {
uc_error("exec '%s' failed (exit code %d)", s->data.exec, err);
snd_error(UCM, "exec '%s' failed (exit code %d)", s->data.exec, err);
goto __fail;
}
break;
@ -873,7 +874,7 @@ shell_retry:
err = -EINTR;
} if (WIFEXITED(err)) {
if (ignore_error == false && WEXITSTATUS(err) != 0) {
uc_error("command '%s' failed (exit code %d)", s->data.exec, WEXITSTATUS(err));
snd_error(UCM, "command '%s' failed (exit code %d)", s->data.exec, WEXITSTATUS(err));
err = -EINVAL;
goto __fail;
}
@ -915,7 +916,7 @@ shell_retry:
goto __fail;
break;
default:
uc_error("unknown sequence command %i", s->type);
snd_error(UCM, "unknown sequence command %i", s->type);
break;
}
}
@ -1031,7 +1032,7 @@ static int set_defaults(snd_use_case_mgr_t *uc_mgr, bool force)
err = execute_sequence(uc_mgr, NULL, &uc_mgr->default_list,
&uc_mgr->value_list, NULL, NULL);
if (err < 0) {
uc_error("Unable to execute default sequence");
snd_error(UCM, "Unable to execute default sequence");
return err;
}
uc_mgr->default_list_executed = 1;
@ -1499,7 +1500,7 @@ const char *parse_open_variables(snd_use_case_mgr_t *uc_mgr, const char *name)
err = snd_config_load_string(&cfg, args, 0);
if (err < 0) {
uc_error("error: open arguments are not valid (%s)", args);
snd_error(UCM, "error: open arguments are not valid (%s)", args);
goto skip;
}
@ -1572,14 +1573,15 @@ int snd_use_case_mgr_open(snd_use_case_mgr_t **uc_mgr,
if (err < 0) {
if (err == -ENXIO && mgr->suppress_nodev_errors)
goto _err;
uc_error("error: failed to import %s use case configuration %d",
snd_error(UCM, "error: failed to import %s use case configuration %d",
card_name, err);
goto _err;
}
err = check_empty_configuration(mgr);
if (err < 0) {
uc_error("error: failed to import %s (empty configuration)", card_name);
snd_error(UCM, "error: failed to import %s (empty configuration)", card_name);
goto _err;
}
@ -1611,7 +1613,7 @@ int snd_use_case_mgr_reload(snd_use_case_mgr_t *uc_mgr)
/* reload all use cases */
err = import_master_config(uc_mgr);
if (err < 0) {
uc_error("error: failed to reload use cases");
snd_error(UCM, "error: failed to reload use cases");
pthread_mutex_unlock(&uc_mgr->mutex);
return -EINVAL;
}
@ -1643,7 +1645,7 @@ static int dismantle_use_case(snd_use_case_mgr_t *uc_mgr)
active_list);
err = set_modifier(uc_mgr, modifier, 0);
if (err < 0)
uc_error("Unable to disable modifier %s", modifier->name);
snd_error(UCM, "Unable to disable modifier %s", modifier->name);
}
INIT_LIST_HEAD(&uc_mgr->active_modifiers);
@ -1652,13 +1654,13 @@ static int dismantle_use_case(snd_use_case_mgr_t *uc_mgr)
active_list);
err = set_device(uc_mgr, device, 0);
if (err < 0)
uc_error("Unable to disable device %s", device->name);
snd_error(UCM, "Unable to disable device %s", device->name);
}
INIT_LIST_HEAD(&uc_mgr->active_devices);
err = set_verb(uc_mgr, uc_mgr->active_verb, 0);
if (err < 0) {
uc_error("Unable to disable verb %s", uc_mgr->active_verb->name);
snd_error(UCM, "Unable to disable verb %s", uc_mgr->active_verb->name);
return err;
}
uc_mgr->active_verb = NULL;
@ -2478,7 +2480,7 @@ static int set_fixedboot_user(snd_use_case_mgr_t *uc_mgr,
int err;
if (value != NULL && *value) {
uc_error("error: wrong value for _fboot (%s)", value);
snd_error(UCM, "error: wrong value for _fboot (%s)", value);
return -EINVAL;
}
if (list_empty(&uc_mgr->fixedboot_list))
@ -2486,7 +2488,7 @@ static int set_fixedboot_user(snd_use_case_mgr_t *uc_mgr,
err = execute_sequence(uc_mgr, NULL, &uc_mgr->fixedboot_list,
&uc_mgr->value_list, NULL, NULL);
if (err < 0) {
uc_error("Unable to execute force boot sequence");
snd_error(UCM, "Unable to execute force boot sequence");
return err;
}
return err;
@ -2498,7 +2500,7 @@ static int set_boot_user(snd_use_case_mgr_t *uc_mgr,
int err;
if (value != NULL && *value) {
uc_error("error: wrong value for _boot (%s)", value);
snd_error(UCM, "error: wrong value for _boot (%s)", value);
return -EINVAL;
}
if (list_empty(&uc_mgr->boot_list))
@ -2506,7 +2508,7 @@ static int set_boot_user(snd_use_case_mgr_t *uc_mgr,
err = execute_sequence(uc_mgr, NULL, &uc_mgr->boot_list,
&uc_mgr->value_list, NULL, NULL);
if (err < 0) {
uc_error("Unable to execute boot sequence");
snd_error(UCM, "Unable to execute boot sequence");
return err;
}
return err;
@ -2516,7 +2518,7 @@ static int set_defaults_user(snd_use_case_mgr_t *uc_mgr,
const char *value)
{
if (value != NULL && *value) {
uc_error("error: wrong value for _defaults (%s)", value);
snd_error(UCM, "error: wrong value for _defaults (%s)", value);
return -EINVAL;
}
return set_defaults(uc_mgr, false);
@ -2579,8 +2581,9 @@ static int set_verb_user(snd_use_case_mgr_t *uc_mgr,
if (verb) {
err = set_verb(uc_mgr, verb, 1);
if (err < 0)
uc_error("error: failed to initialize new use case: %s",
snd_error(UCM, "error: failed to initialize new use case: %s",
verb_name);
}
return err;
}
@ -2631,11 +2634,11 @@ static int switch_device(snd_use_case_mgr_t *uc_mgr,
if (uc_mgr->active_verb == NULL)
return -ENOENT;
if (device_status(uc_mgr, old_device) == 0) {
uc_error("error: device %s not enabled", old_device);
snd_error(UCM, "error: device %s not enabled", old_device);
return -EINVAL;
}
if (device_status(uc_mgr, new_device) != 0) {
uc_error("error: device %s already enabled", new_device);
snd_error(UCM, "error: device %s already enabled", new_device);
return -EINVAL;
}
xold = find_device(uc_mgr, uc_mgr->active_verb, old_device, 1);
@ -2687,11 +2690,11 @@ static int switch_modifier(snd_use_case_mgr_t *uc_mgr,
if (uc_mgr->active_verb == NULL)
return -ENOENT;
if (modifier_status(uc_mgr, old_modifier) == 0) {
uc_error("error: modifier %s not enabled", old_modifier);
snd_error(UCM, "error: modifier %s not enabled", old_modifier);
return -EINVAL;
}
if (modifier_status(uc_mgr, new_modifier) != 0) {
uc_error("error: modifier %s already enabled", new_modifier);
snd_error(UCM, "error: modifier %s already enabled", new_modifier);
return -EINVAL;
}
xold = find_modifier(uc_mgr, uc_mgr->active_verb, old_modifier, 1);

View file

@ -75,7 +75,7 @@ int uc_mgr_config_load_file(snd_use_case_mgr_t *uc_mgr,
file);
err = uc_mgr_config_load(uc_mgr->conf_format, filename, cfg);
if (err < 0) {
uc_error("error: failed to open file %s: %d", filename, err);
snd_error(UCM, "error: failed to open file %s: %d", filename, err);
return err;
}
return 0;
@ -187,7 +187,7 @@ static int parse_integer_substitute3(snd_use_case_mgr_t *uc_mgr,
static int parse_is_name_safe(const char *name)
{
if (strchr(name, '.')) {
uc_error("char '.' not allowed in '%s'", name);
snd_error(UCM, "char '.' not allowed in '%s'", name);
return 0;
}
return 1;
@ -237,11 +237,11 @@ static int error_node(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
err = parse_string_substitute3(uc_mgr, cfg, &s);
if (err < 0) {
uc_error("error: failed to get Error string");
snd_error(UCM, "error: failed to get Error string");
return err;
}
if (!uc_mgr->suppress_nodev_errors)
uc_error("%s", s);
snd_error(UCM, "%s", s);
free(s);
return -ENXIO;
}
@ -258,16 +258,16 @@ static int parse_syntax_field(snd_use_case_mgr_t *uc_mgr,
err = snd_config_search(cfg, "Syntax", &n);
if (err < 0) {
uc_error("Syntax field not found in %s", filename);
snd_error(UCM, "Syntax field not found in %s", filename);
return -EINVAL;
}
err = snd_config_get_integer(n, &l);
if (err < 0) {
uc_error("Syntax field is invalid in %s", filename);
snd_error(UCM, "Syntax field is invalid in %s", filename);
return err;
}
if (l < 2 || l > SYNTAX_VERSION_MAX) {
uc_error("Incompatible syntax %ld in %s", l, filename);
snd_error(UCM, "Incompatible syntax %ld in %s", l, filename);
return -EINVAL;
}
/* delete this field to optimize strcmp() call in the parsing loop */
@ -294,12 +294,12 @@ static int evaluate_regex(snd_use_case_mgr_t *uc_mgr,
return err;
if (snd_config_get_type(d) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for DefineRegex");
snd_error(UCM, "compound type expected for DefineRegex");
return -EINVAL;
}
if (uc_mgr->conf_format < 3) {
uc_error("DefineRegex is supported in v3+ syntax");
snd_error(UCM, "DefineRegex is supported in v3+ syntax");
return -EINVAL;
}
@ -309,7 +309,7 @@ static int evaluate_regex(snd_use_case_mgr_t *uc_mgr,
if (err < 0)
return err;
if (id[0] == '@') {
uc_error("error: value names starting with '@' are reserved for application variables");
snd_error(UCM, "error: value names starting with '@' are reserved for application variables");
return -EINVAL;
}
err = uc_mgr_define_regex(uc_mgr, id, n);
@ -340,12 +340,12 @@ static int evaluate_define(snd_use_case_mgr_t *uc_mgr,
return err;
if (snd_config_get_type(d) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for Define");
snd_error(UCM, "compound type expected for Define");
return -EINVAL;
}
if (uc_mgr->conf_format < 3) {
uc_error("Define is supported in v3+ syntax");
snd_error(UCM, "Define is supported in v3+ syntax");
return -EINVAL;
}
@ -363,7 +363,7 @@ static int evaluate_define(snd_use_case_mgr_t *uc_mgr,
return err;
if (id[0] == '@') {
free(s);
uc_error("error: value names starting with '@' are reserved for application variables");
snd_error(UCM, "error: value names starting with '@' are reserved for application variables");
return -EINVAL;
}
err = uc_mgr_set_variable(uc_mgr, id, s);
@ -393,12 +393,12 @@ static int evaluate_define_macro(snd_use_case_mgr_t *uc_mgr,
return err;
if (snd_config_get_type(d) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for DefineMacro");
snd_error(UCM, "compound type expected for DefineMacro");
return -EINVAL;
}
if (uc_mgr->conf_format < 6) {
uc_error("DefineMacro is supported in v6+ syntax");
snd_error(UCM, "DefineMacro is supported in v6+ syntax");
return -EINVAL;
}
@ -424,7 +424,7 @@ static int evaluate_macro1(snd_use_case_mgr_t *uc_mgr,
return err;
err = snd_config_search(uc_mgr->macros, mid, &m);
if (err < 0) {
uc_error("Macro '%s' is not defined", mid);
snd_error(UCM, "Macro '%s' is not defined", mid);
return err;
}
@ -448,7 +448,7 @@ static int evaluate_macro1(snd_use_case_mgr_t *uc_mgr,
goto __err_path;
snprintf(name, sizeof(name), "__%s", id);
if (uc_mgr_get_variable(uc_mgr, name)) {
uc_error("Macro argument '%s' is already defined", name);
snd_error(UCM, "Macro argument '%s' is already defined", name);
goto __err_path;
}
err = snd_config_get_ascii(n, &var);
@ -520,12 +520,12 @@ static int evaluate_macro(snd_use_case_mgr_t *uc_mgr,
return err;
if (snd_config_get_type(d) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for DefineMacro");
snd_error(UCM, "compound type expected for DefineMacro");
return -EINVAL;
}
if (uc_mgr->conf_format < 6) {
uc_error("Macro is supported in v6+ syntax");
snd_error(UCM, "Macro is supported in v6+ syntax");
return -EINVAL;
}
@ -535,7 +535,7 @@ static int evaluate_macro(snd_use_case_mgr_t *uc_mgr,
const char *id;
if (snd_config_get_id(n, &id))
id = "";
uc_error("compound type expected for Macro.%s", id);
snd_error(UCM, "compound type expected for Macro.%s", id);
return -EINVAL;
}
snd_config_for_each(i2, next2, n) {
@ -607,7 +607,7 @@ static int evaluate_variant(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
return err;
if (uc_mgr->conf_format < 6) {
uc_error("Variant is supported in v6+ syntax");
snd_error(UCM, "Variant is supported in v6+ syntax");
return -EINVAL;
}
@ -653,7 +653,7 @@ int uc_mgr_evaluate_inplace(snd_use_case_mgr_t *uc_mgr,
while (err1 == 0 || err2 == 0 || err3 == 0 || err4 == 0 || err5 == 0) {
if (iterations == 0) {
uc_error("Maximal inplace evaluation iterations number reached (recursive references?)");
snd_error(UCM, "Maximal inplace evaluation iterations number reached (recursive references?)");
return -EINVAL;
}
iterations--;
@ -676,7 +676,7 @@ int uc_mgr_evaluate_inplace(snd_use_case_mgr_t *uc_mgr,
continue;
uc_mgr->macro_hops++;
if (uc_mgr->macro_hops > 100) {
uc_error("Maximal macro hops reached!");
snd_error(UCM, "Maximal macro hops reached!");
return -EINVAL;
}
err4 = evaluate_macro(uc_mgr, cfg);
@ -707,7 +707,7 @@ static int parse_libconfig1(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
return -EINVAL;
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for %s", id);
snd_error(UCM, "compound type expected for %s", id);
return -EINVAL;
}
@ -735,7 +735,7 @@ static int parse_libconfig1(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
continue;
}
uc_error("unknown field %s", id);
snd_error(UCM, "unknown field %s", id);
return -EINVAL;
}
@ -795,7 +795,7 @@ static int parse_libconfig(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
return -EINVAL;
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for %s", id);
snd_error(UCM, "compound type expected for %s", id);
return -EINVAL;
}
@ -827,7 +827,7 @@ static int parse_transition(snd_use_case_mgr_t *uc_mgr,
return -EINVAL;
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for %s", id);
snd_error(UCM, "compound type expected for %s", id);
return -EINVAL;
}
@ -875,7 +875,7 @@ static int parse_compound(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg,
return -EINVAL;
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for %s", id);
snd_error(UCM, "compound type expected for %s", id);
return -EINVAL;
}
/* parse compound */
@ -883,7 +883,7 @@ static int parse_compound(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg,
n = snd_config_iterator_entry(i);
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for %s, is %d", id, snd_config_get_type(cfg));
snd_error(UCM, "compound type expected for %s, is %d", id, snd_config_get_type(cfg));
return -EINVAL;
}
@ -901,8 +901,9 @@ static int strip_legacy_dev_index(char *name)
if (!dot)
return 0;
if (dot[1] != '0' || dot[2] != '\0') {
uc_error("device name %s contains a '.',"
snd_error(UCM, "device name %s contains a '.',"
" and is not legacy foo.0 format", name);
return -EINVAL;
}
*dot = '\0';
@ -924,8 +925,9 @@ static int parse_device_list(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED,
int err;
if (dev_list->type != DEVLIST_NONE) {
uc_error("error: multiple supported or"
snd_error(UCM, "error: multiple supported or"
" conflicting device lists");
return -EEXIST;
}
@ -933,7 +935,7 @@ static int parse_device_list(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED,
return -EINVAL;
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for %s", id);
snd_error(UCM, "compound type expected for %s", id);
return -EINVAL;
}
@ -1031,7 +1033,7 @@ static int parse_component_seq(snd_use_case_mgr_t *uc_mgr,
cmpt_seq->device = find_component_dev(uc_mgr, val);
if (!cmpt_seq->device) {
uc_error("error: Cannot find component device %s", val);
snd_error(UCM, "error: Cannot find component device %s", val);
free(val);
return -EINVAL;
}
@ -1072,7 +1074,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr,
const char *cmd = NULL;
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("error: compound is expected for sequence definition");
snd_error(UCM, "error: compound is expected for sequence definition");
return -EINVAL;
}
@ -1085,7 +1087,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr,
continue;
if (idx == 1) {
if (snd_config_get_type(n) != SND_CONFIG_TYPE_STRING) {
uc_error("error: string type is expected for sequence command");
snd_error(UCM, "error: string type is expected for sequence command");
return -EINVAL;
}
snd_config_get_string(n, &cmd);
@ -1102,7 +1104,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr,
curr->type = SEQUENCE_ELEMENT_TYPE_CDEV;
err = parse_string_substitute3(uc_mgr, n, &curr->data.cdev);
if (err < 0) {
uc_error("error: cdev requires a string!");
snd_error(UCM, "error: cdev requires a string!");
return err;
}
continue;
@ -1113,7 +1115,7 @@ static int parse_sequence(snd_use_case_mgr_t *uc_mgr,
cset:
err = parse_string_substitute3(uc_mgr, n, &curr->data.cset);
if (err < 0) {
uc_error("error: %s requires a string!", cmd);
snd_error(UCM, "error: %s requires a string!", cmd);
return err;
}
continue;
@ -1127,7 +1129,7 @@ cset:
strcmp(cmd, "enadev") == 0,
&curr->data.cmpt_seq);
if (err < 0) {
uc_error("error: %s requires a valid device!", cmd);
snd_error(UCM, "error: %s requires a valid device!", cmd);
return err;
}
continue;
@ -1143,7 +1145,7 @@ cset:
device:
err = parse_string_substitute3(uc_mgr, n, &curr->data.device);
if (err < 0) {
uc_error("error: %s requires a valid device!", cmd);
snd_error(UCM, "error: %s requires a valid device!", cmd);
return err;
}
continue;
@ -1178,7 +1180,7 @@ device:
curr->type = SEQUENCE_ELEMENT_TYPE_SYSSET;
err = parse_string_substitute3(uc_mgr, n, &curr->data.sysw);
if (err < 0) {
uc_error("error: sysw requires a string!");
snd_error(UCM, "error: sysw requires a string!");
return err;
}
continue;
@ -1188,7 +1190,7 @@ device:
curr->type = SEQUENCE_ELEMENT_TYPE_SLEEP;
err = parse_integer_substitute3(uc_mgr, n, &curr->data.sleep);
if (err < 0) {
uc_error("error: usleep requires integer!");
snd_error(UCM, "error: usleep requires integer!");
return err;
}
continue;
@ -1198,7 +1200,7 @@ device:
curr->type = SEQUENCE_ELEMENT_TYPE_SLEEP;
err = parse_integer_substitute3(uc_mgr, n, &curr->data.sleep);
if (err < 0) {
uc_error("error: msleep requires integer!");
snd_error(UCM, "error: msleep requires integer!");
return err;
}
curr->data.sleep *= 1000L;
@ -1210,7 +1212,7 @@ device:
exec:
err = parse_string_substitute3(uc_mgr, n, &curr->data.exec);
if (err < 0) {
uc_error("error: exec requires a string!");
snd_error(UCM, "error: exec requires a string!");
return err;
}
continue;
@ -1225,7 +1227,7 @@ exec:
curr->type = SEQUENCE_ELEMENT_TYPE_CFGSAVE;
err = parse_string_substitute3(uc_mgr, n, &curr->data.cfgsave);
if (err < 0) {
uc_error("error: sysw requires a string!");
snd_error(UCM, "error: sysw requires a string!");
return err;
}
continue;
@ -1234,7 +1236,7 @@ exec:
if (strcmp(cmd, "comment") == 0)
goto skip;
uc_error("error: sequence command '%s' is ignored", cmd);
snd_error(UCM, "error: sequence command '%s' is ignored", cmd);
skip:
list_del(&curr->list);
@ -1287,7 +1289,7 @@ static int parse_value(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED,
int err;
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("error: compound is expected for value definition");
snd_error(UCM, "error: compound is expected for value definition");
return -EINVAL;
}
@ -1310,19 +1312,19 @@ static int parse_value(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED,
case SND_CONFIG_TYPE_REAL:
err = snd_config_get_ascii(n, &s);
if (err < 0) {
uc_error("error: unable to parse value for id '%s': %s!", id, snd_strerror(err));
snd_error(UCM, "error: unable to parse value for id '%s': %s!", id, snd_strerror(err));
return err;
}
break;
case SND_CONFIG_TYPE_STRING:
err = parse_string_substitute(uc_mgr, n, &s);
if (err < 0) {
uc_error("error: unable to parse a string for id '%s'!", id);
snd_error(UCM, "error: unable to parse a string for id '%s'!", id);
return err;
}
break;
default:
uc_error("error: invalid type %i in Value compound '%s'", type, id);
snd_error(UCM, "error: invalid type %i in Value compound '%s'", type, id);
return -EINVAL;
}
err = uc_mgr_add_value(base, id, s);
@ -1419,7 +1421,7 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "Comment") == 0) {
err = parse_string_substitute3(uc_mgr, n, &modifier->comment);
if (err < 0) {
uc_error("error: failed to get modifier comment");
snd_error(UCM, "error: failed to get modifier comment");
return err;
}
continue;
@ -1429,8 +1431,9 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr,
err = parse_device_list(uc_mgr, &modifier->dev_list,
DEVLIST_SUPPORTED, n);
if (err < 0) {
uc_error("error: failed to parse supported"
snd_error(UCM, "error: failed to parse supported"
" device list");
return err;
}
}
@ -1439,8 +1442,9 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr,
err = parse_device_list(uc_mgr, &modifier->dev_list,
DEVLIST_CONFLICTING, n);
if (err < 0) {
uc_error("error: failed to parse conflicting"
snd_error(UCM, "error: failed to parse conflicting"
" device list");
return err;
}
}
@ -1448,8 +1452,9 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "EnableSequence") == 0) {
err = parse_sequence(uc_mgr, &modifier->enable_list, n);
if (err < 0) {
uc_error("error: failed to parse modifier"
snd_error(UCM, "error: failed to parse modifier"
" enable sequence");
return err;
}
continue;
@ -1458,8 +1463,9 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "DisableSequence") == 0) {
err = parse_sequence(uc_mgr, &modifier->disable_list, n);
if (err < 0) {
uc_error("error: failed to parse modifier"
snd_error(UCM, "error: failed to parse modifier"
" disable sequence");
return err;
}
continue;
@ -1468,8 +1474,9 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "TransitionSequence") == 0) {
err = parse_transition(uc_mgr, &modifier->transition_list, n);
if (err < 0) {
uc_error("error: failed to parse transition"
snd_error(UCM, "error: failed to parse transition"
" modifier");
return err;
}
continue;
@ -1478,7 +1485,7 @@ static int parse_modifier(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "Value") == 0) {
err = parse_value(uc_mgr, &modifier->value_list, n);
if (err < 0) {
uc_error("error: failed to parse Value");
snd_error(UCM, "error: failed to parse Value");
return err;
}
continue;
@ -1564,7 +1571,7 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "Comment") == 0) {
err = parse_string_substitute3(uc_mgr, n, &device->comment);
if (err < 0) {
uc_error("error: failed to get device comment");
snd_error(UCM, "error: failed to get device comment");
return err;
}
continue;
@ -1574,8 +1581,9 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr,
err = parse_device_list(uc_mgr, &device->dev_list,
DEVLIST_SUPPORTED, n);
if (err < 0) {
uc_error("error: failed to parse supported"
snd_error(UCM, "error: failed to parse supported"
" device list");
return err;
}
}
@ -1584,8 +1592,9 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr,
err = parse_device_list(uc_mgr, &device->dev_list,
DEVLIST_CONFLICTING, n);
if (err < 0) {
uc_error("error: failed to parse conflicting"
snd_error(UCM, "error: failed to parse conflicting"
" device list");
return err;
}
}
@ -1594,8 +1603,9 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr,
uc_dbg("EnableSequence");
err = parse_sequence(uc_mgr, &device->enable_list, n);
if (err < 0) {
uc_error("error: failed to parse device enable"
snd_error(UCM, "error: failed to parse device enable"
" sequence");
return err;
}
continue;
@ -1605,8 +1615,9 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr,
uc_dbg("DisableSequence");
err = parse_sequence(uc_mgr, &device->disable_list, n);
if (err < 0) {
uc_error("error: failed to parse device disable"
snd_error(UCM, "error: failed to parse device disable"
" sequence");
return err;
}
continue;
@ -1616,8 +1627,9 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr,
uc_dbg("TransitionSequence");
err = parse_transition(uc_mgr, &device->transition_list, n);
if (err < 0) {
uc_error("error: failed to parse transition"
snd_error(UCM, "error: failed to parse transition"
" device");
return err;
}
continue;
@ -1626,7 +1638,7 @@ static int parse_device(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "Value") == 0) {
err = parse_value(uc_mgr, &device->value_list, n);
if (err < 0) {
uc_error("error: failed to parse Value");
snd_error(UCM, "error: failed to parse Value");
return err;
}
continue;
@ -1660,7 +1672,7 @@ static int parse_dev_name_list(snd_use_case_mgr_t *uc_mgr,
return -EINVAL;
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for %s", id);
snd_error(UCM, "compound type expected for %s", id);
return -EINVAL;
}
@ -1677,7 +1689,7 @@ static int parse_dev_name_list(snd_use_case_mgr_t *uc_mgr,
err = parse_string_substitute3(uc_mgr, n, &name2);
if (err < 0) {
free(name1s);
uc_error("error: failed to get target device name for '%s'", name1);
snd_error(UCM, "error: failed to get target device name for '%s'", name1);
return err;
}
@ -1789,14 +1801,15 @@ static int verb_dev_list_add(struct use_case_verb *verb,
if (list_empty(&device->dev_list.list)) {
device->dev_list.type = dst_type;
} else {
uc_error("error: incompatible device list type ('%s', '%s')",
snd_error(UCM, "error: incompatible device list type ('%s', '%s')",
device->name, src);
return -EINVAL;
}
}
return uc_mgr_put_to_dev_list(&device->dev_list, src);
}
uc_error("error: unable to find device '%s'", dst);
snd_error(UCM, "error: unable to find device '%s'", dst);
return -ENOENT;
}
@ -1831,7 +1844,7 @@ static int verb_device_management(struct use_case_verb *verb)
dev = list_entry(pos, struct ucm_dev_name, list);
err = uc_mgr_rename_device(verb, dev->name1, dev->name2);
if (err < 0) {
uc_error("error: cannot rename device '%s' to '%s'", dev->name1, dev->name2);
snd_error(UCM, "error: cannot rename device '%s' to '%s'", dev->name1, dev->name2);
return err;
}
}
@ -1841,7 +1854,7 @@ static int verb_device_management(struct use_case_verb *verb)
dev = list_entry(pos, struct ucm_dev_name, list);
err = uc_mgr_remove_device(verb, dev->name2);
if (err < 0) {
uc_error("error: cannot remove device '%s'", dev->name2);
snd_error(UCM, "error: cannot remove device '%s'", dev->name2);
return err;
}
}
@ -1915,7 +1928,7 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr,
uc_dbg("Parse EnableSequence");
err = parse_sequence(uc_mgr, &verb->enable_list, n);
if (err < 0) {
uc_error("error: failed to parse verb enable sequence");
snd_error(UCM, "error: failed to parse verb enable sequence");
return err;
}
continue;
@ -1925,7 +1938,7 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr,
uc_dbg("Parse DisableSequence");
err = parse_sequence(uc_mgr, &verb->disable_list, n);
if (err < 0) {
uc_error("error: failed to parse verb disable sequence");
snd_error(UCM, "error: failed to parse verb disable sequence");
return err;
}
continue;
@ -1935,7 +1948,7 @@ static int parse_verb(snd_use_case_mgr_t *uc_mgr,
uc_dbg("Parse TransitionSequence");
err = parse_transition(uc_mgr, &verb->transition_list, n);
if (err < 0) {
uc_error("error: failed to parse transition sequence");
snd_error(UCM, "error: failed to parse transition sequence");
return err;
}
continue;
@ -2022,8 +2035,9 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "SectionVerb") == 0) {
err = parse_verb(uc_mgr, verb, n);
if (err < 0) {
uc_error("error: %s failed to parse verb",
snd_error(UCM, "error: %s failed to parse verb",
file);
goto _err;
}
continue;
@ -2034,8 +2048,9 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr,
err = parse_compound(uc_mgr, n,
parse_device_name, verb, NULL);
if (err < 0) {
uc_error("error: %s failed to parse device",
snd_error(UCM, "error: %s failed to parse device",
file);
goto _err;
}
continue;
@ -2046,8 +2061,9 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr,
err = parse_compound(uc_mgr, n,
parse_modifier_name, verb, NULL);
if (err < 0) {
uc_error("error: %s failed to parse modifier",
snd_error(UCM, "error: %s failed to parse modifier",
file);
goto _err;
}
continue;
@ -2057,8 +2073,9 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "RenameDevice") == 0) {
err = parse_dev_name_list(uc_mgr, n, &verb->rename_list);
if (err < 0) {
uc_error("error: %s failed to parse device rename",
snd_error(UCM, "error: %s failed to parse device rename",
file);
goto _err;
}
continue;
@ -2068,8 +2085,9 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "RemoveDevice") == 0) {
err = parse_dev_name_list(uc_mgr, n, &verb->remove_list);
if (err < 0) {
uc_error("error: %s failed to parse device remove",
snd_error(UCM, "error: %s failed to parse device remove",
file);
goto _err;
}
continue;
@ -2079,7 +2097,7 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr,
if (uc_mgr->conf_format > 3 && strcmp(id, "LibraryConfig") == 0) {
err = parse_libconfig(uc_mgr, n);
if (err < 0) {
uc_error("error: failed to parse LibConfig");
snd_error(UCM, "error: failed to parse LibConfig");
goto _err;
}
continue;
@ -2090,14 +2108,14 @@ static int parse_verb_file(snd_use_case_mgr_t *uc_mgr,
/* use case verb must have at least 1 device */
if (list_empty(&verb->device_list)) {
uc_error("error: no use case device defined", file);
snd_error(UCM, "error: no use case device defined", file);
return -EINVAL;
}
/* do device rename and delete */
err = verb_device_management(verb);
if (err < 0) {
uc_error("error: device management error in verb '%s'", verb->name);
snd_error(UCM, "error: device management error in verb '%s'", verb->name);
return err;
}
@ -2131,7 +2149,7 @@ static int parse_variant(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg,
if (_vfile) {
err = parse_string_substitute3(uc_mgr, n, &file);
if (err < 0) {
uc_error("failed to get File");
snd_error(UCM, "failed to get File");
goto __error;
}
}
@ -2143,14 +2161,14 @@ static int parse_variant(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg,
if (_vcomment) {
err = parse_string_substitute3(uc_mgr, n, &comment);
if (err < 0) {
uc_error("error: failed to get Comment");
snd_error(UCM, "error: failed to get Comment");
goto __error;
}
}
continue;
}
uc_error("unknown field '%s' in Variant section", id);
snd_error(UCM, "unknown field '%s' in Variant section", id);
err = -EINVAL;
goto __error;
}
@ -2181,13 +2199,13 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg,
int err;
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for use case section");
snd_error(UCM, "compound type expected for use case section");
return -EINVAL;
}
err = parse_get_safe_name(uc_mgr, cfg, NULL, &use_case_name);
if (err < 0) {
uc_error("unable to get name for use case section");
snd_error(UCM, "unable to get name for use case section");
return err;
}
@ -2209,7 +2227,7 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg,
if (strcmp(id, "File") == 0) {
err = parse_string_substitute3(uc_mgr, n, &file);
if (err < 0) {
uc_error("failed to get File");
snd_error(UCM, "failed to get File");
goto __error;
}
continue;
@ -2219,7 +2237,7 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg,
if (strncmp(id, "Comment", 7) == 0) {
err = parse_string_substitute3(uc_mgr, n, &comment);
if (err < 0) {
uc_error("error: failed to get Comment");
snd_error(UCM, "error: failed to get Comment");
goto __error;
}
continue;
@ -2243,11 +2261,11 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg,
continue;
}
uc_error("unknown field '%s' in SectionUseCase", id);
snd_error(UCM, "unknown field '%s' in SectionUseCase", id);
}
if (variant && !variant_ok) {
uc_error("error: undefined variant '%s'", use_case_name);
snd_error(UCM, "error: undefined variant '%s'", use_case_name);
err = -EINVAL;
goto __error;
}
@ -2257,7 +2275,7 @@ static int parse_master_section(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg,
/* do we have both use case name and file ? */
if (!file) {
uc_error("error: use case missing file");
snd_error(UCM, "error: use case missing file");
err = -EINVAL;
goto __error;
}
@ -2304,12 +2322,12 @@ static int parse_controls_fixedboot(snd_use_case_mgr_t *uc_mgr, snd_config_t *cf
int err;
if (!list_empty(&uc_mgr->fixedboot_list)) {
uc_error("FixedBoot list is not empty");
snd_error(UCM, "FixedBoot list is not empty");
return -EINVAL;
}
err = parse_sequence(uc_mgr, &uc_mgr->fixedboot_list, cfg);
if (err < 0) {
uc_error("Unable to parse FixedBootSequence");
snd_error(UCM, "Unable to parse FixedBootSequence");
return err;
}
@ -2324,12 +2342,12 @@ static int parse_controls_boot(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
int err;
if (!list_empty(&uc_mgr->boot_list)) {
uc_error("Boot list is not empty");
snd_error(UCM, "Boot list is not empty");
return -EINVAL;
}
err = parse_sequence(uc_mgr, &uc_mgr->boot_list, cfg);
if (err < 0) {
uc_error("Unable to parse BootSequence");
snd_error(UCM, "Unable to parse BootSequence");
return err;
}
@ -2344,12 +2362,12 @@ static int parse_controls(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
int err;
if (!list_empty(&uc_mgr->default_list)) {
uc_error("Default list is not empty");
snd_error(UCM, "Default list is not empty");
return -EINVAL;
}
err = parse_sequence(uc_mgr, &uc_mgr->default_list, cfg);
if (err < 0) {
uc_error("Unable to parse SectionDefaults");
snd_error(UCM, "Unable to parse SectionDefaults");
return err;
}
@ -2412,7 +2430,7 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
int err;
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for master file");
snd_error(UCM, "compound type expected for master file");
return -EINVAL;
}
@ -2437,7 +2455,7 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
if (strcmp(id, "Comment") == 0) {
err = parse_string_substitute3(uc_mgr, n, &uc_mgr->comment);
if (err < 0) {
uc_error("error: failed to get master comment");
snd_error(UCM, "error: failed to get master comment");
return err;
}
continue;
@ -2481,7 +2499,7 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
if (strcmp(id, "ValueDefaults") == 0) {
err = parse_value(uc_mgr, &uc_mgr->value_list, n);
if (err < 0) {
uc_error("error: failed to parse ValueDefaults");
snd_error(UCM, "error: failed to parse ValueDefaults");
return err;
}
continue;
@ -2491,7 +2509,7 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
if (uc_mgr->conf_format > 3 && strcmp(id, "LibraryConfig") == 0) {
err = parse_libconfig(uc_mgr, n);
if (err < 0) {
uc_error("error: failed to parse LibraryConfig");
snd_error(UCM, "error: failed to parse LibraryConfig");
return err;
}
continue;
@ -2505,7 +2523,7 @@ static int parse_master_file(snd_use_case_mgr_t *uc_mgr, snd_config_t *cfg)
if (strcmp(id, "Syntax") == 0)
continue;
uc_error("unknown master file field %s", id);
snd_error(UCM, "unknown master file field %s", id);
}
return 0;
}
@ -2538,7 +2556,7 @@ static int get_by_card_name(snd_use_case_mgr_t *mgr, const char *card_name)
card = -1;
if (snd_card_next(&card) < 0 || card < 0) {
uc_error("no soundcards found...");
snd_error(UCM, "no soundcards found...");
return -1;
}
@ -2562,7 +2580,7 @@ static int get_by_card_name(snd_use_case_mgr_t *mgr, const char *card_name)
}
if (snd_card_next(&card) < 0) {
uc_error("snd_card_next");
snd_error(UCM, "snd_card_next");
break;
}
}
@ -2591,7 +2609,7 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr,
int err;
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for UseCasePath node");
snd_error(UCM, "compound type expected for UseCasePath node");
return -EINVAL;
}
@ -2600,7 +2618,7 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr,
n = snd_config_iterator_entry(i);
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for UseCasePath.something node");
snd_error(UCM, "compound type expected for UseCasePath.something node");
return -EINVAL;
}
@ -2619,11 +2637,11 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "Version") == 0) {
err = parse_integer_substitute(uc_mgr, n2, &version);
if (err < 0) {
uc_error("unable to parse UcmDirectory");
snd_error(UCM, "unable to parse UcmDirectory");
goto __error;
}
if (version < 1 || version > 2) {
uc_error("Version must be 1 or 2");
snd_error(UCM, "Version must be 1 or 2");
err = -EINVAL;
goto __error;
}
@ -2633,7 +2651,7 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "Directory") == 0) {
err = parse_string_substitute(uc_mgr, n2, &dir);
if (err < 0) {
uc_error("unable to parse Directory");
snd_error(UCM, "unable to parse Directory");
goto __error;
}
continue;
@ -2642,21 +2660,21 @@ static int parse_toplevel_path(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "File") == 0) {
err = parse_string_substitute(uc_mgr, n2, &file);
if (err < 0) {
uc_error("unable to parse File");
snd_error(UCM, "unable to parse File");
goto __error;
}
continue;
}
uc_error("unknown UseCasePath field %s", id);
snd_error(UCM, "unknown UseCasePath field %s", id);
}
if (dir == NULL) {
uc_error("Directory is not defined in %s!", filename);
snd_error(UCM, "Directory is not defined in %s!", filename);
goto __next;
}
if (file == NULL) {
uc_error("File is not defined in %s!", filename);
snd_error(UCM, "File is not defined in %s!", filename);
goto __next;
}
@ -2736,7 +2754,7 @@ static int parse_toplevel_config(snd_use_case_mgr_t *uc_mgr,
int err;
if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for toplevel file");
snd_error(UCM, "compound type expected for toplevel file");
return -EINVAL;
}
@ -2767,7 +2785,7 @@ static int parse_toplevel_config(snd_use_case_mgr_t *uc_mgr,
if (uc_mgr->conf_format > 3 && strcmp(id, "LibraryConfig") == 0) {
err = parse_libconfig(uc_mgr, n);
if (err < 0) {
uc_error("error: failed to parse LibConfig");
snd_error(UCM, "error: failed to parse LibConfig");
return err;
}
continue;
@ -2777,7 +2795,7 @@ static int parse_toplevel_config(snd_use_case_mgr_t *uc_mgr,
if (strcmp(id, "Syntax") == 0)
continue;
uc_error("unknown toplevel field %s", id);
snd_error(UCM, "unknown toplevel field %s", id);
}
return -ENOENT;
@ -2793,7 +2811,7 @@ static int load_toplevel_config(snd_use_case_mgr_t *uc_mgr,
ucm_filename(filename, sizeof(filename), 2, NULL, "ucm.conf");
if (access(filename, R_OK) != 0) {
uc_error("Unable to find the top-level configuration file '%s'.", filename);
snd_error(UCM, "Unable to find the top-level configuration file '%s'.", filename);
return -ENOENT;
}
@ -2809,8 +2827,9 @@ static int load_toplevel_config(snd_use_case_mgr_t *uc_mgr,
err = uc_mgr_config_load(uc_mgr->conf_format, filename, cfg);
if (err < 0) {
uc_error("error: could not parse configuration for card %s",
snd_error(UCM, "error: could not parse configuration for card %s",
uc_mgr->card_name);
goto __error;
}
@ -2840,7 +2859,7 @@ int uc_mgr_import_master_config(snd_use_case_mgr_t *uc_mgr)
if (strncmp(name, "hw:", 3) == 0) {
err = get_by_card(uc_mgr, name);
if (err < 0) {
uc_error("card '%s' is not valid", name);
snd_error(UCM, "card '%s' is not valid", name);
goto __error;
}
} else if (strncmp(name, "strict:", 7)) {
@ -2943,8 +2962,9 @@ int uc_mgr_scan_master_configs(const char **_list[])
err = scandir64(filename, &namelist, filename_filter, SORTFUNC);
if (err < 0) {
err = -errno;
uc_error("error: could not scan directory %s: %s",
snd_error(UCM, "error: could not scan directory %s: %s",
filename, strerror(-err));
return err;
}
cnt = err;
@ -2982,7 +3002,7 @@ int uc_mgr_scan_master_configs(const char **_list[])
if (err == -ENOENT || err == -ENXIO)
continue;
if (err < 0) {
uc_error("Unable to open '%s': %s", fn, snd_strerror(err));
snd_error(UCM, "Unable to open '%s': %s", fn, snd_strerror(err));
goto __err;
}
err = snd_use_case_get(uc_mgr, "comment", (const char **)&s);
@ -3020,18 +3040,18 @@ int uc_mgr_scan_master_configs(const char **_list[])
goto __err;
err = snd_config_search(cfg, "Syntax", &c);
if (err < 0) {
uc_error("Syntax field not found in %s", d_name);
snd_error(UCM, "Syntax field not found in %s", d_name);
snd_config_delete(cfg);
continue;
}
err = snd_config_get_integer(c, &l);
if (err < 0) {
uc_error("Syntax field is invalid in %s", d_name);
snd_error(UCM, "Syntax field is invalid in %s", d_name);
snd_config_delete(cfg);
goto __err;
}
if (l < 2 || l > SYNTAX_VERSION_MAX) {
uc_error("Incompatible syntax %d in %s", l, d_name);
snd_error(UCM, "Incompatible syntax %d in %s", l, d_name);
snd_config_delete(cfg);
goto __err;
}

View file

@ -47,7 +47,7 @@ static int if_eval_string(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
if (uc_mgr->conf_format >= 3) {
err = get_string(eval, "Empty", &string1);
if (err < 0 && err != -ENOENT) {
uc_error("String error (If.Condition.Empty)");
snd_error(UCM, "String error (If.Condition.Empty)");
return -EINVAL;
}
@ -63,23 +63,23 @@ static int if_eval_string(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
err = get_string(eval, "String1", &string1);
if (err < 0 && err != -ENOENT) {
uc_error("String error (If.Condition.String1)");
snd_error(UCM, "String error (If.Condition.String1)");
return -EINVAL;
}
err = get_string(eval, "String2", &string2);
if (err < 0 && err != -ENOENT) {
uc_error("String error (If.Condition.String2)");
snd_error(UCM, "String error (If.Condition.String2)");
return -EINVAL;
}
if (string1 || string2) {
if (string1 == NULL) {
uc_error("If.Condition.String1 not defined");
snd_error(UCM, "If.Condition.String1 not defined");
return -EINVAL;
}
if (string2 == NULL) {
uc_error("If.Condition.String2 not defined");
snd_error(UCM, "If.Condition.String2 not defined");
return -EINVAL;
}
err = uc_mgr_get_substituted_value(uc_mgr, &s1, string1);
@ -98,23 +98,23 @@ static int if_eval_string(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
err = get_string(eval, "Haystack", &string1);
if (err < 0 && err != -ENOENT) {
uc_error("String error (If.Condition.Haystack)");
snd_error(UCM, "String error (If.Condition.Haystack)");
return -EINVAL;
}
err = get_string(eval, "Needle", &string2);
if (err < 0 && err != -ENOENT) {
uc_error("String error (If.Condition.Needle)");
snd_error(UCM, "String error (If.Condition.Needle)");
return -EINVAL;
}
if (string1 || string2) {
if (string1 == NULL) {
uc_error("If.Condition.Haystack not defined");
snd_error(UCM, "If.Condition.Haystack not defined");
return -EINVAL;
}
if (string2 == NULL) {
uc_error("If.Condition.Needle not defined");
snd_error(UCM, "If.Condition.Needle not defined");
return -EINVAL;
}
err = uc_mgr_get_substituted_value(uc_mgr, &s1, string1);
@ -131,7 +131,7 @@ static int if_eval_string(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
return err;
}
uc_error("Unknown String condition arguments");
snd_error(UCM, "Unknown String condition arguments");
return -EINVAL;
}
@ -146,13 +146,13 @@ static int if_eval_regex_match(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
err = get_string(eval, "String", &string);
if (err < 0) {
uc_error("RegexMatch error (If.Condition.String)");
snd_error(UCM, "RegexMatch error (If.Condition.String)");
return -EINVAL;
}
err = get_string(eval, "Regex", &regex_string);
if (err < 0) {
uc_error("RegexMatch error (If.Condition.Regex)");
snd_error(UCM, "RegexMatch error (If.Condition.Regex)");
return -EINVAL;
}
@ -161,7 +161,7 @@ static int if_eval_regex_match(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
return err;
err = regcomp(&re, s, options);
if (err) {
uc_error("Regex '%s' compilation failed (code %d)", s, err);
snd_error(UCM, "Regex '%s' compilation failed (code %d)", s, err);
free(s);
return -EINVAL;
}
@ -194,19 +194,19 @@ static int if_eval_control_exists(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval
err = get_string(eval, "Device", &device);
if (err < 0 && err != -ENOENT) {
uc_error("ControlExists error (If.Condition.Device)");
snd_error(UCM, "ControlExists error (If.Condition.Device)");
return -EINVAL;
}
err = get_string(eval, "Control", &ctldef);
if (err < 0) {
uc_error("ControlExists error (If.Condition.Control)");
snd_error(UCM, "ControlExists error (If.Condition.Control)");
return -EINVAL;
}
err = get_string(eval, "ControlEnum", &enumval);
if (err < 0 && err != -ENOENT) {
uc_error("ControlExists error (If.Condition.ControlEnum)");
snd_error(UCM, "ControlExists error (If.Condition.ControlEnum)");
return -EINVAL;
}
@ -216,14 +216,14 @@ static int if_eval_control_exists(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval
err = snd_ctl_ascii_elem_id_parse(elem_id, s);
free(s);
if (err < 0) {
uc_error("unable to parse element identificator (%s)", ctldef);
snd_error(UCM, "unable to parse element identificator (%s)", ctldef);
return -EINVAL;
}
if (device == NULL) {
ctl = uc_mgr_get_ctl(uc_mgr);
if (ctl == NULL) {
uc_error("cannot determine control device");
snd_error(UCM, "cannot determine control device");
return -EINVAL;
}
} else {
@ -277,19 +277,19 @@ static int if_eval_path(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
char *s;
if (uc_mgr->conf_format < 4) {
uc_error("Path condition is supported in v4+ syntax");
snd_error(UCM, "Path condition is supported in v4+ syntax");
return -EINVAL;
}
err = get_string(eval, "Path", &path);
if (err < 0) {
uc_error("Path error (If.Condition.Path)");
snd_error(UCM, "Path error (If.Condition.Path)");
return -EINVAL;
}
err = get_string(eval, "Mode", &mode);
if (err < 0 && err != -ENOENT) {
uc_error("Path error (If.Condition.Mode)");
snd_error(UCM, "Path error (If.Condition.Mode)");
return -EINVAL;
}
@ -309,7 +309,7 @@ static int if_eval_path(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
} else if (strcasecmp(s, "exec") == 0) {
amode = X_OK;
} else {
uc_error("Path unknown mode '%s' (If.Condition.Mode)", s);
snd_error(UCM, "Path unknown mode '%s' (If.Condition.Mode)", s);
free(s);
return -EINVAL;
}
@ -339,13 +339,13 @@ static int if_eval(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
int err;
if (snd_config_get_type(eval) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for If.Condition");
snd_error(UCM, "compound type expected for If.Condition");
return -EINVAL;
}
err = get_string(eval, "Type", &type);
if (err < 0) {
uc_error("type block error (If.Condition)");
snd_error(UCM, "type block error (If.Condition)");
return -EINVAL;
}
@ -364,7 +364,7 @@ static int if_eval(snd_use_case_mgr_t *uc_mgr, snd_config_t *eval)
if (strcmp(type, "Path") == 0)
return if_eval_path(uc_mgr, eval);
uc_error("unknown If.Condition.Type");
snd_error(UCM, "unknown If.Condition.Type");
return -EINVAL;
}
@ -380,36 +380,36 @@ static int if_eval_one(snd_use_case_mgr_t *uc_mgr,
*result = NULL;
if (snd_config_get_type(cond) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for If.1");
snd_error(UCM, "compound type expected for If.1");
return -EINVAL;
}
if (snd_config_search(cond, "Condition", &expr) < 0) {
uc_error("condition block expected (If)");
snd_error(UCM, "condition block expected (If)");
return -EINVAL;
}
err = snd_config_search(cond, "True", &_true);
if (err < 0 && err != -ENOENT) {
uc_error("true block error (If)");
snd_error(UCM, "true block error (If)");
return -EINVAL;
}
err = snd_config_search(cond, "False", &_false);
if (err < 0 && err != -ENOENT) {
uc_error("false block error (If)");
snd_error(UCM, "false block error (If)");
return -EINVAL;
}
err = snd_config_search(cond, "Before", before);
if (err < 0 && err != -ENOENT) {
uc_error("before block identifier error");
snd_error(UCM, "before block identifier error");
return -EINVAL;
}
err = snd_config_search(cond, "After", after);
if (err < 0 && err != -ENOENT) {
uc_error("before block identifier error");
snd_error(UCM, "before block identifier error");
return -EINVAL;
}
@ -448,12 +448,12 @@ int uc_mgr_evaluate_condition(snd_use_case_mgr_t *uc_mgr,
int err;
if (uc_mgr->conf_format < 2) {
uc_error("conditions are not supported for v1 syntax");
snd_error(UCM, "conditions are not supported for v1 syntax");
return -EINVAL;
}
if (snd_config_get_type(cond) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for If");
snd_error(UCM, "compound type expected for If");
return -EINVAL;
}

View file

@ -236,15 +236,16 @@ int uc_mgr_exec(const char *prog)
if (p == -1) {
err = -errno;
pthread_mutex_unlock(&fork_lock);
uc_error("Unable to fork() for \"%s\" -- %s", prog, strerror(errno));
snd_error(UCM, "Unable to fork() for \"%s\" -- %s", prog, strerror(errno));
goto __error;
}
if (p == 0) {
f = open("/dev/null", O_RDWR);
if (f == -1) {
uc_error("pid %d cannot open /dev/null for redirect %s -- %s",
snd_error(UCM, "pid %d cannot open /dev/null for redirect %s -- %s",
getpid(), prog, strerror(errno));
exit(1);
}

View file

@ -50,25 +50,25 @@ static int include_eval_one(snd_use_case_mgr_t *uc_mgr,
*result = NULL;
if (snd_config_get_type(inc) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for Include.1");
snd_error(UCM, "compound type expected for Include.1");
return -EINVAL;
}
err = get_string(inc, "File", &file);
if (err < 0) {
uc_error("file expected (Include)");
snd_error(UCM, "file expected (Include)");
return -EINVAL;
}
err = snd_config_search(inc, "Before", before);
if (err < 0 && err != -ENOENT) {
uc_error("before block identifier error");
snd_error(UCM, "before block identifier error");
return -EINVAL;
}
err = snd_config_search(inc, "After", after);
if (err < 0 && err != -ENOENT) {
uc_error("before block identifier error");
snd_error(UCM, "before block identifier error");
return -EINVAL;
}
@ -144,7 +144,7 @@ static int compound_merge(snd_use_case_mgr_t *uc_mgr, const char *id,
int err, array, idx;
if (snd_config_get_type(src) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for the merged block");
snd_error(UCM, "compound type expected for the merged block");
return -EINVAL;
}
@ -164,17 +164,17 @@ static int compound_merge(snd_use_case_mgr_t *uc_mgr, const char *id,
return snd_config_merge(dst, src, 0); /* merge / append mode */
if (_before && _after) {
uc_error("defined both before and after identifiers in the If or Include block");
snd_error(UCM, "defined both before and after identifiers in the If or Include block");
return -EINVAL;
}
array = snd_config_is_array(dst);
if (array < 0) {
uc_error("destination configuration node is not a compound");
snd_error(UCM, "destination configuration node is not a compound");
return array;
}
if (array && snd_config_is_array(src) <= 0) {
uc_error("source configuration node is not an array");
snd_error(UCM, "source configuration node is not an array");
return -EINVAL;
}
@ -287,12 +287,12 @@ int uc_mgr_evaluate_include(snd_use_case_mgr_t *uc_mgr,
int err;
if (uc_mgr->conf_format < 3) {
uc_error("in-place include is supported in v3+ syntax");
snd_error(UCM, "in-place include is supported in v3+ syntax");
return -EINVAL;
}
if (snd_config_get_type(inc) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for Include");
snd_error(UCM, "compound type expected for Include");
return -EINVAL;
}

View file

@ -285,8 +285,6 @@ struct snd_use_case_mgr {
char *cdev;
};
#define uc_error SNDERR
#ifdef UC_MGR_DEBUG
#define uc_dbg SNDERR
#else

View file

@ -98,24 +98,24 @@ int uc_mgr_define_regex(snd_use_case_mgr_t *uc_mgr, const char *name,
int err;
if (uc_mgr->conf_format < 3) {
uc_error("define regex is supported in v3+ syntax");
snd_error(UCM, "define regex is supported in v3+ syntax");
return -EINVAL;
}
if (snd_config_get_type(eval) != SND_CONFIG_TYPE_COMPOUND) {
uc_error("compound type expected for DefineRegex");
snd_error(UCM, "compound type expected for DefineRegex");
return -EINVAL;
}
err = get_string(eval, "String", &string);
if (err < 0) {
uc_error("DefineRegex error (String)");
snd_error(UCM, "DefineRegex error (String)");
return -EINVAL;
}
err = get_string(eval, "Regex", &regex_string);
if (err < 0) {
uc_error("DefineRegex error (Regex string)");
snd_error(UCM, "DefineRegex error (Regex string)");
return -EINVAL;
}
@ -123,7 +123,7 @@ int uc_mgr_define_regex(snd_use_case_mgr_t *uc_mgr, const char *name,
if (err == -ENOENT) {
options = REG_EXTENDED;
} else if (err < 0) {
uc_error("DefineRegex error (Flags string)");
snd_error(UCM, "DefineRegex error (Flags string)");
return -EINVAL;
} else {
while (*flags_string) {
@ -141,7 +141,7 @@ int uc_mgr_define_regex(snd_use_case_mgr_t *uc_mgr, const char *name,
options |= REG_NEWLINE;
break;
default:
uc_error("DefineRegex error (unknown flag '%c')", *flags_string);
snd_error(UCM, "DefineRegex error (unknown flag '%c')", *flags_string);
return -EINVAL;
}
flags_string++;
@ -154,7 +154,7 @@ int uc_mgr_define_regex(snd_use_case_mgr_t *uc_mgr, const char *name,
err = regcomp(&re, s, options);
free(s);
if (err) {
uc_error("Regex '%s' compilation failed (code %d)", s, err);
snd_error(UCM, "Regex '%s' compilation failed (code %d)", s, err);
return -EINVAL;
}

View file

@ -178,11 +178,11 @@ static struct ctl_list *get_ctl_list_by_name(snd_use_case_mgr_t *uc_mgr, const c
static char *rval_card_number_by_name(snd_use_case_mgr_t *uc_mgr, const char *id)
{
if (uc_mgr->conf_format < 3) {
uc_error("CardNumberByName substitution is supported in v3+ syntax");
snd_error(UCM, "CardNumberByName substitution is supported in v3+ syntax");
return NULL;
}
uc_error("${CardNumberByName} substitution is obsolete - use ${find-card}!");
snd_error(UCM, "${CardNumberByName} substitution is obsolete - use ${find-card}!");
return get_card_number(get_ctl_list_by_name(uc_mgr, id));
}
@ -192,11 +192,11 @@ static char *rval_card_id_by_name(snd_use_case_mgr_t *uc_mgr, const char *id)
struct ctl_list *ctl_list;
if (uc_mgr->conf_format < 3) {
uc_error("CardIdByName substitution is supported in v3+ syntax");
snd_error(UCM, "CardIdByName substitution is supported in v3+ syntax");
return NULL;
}
uc_error("${CardIdByName} substitution is obsolete - use ${find-card}!");
snd_error(UCM, "${CardIdByName} substitution is obsolete - use ${find-card}!");
ctl_list = get_ctl_list_by_name(uc_mgr, id);
if (ctl_list == NULL)
@ -242,19 +242,19 @@ static char *rval_lookup_main(snd_use_case_mgr_t *uc_mgr,
int err;
if (uc_mgr->conf_format < 4) {
uc_error("Lookups are supported in v4+ syntax");
snd_error(UCM, "Lookups are supported in v4+ syntax");
return NULL;
}
err = snd_config_load_string(&config, query, 0);
if (err < 0) {
uc_error("The lookup arguments '%s' are invalid", query);
snd_error(UCM, "The lookup arguments '%s' are invalid", query);
return NULL;
}
if (iter->init && iter->init(uc_mgr, iter, config))
goto null;
if (snd_config_search(config, "field", &d)) {
uc_error("Lookups require field!");
snd_error(UCM, "Lookups require field!");
goto null;
}
if (snd_config_get_string(d, &s))
@ -266,18 +266,18 @@ static char *rval_lookup_main(snd_use_case_mgr_t *uc_mgr,
}
}
if (iter->fcn == NULL) {
uc_error("Unknown field value '%s'", s);
snd_error(UCM, "Unknown field value '%s'", s);
goto null;
}
if (snd_config_search(config, "regex", &d)) {
uc_error("Lookups require regex!");
snd_error(UCM, "Lookups require regex!");
goto null;
}
if (snd_config_get_string(d, &s))
goto null;
err = regcomp(&re, s, REG_EXTENDED | REG_ICASE);
if (err) {
uc_error("Regex '%s' compilation failed (code %d)", s, err);
snd_error(UCM, "Regex '%s' compilation failed (code %d)", s, err);
goto null;
}
@ -343,7 +343,7 @@ static char *rval_card_lookup_return(struct lookup_iterate *iter, snd_config_t *
snprintf(num, sizeof(num), "%d", snd_ctl_card_info_get_card(iter->info));
return strdup(num);
} else {
uc_error("Unknown return type '%s'", s);
snd_error(UCM, "Unknown return type '%s'", s);
return NULL;
}
}
@ -384,7 +384,7 @@ next:
if (err < 0) {
if (err == -ENOENT)
goto next;
uc_error("Unable to obtain PCM info (device %d)", device);
snd_error(UCM, "Unable to obtain PCM info (device %d)", device);
return NULL;
}
return iter;
@ -431,7 +431,7 @@ static int rval_pcm_lookup_init(struct lookup_iterate *iter,
else if (strcasecmp(s, "capture") == 0)
stream = SND_PCM_STREAM_CAPTURE;
else {
uc_error("Unknown stream type '%s'", s);
snd_error(UCM, "Unknown stream type '%s'", s);
return -EINVAL;
}
}
@ -466,24 +466,24 @@ static int rval_device_lookup_init(snd_use_case_mgr_t *uc_mgr,
if (snd_config_search(config, "ctl", &d) || snd_config_get_string(d, &s)) {
iter->ctl_list = uc_mgr_get_master_ctl(uc_mgr);
if (iter->ctl_list == NULL) {
uc_error("Control device is not defined!");
snd_error(UCM, "Control device is not defined!");
return -EINVAL;
}
} else {
err = uc_mgr_open_ctl(uc_mgr, &iter->ctl_list, s, 1);
if (err < 0) {
uc_error("Control device '%s' not found", s);
snd_error(UCM, "Control device '%s' not found", s);
return -EINVAL;
}
}
if (snd_config_search(config, "type", &d) || snd_config_get_string(d, &s)) {
uc_error("Missing device type!");
snd_error(UCM, "Missing device type!");
return -EINVAL;
}
for (t = types; t->name; t++)
if (strcasecmp(t->name, s) == 0)
return t->init(iter, config);
uc_error("Device type '%s' is invalid", s);
snd_error(UCM, "Device type '%s' is invalid", s);
return -EINVAL;
}
@ -531,7 +531,7 @@ static int parse_position(snd_config_t *config, const char *name, ssize_t *pos,
*pos = -1;
return 0;
}
uc_error("Unable to find field '%s'", name);
snd_error(UCM, "Unable to find field '%s'", name);
return -1;
}
if (!snd_config_get_integer(d, &v))
@ -539,7 +539,7 @@ static int parse_position(snd_config_t *config, const char *name, ssize_t *pos,
if (snd_config_get_string(d, &s))
return -1;
if (safe_strtol(s, &v)) {
uc_error("Unable to parse position '%s'", s);
snd_error(UCM, "Unable to parse position '%s'", s);
return -1;
}
fin:
@ -555,7 +555,7 @@ static int parse_range(const char *cfg, int *type, ssize_t *pos, ssize_t *size)
err = snd_config_load_string(&config, cfg, 0);
if (err < 0) {
uc_error("The range arguments '%s' are invalid", cfg);
snd_error(UCM, "The range arguments '%s' are invalid", cfg);
return -1;
}
if (snd_config_search(config, "type", &d)) {
@ -568,7 +568,7 @@ static int parse_range(const char *cfg, int *type, ssize_t *pos, ssize_t *size)
} else if (strcasecmp(s, "hex") == 0) {
*type = RANGE_TYPE_HEX;
} else {
uc_error("Unknown range type '%s'", s);
snd_error(UCM, "Unknown range type '%s'", s);
}
}
*pos = 0;
@ -582,7 +582,7 @@ static int parse_range(const char *cfg, int *type, ssize_t *pos, ssize_t *size)
if (*size <= 0)
*size = 1;
if (*pos < 0) {
uc_error("Invalid start position");
snd_error(UCM, "Invalid start position");
retval = -1;
goto null;
}
@ -605,7 +605,7 @@ static char *rval_sysfs_main(snd_use_case_mgr_t *uc_mgr, const char *top_path, c
return NULL;
if (id[0] == '[') {
if (uc_mgr->conf_format < 8) {
uc_error("Sysfs ranges are supported in v8+ syntax");
snd_error(UCM, "Sysfs ranges are supported in v8+ syntax");
return NULL;
}
s = strchr(id, ']');
@ -617,7 +617,7 @@ static char *rval_sysfs_main(snd_use_case_mgr_t *uc_mgr, const char *top_path, c
strncpy(link, id + 1, len);
link[len] = '\0';
if (parse_range(link, &type, &range_start, &range_size)) {
uc_error("sysfs: cannot parse hex range '%s'", link);
snd_error(UCM, "sysfs: cannot parse hex range '%s'", link);
return NULL;
}
id = s + 1;
@ -633,7 +633,7 @@ static char *rval_sysfs_main(snd_use_case_mgr_t *uc_mgr, const char *top_path, c
if (S_ISLNK(sb.st_mode)) {
len = readlink(path, link, sizeof(link) - 1);
if (len <= 0) {
uc_error("sysfs: cannot read link '%s' (%d)", path, errno);
snd_error(UCM, "sysfs: cannot read link '%s' (%d)", path, errno);
return NULL;
}
link[len] = '\0';
@ -649,18 +649,18 @@ static char *rval_sysfs_main(snd_use_case_mgr_t *uc_mgr, const char *top_path, c
fd = open(path, O_RDONLY);
if (fd < 0) {
uc_error("sysfs open failed for '%s' (%d)", path, errno);
snd_error(UCM, "sysfs open failed for '%s' (%d)", path, errno);
return NULL;
}
len = sizeof(path) - 1;
if (range_start > 0 && lseek(fd, range_start, SEEK_SET) != range_start) {
uc_error("sysfs seek failed (%d)", errno);
snd_error(UCM, "sysfs seek failed (%d)", errno);
close(fd);
return NULL;
}
if (range_size > 0) {
if (range_size > len) {
uc_error("sysfs EOB for '%s'", path);
snd_error(UCM, "sysfs EOB for '%s'", path);
close(fd);
return NULL;
} else {
@ -670,7 +670,7 @@ static char *rval_sysfs_main(snd_use_case_mgr_t *uc_mgr, const char *top_path, c
len = read(fd, path, len);
close(fd);
if (len < 0) {
uc_error("sysfs unable to read value '%s' (%d)", path, errno);
snd_error(UCM, "sysfs unable to read value '%s' (%d)", path, errno);
return NULL;
}
if (type == RANGE_TYPE_HEX && range_start >= 0) {
@ -701,7 +701,7 @@ static char *rval_sysfs_card(snd_use_case_mgr_t *uc_mgr, const char *id)
char top_path[32], *s;
if (uc_mgr->conf_format < 8) {
uc_error("sys-card is supported in v8+ syntax");
snd_error(UCM, "sys-card is supported in v8+ syntax");
return NULL;
}
s = get_card_number(uc_mgr_get_master_ctl(uc_mgr));
@ -716,7 +716,7 @@ static char *rval_var(snd_use_case_mgr_t *uc_mgr, const char *id)
bool ignore_not_found = false;
if (uc_mgr->conf_format < 3) {
uc_error("variable substitution is supported in v3+ syntax");
snd_error(UCM, "variable substitution is supported in v3+ syntax");
return NULL;
}
@ -755,12 +755,12 @@ static char *rval_eval(snd_use_case_mgr_t *uc_mgr, const char *e)
int err;
if (uc_mgr->conf_format < 5) {
uc_error("variable evaluation is supported in v5+ syntax");
snd_error(UCM, "variable evaluation is supported in v5+ syntax");
return NULL;
}
err = _snd_eval_string(&dst, e, rval_eval_var_cb, uc_mgr);
if (err < 0) {
uc_error("unable to evaluate '%s'", e);
snd_error(UCM, "unable to evaluate '%s'", e);
return NULL;
}
err = snd_config_get_ascii(dst, &r);
@ -779,7 +779,7 @@ static int rval_evali(snd_use_case_mgr_t *uc_mgr, snd_config_t *node, const char
int err;
if (uc_mgr->conf_format < 6) {
uc_error("variable evaluation is supported in v6+ syntax");
snd_error(UCM, "variable evaluation is supported in v6+ syntax");
return -EINVAL;
}
err = snd_config_get_id(node, &id);
@ -796,7 +796,7 @@ static int rval_evali(snd_use_case_mgr_t *uc_mgr, snd_config_t *node, const char
err = _snd_eval_string(&dst, s + 8, rval_eval_var_cb, uc_mgr);
free(s);
if (err < 0) {
uc_error("unable to evaluate '%s'", e);
snd_error(UCM, "unable to evaluate '%s'", e);
return err;
}
err = snd_config_set_id(dst, id);
@ -921,9 +921,9 @@ __merr:
if (tmp) {
strncpy(r, value, tmp + 1 - value);
r[tmp + 1 - value] = '\0';
uc_error("variable '%s' is not known!", r);
snd_error(UCM, "variable '%s' is not known!", r);
} else {
uc_error("variable reference '%s' is not complete", value);
snd_error(UCM, "variable reference '%s' is not complete", value);
}
goto __error;
__match2:
@ -941,7 +941,7 @@ __match2:
goto __direct_fcn2;
tmp = uc_mgr_get_variable(uc_mgr, v2 + 1);
if (tmp == NULL) {
uc_error("define '%s' is not reachable in this context!", v2 + 1);
snd_error(UCM, "define '%s' is not reachable in this context!", v2 + 1);
rval = NULL;
} else {
rval = fcn2(uc_mgr, tmp);
@ -962,8 +962,9 @@ __rval:
}
strncpy(r, value, idsize);
r[idsize] = '\0';
uc_error("variable '%s' is %s in this context!", r,
snd_error(UCM, "variable '%s' is %s in this context!", r,
rval ? "empty" : "not defined");
err = -EINVAL;
goto __error;
}
@ -1016,7 +1017,7 @@ int uc_mgr_substitute_tree(snd_use_case_mgr_t *uc_mgr, snd_config_t *node)
return err;
err = snd_config_set_id(node, s);
if (err < 0) {
uc_error("unable to set substituted id '%s' (old id '%s')", s, id);
snd_error(UCM, "unable to set substituted id '%s' (old id '%s')", s, id);
free(s);
return err;
}

View file

@ -55,7 +55,7 @@ const char *uc_mgr_sysfs_root(void)
if (e == NULL)
return "/sys";
if (*e == '\0')
uc_error("no sysfs root!");
snd_error(UCM, "no sysfs root!");
return e;
}
@ -69,7 +69,7 @@ struct ctl_list *uc_mgr_get_master_ctl(snd_use_case_mgr_t *uc_mgr)
if (ctl_list2->slave)
continue;
if (ctl_list) {
uc_error("multiple control device names were found!");
snd_error(UCM, "multiple control device names were found!");
return NULL;
}
ctl_list = ctl_list2;
@ -298,7 +298,7 @@ int uc_mgr_open_ctl(snd_use_case_mgr_t *uc_mgr,
if (err == 0)
id = snd_ctl_card_info_get_id(info);
if (err < 0 || id == NULL || id[0] == '\0') {
uc_error("control hardware info (%s): %s", device, snd_strerror(err));
snd_error(UCM, "control hardware info (%s): %s", device, snd_strerror(err));
snd_ctl_close(ctl);
return err >= 0 ? -EINVAL : err;
}
@ -361,7 +361,7 @@ int uc_mgr_config_load_into(int format, const char *file, snd_config_t *top)
if (!fp) {
err = -errno;
__err_open:
uc_error("could not open configuration file %s", file);
snd_error(UCM, "could not open configuration file %s", file);
return err;
}
err = snd_input_stdio_attach(&in, fp, 1);
@ -372,7 +372,7 @@ int uc_mgr_config_load_into(int format, const char *file, snd_config_t *top)
default_paths[1] = NULL;
err = _snd_config_load_with_include(top, in, 0, default_paths);
if (err < 0) {
uc_error("could not load configuration file %s", file);
snd_error(UCM, "could not load configuration file %s", file);
if (in)
snd_input_close(in);
return err;