]> git.alsa-project.org Git - alsa-lib.git/commitdiff
control: Simplify using snd_config_get_bool()
authorTakashi Iwai <tiwai@suse.de>
Fri, 12 Oct 2012 10:22:53 +0000 (12:22 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 21 Feb 2013 16:48:55 +0000 (17:48 +0100)
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

index eecda45798b8835e4891b7e0032466eba31576ad..bd3599de58e141823ea676aa04a8bdd45b3e0b6d 100644 (file)
@@ -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);