mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-02 09:01:48 -05:00
ctl: use condition statements instead of assert() for new APIs to add an element set
Usage of assert() is not better practice of programming as shared library APIs. They should return appropriate error code to promote applications to handle error state. This commit applies condition statements with return value of -EINVAL, instead of assert(). As a backward compatibility for existent applications, old APIs still call assert(). Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
9797e98930
commit
df43c2d380
1 changed files with 19 additions and 5 deletions
|
|
@ -382,7 +382,8 @@ int snd_ctl_add_integer_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
|||
unsigned int numid;
|
||||
int err;
|
||||
|
||||
assert(ctl && info && info->id.name[0]);
|
||||
if (ctl == NULL || info == NULL || info->id.name[0] == '\0')
|
||||
return -EINVAL;
|
||||
|
||||
info->type = SND_CTL_ELEM_TYPE_INTEGER;
|
||||
info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
||||
|
|
@ -471,7 +472,8 @@ int snd_ctl_add_integer64_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
|||
unsigned int numid;
|
||||
int err;
|
||||
|
||||
assert(ctl && info && info->id.name[0]);
|
||||
if (ctl == NULL || info == NULL || info->id.name[0] == '\0')
|
||||
return -EINVAL;
|
||||
|
||||
info->type = SND_CTL_ELEM_TYPE_INTEGER64;
|
||||
info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
||||
|
|
@ -549,7 +551,8 @@ int snd_ctl_add_boolean_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
|||
unsigned int element_count,
|
||||
unsigned int member_count)
|
||||
{
|
||||
assert(ctl && info && info->id.name[0]);
|
||||
if (ctl == NULL || info == NULL || info->id.name[0] == '\0')
|
||||
return -EINVAL;
|
||||
|
||||
info->type = SND_CTL_ELEM_TYPE_BOOLEAN;
|
||||
info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
||||
|
|
@ -619,7 +622,9 @@ int snd_ctl_add_enumerated_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
|||
char *buf, *p;
|
||||
int err;
|
||||
|
||||
assert(ctl && info && info->id.name[0] && labels);
|
||||
if (ctl == NULL || info == NULL || info->id.name[0] == '\0' ||
|
||||
labels == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
info->type = SND_CTL_ELEM_TYPE_ENUMERATED;
|
||||
info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
||||
|
|
@ -698,7 +703,8 @@ int snd_ctl_add_bytes_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
|||
unsigned int element_count,
|
||||
unsigned int member_count)
|
||||
{
|
||||
assert(ctl && info && info->id.name[0]);
|
||||
if (ctl == NULL || info == NULL || info->id.name[0] == '\0')
|
||||
return -EINVAL;
|
||||
|
||||
info->type = SND_CTL_ELEM_TYPE_BYTES;
|
||||
info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
||||
|
|
@ -726,6 +732,8 @@ int snd_ctl_elem_add_integer(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
|
|||
{
|
||||
snd_ctl_elem_info_t info = {0};
|
||||
|
||||
assert(ctl && id && id->name[0]);
|
||||
|
||||
info.id = *id;
|
||||
|
||||
return snd_ctl_add_integer_elem_set(ctl, &info, 1, member_count,
|
||||
|
|
@ -745,6 +753,8 @@ int snd_ctl_elem_add_integer64(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
|
|||
{
|
||||
snd_ctl_elem_info_t info = {0};
|
||||
|
||||
assert(ctl && id && id->name[0]);
|
||||
|
||||
info.id = *id;
|
||||
|
||||
return snd_ctl_add_integer64_elem_set(ctl, &info, 1, member_count,
|
||||
|
|
@ -763,6 +773,8 @@ int snd_ctl_elem_add_boolean(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
|
|||
{
|
||||
snd_ctl_elem_info_t info = {0};
|
||||
|
||||
assert(ctl && id && id->name[0]);
|
||||
|
||||
info.id = *id;
|
||||
|
||||
return snd_ctl_add_boolean_elem_set(ctl, &info, 1, member_count);
|
||||
|
|
@ -783,6 +795,8 @@ int snd_ctl_elem_add_enumerated(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
|
|||
{
|
||||
snd_ctl_elem_info_t info = {0};
|
||||
|
||||
assert(ctl && id && id->name[0] && labels);
|
||||
|
||||
info.id = *id;
|
||||
|
||||
return snd_ctl_add_enumerated_elem_set(ctl, &info, 1, member_count,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue