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 "
"and multiple of 4");
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",
card_name, err);
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",
verb_name);
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);

File diff suppressed because it is too large Load diff

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",
getpid(), prog, strerror(errno));
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,
rval ? "empty" : "not defined");
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;