switch-on-connect: Fix warning on discarded const qualifier
authorArun Raghavan <arun@arunraghavan.net>
Fri, 22 Nov 2019 15:46:33 +0000 (21:16 +0530)
committerArun Raghavan <arun@arunraghavan.net>
Fri, 22 Nov 2019 17:02:16 +0000 (22:32 +0530)
pa_modargs_get_value() returns a const string -- instead of discarding
the const qualifier, let's just duplicate the string and free it
explicitly in the failure case.

src/modules/module-switch-on-connect.c

index 5ebe0f4..4205a78 100644 (file)
@@ -249,12 +249,10 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
-    u->blacklist = pa_modargs_get_value(ma, "blacklist", NULL);
-    if (u->blacklist != NULL && pa_is_regex_valid(u->blacklist)) {
-        /* String returned above will be freed with modargs, duplicate it */
-        u->blacklist = pa_xstrdup(u->blacklist);
-    } else if (u->blacklist != NULL) {
-        pa_log_error("A blacklist pattern was provided but is not a valid regex.");
+    u->blacklist = pa_xstrdup(pa_modargs_get_value(ma, "blacklist", NULL));
+    if (u->blacklist != NULL && !pa_is_regex_valid(u->blacklist)) {
+        pa_log_error("A blacklist pattern was provided but is not a valid regex");
+        pa_xfree(u->blacklist);
         goto fail;
     }