From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH RFC 1/2] control: Simplify using snd_config_get_bool()
Date: Fri, 12 Oct 2012 17:25:23 +0200 [thread overview]
Message-ID: <s5hmwzrk90c.wl%tiwai@suse.de> (raw)
In-Reply-To: s5hpq4nk9b1.wl%tiwai@suse.de
snd_config_get_bool() was improved to parse also ASCII strings now,
so we don't have to open-code the boolean parser in
src/control/setup.c any longer.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
src/control/setup.c | 37 ++++++-------------------------------
1 file changed, 6 insertions(+), 31 deletions(-)
diff --git a/src/control/setup.c b/src/control/setup.c
index eecda45..bd3599d 100644
--- a/src/control/setup.c
+++ b/src/control/setup.c
@@ -400,7 +400,6 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
{
snd_config_t *conf;
snd_config_iterator_t i, next;
- char *tmp;
int iface = SND_CTL_ELEM_IFACE_MIXER;
const char *name = NULL;
long index = 0;
@@ -464,33 +463,17 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
continue;
}
if (strcmp(id, "lock") == 0) {
- if ((err = snd_config_get_ascii(n, &tmp)) < 0) {
- SNDERR("field %s has an invalid type", id);
- goto _err;
- }
- err = snd_config_get_bool_ascii(tmp);
- if (err < 0) {
- SNDERR("field %s is not a boolean", id);
- free(tmp);
+ err = snd_config_get_bool(n);
+ if (err < 0)
goto _err;
- }
lock = err;
- free(tmp);
continue;
}
if (strcmp(id, "preserve") == 0) {
- if ((err = snd_config_get_ascii(n, &tmp)) < 0) {
- SNDERR("field %s has an invalid type", id);
- goto _err;
- }
- err = snd_config_get_bool_ascii(tmp);
- if (err < 0) {
- SNDERR("field %s is not a boolean", id);
- free(tmp);
+ err = snd_config_get_bool(n);
+ if (err < 0)
goto _err;
- }
preserve = err;
- free(tmp);
continue;
}
if (strcmp(id, "value") == 0) {
@@ -502,18 +485,10 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
continue;
}
if (strcmp(id, "optional") == 0) {
- if ((err = snd_config_get_ascii(n, &tmp)) < 0) {
- SNDERR("field %s has an invalid type", id);
- goto _err;
- }
- err = snd_config_get_bool_ascii(tmp);
- if (err < 0) {
- SNDERR("field %s is not a boolean", id);
- free(tmp);
+ err = snd_config_get_bool(n);
+ if (err < 0)
goto _err;
- }
optional = err;
- free(tmp);
continue;
}
SNDERR("Unknown field %s", id);
--
1.7.12.2
next prev parent reply other threads:[~2012-10-12 15:25 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-12 15:18 [RFC] Fix for conflict of HDMI and SPDIF IEC958 controls Takashi Iwai
2012-10-12 15:24 ` [PATCH RFC] ALSA: hda - Add workaround for conflicting " Takashi Iwai
2012-10-17 8:17 ` Takashi Iwai
2012-10-17 12:43 ` Raymond Yau
2012-10-17 12:44 ` Takashi Iwai
2013-02-08 22:44 ` [PATCH] ALSA: hda - Fix the " Anssi Hannula
2013-02-10 10:38 ` Takashi Iwai
2013-02-10 11:05 ` Anssi Hannula
2013-02-11 10:51 ` Takashi Iwai
2013-02-11 11:20 ` Anssi Hannula
2013-02-11 11:28 ` Takashi Iwai
2013-02-12 15:51 ` Anssi Hannula
2013-02-12 17:40 ` Takashi Iwai
2012-10-12 15:25 ` Takashi Iwai [this message]
2012-10-12 15:25 ` [PATCH RFC 2/2] Add workaround for conflicting IEC958 controls for HD-audio Takashi Iwai
2013-02-03 16:40 ` Anssi Hannula
2013-02-04 9:34 ` Takashi Iwai
2012-10-15 2:31 ` [RFC] Fix for conflict of HDMI and SPDIF IEC958 controls Raymond Yau
2012-10-15 7:46 ` Takashi Iwai
2012-10-15 8:15 ` Raymond Yau
2012-10-15 8:35 ` Takashi Iwai
2012-10-15 8:49 ` Raymond Yau
2012-10-15 8:55 ` Takashi Iwai
[not found] ` <CAN8ccib4Z9VpHcdGxP3q5kofikU6zt6risGDAbOBiRKyKVcsxA@mail.gmail.com>
[not found] ` <CAN8cciY0TfZ+50EuoYbFdz1AzgNuDKZAaDE-o0v-YD_MpXnO1g@mail.gmail.com>
2012-10-15 13:10 ` Raymond Yau
2012-10-15 13:20 ` Takashi Iwai
2012-10-15 10:09 ` David Henningsson
2012-10-15 10:18 ` Takashi Iwai
2012-10-15 10:58 ` David Henningsson
2012-10-15 10:21 ` Jaroslav Kysela
2012-10-15 10:31 ` Takashi Iwai
2012-10-15 11:11 ` Jaroslav Kysela
2012-10-15 12:06 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5hmwzrk90c.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).