]> git.alsa-project.org Git - alsa-lib.git/commitdiff
topology: sort_config() cleanups - use goto for the error path
authorJaroslav Kysela <perex@perex.cz>
Thu, 7 Jan 2021 16:45:27 +0000 (17:45 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 7 Jan 2021 16:45:27 +0000 (17:45 +0100)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/topology/save.c

index f7af7af3e8c270ac95594def4b0eb81a113f3eec..fecbc6a5dfa8d306ebc2b59770b23da6cf0fd5a2 100644 (file)
@@ -180,29 +180,28 @@ static snd_config_t *sort_config(const char *id, snd_config_t *src)
        }
        if (array <= 0)
                qsort(a, count, sizeof(a[0]), _compar);
-       if (snd_config_make_compound(&dst, id, count == 1)) {
-               free(a);
-               return NULL;
-       }
+       if (snd_config_make_compound(&dst, id, count == 1))
+               goto lerr;
        for (index = 0; index < count; index++) {
                snd_config_t *s = a[index];
                const char *id2;
                if (snd_config_get_id(s, &id2)) {
                        snd_config_delete(dst);
-                       free(a);
-                       return NULL;
+                       goto lerr;
                }
                s = sort_config(id2, s);
                if (s == NULL || snd_config_add(dst, s)) {
                        if (s)
                                snd_config_delete(s);
                        snd_config_delete(dst);
-                       free(a);
-                       return NULL;
+                       goto lerr;
                }
        }
        free(a);
        return dst;
+lerr:
+       free(a);
+       return NULL;
 }
 
 static int tplg_check_quoted(const unsigned char *p)