[pulseaudio-commits] 8 commits - src/modules src/pulsecore src/utils

Tanu Kaskinen tanuk at kemper.freedesktop.org
Wed Mar 28 07:40:36 PDT 2012


 src/modules/alsa/alsa-mixer.c       |    4 ++--
 src/modules/alsa/alsa-mixer.h       |    2 +-
 src/modules/alsa/alsa-sink.c        |    2 --
 src/modules/alsa/alsa-source.c      |    2 --
 src/modules/dbus/iface-core.c       |    2 +-
 src/modules/dbus/iface-device.c     |   10 +++++++---
 src/modules/module-device-manager.c |    4 +++-
 src/pulsecore/protocol-dbus.c       |    4 ++--
 src/pulsecore/sample-util.c         |    6 +-----
 src/utils/padsp.c                   |    1 +
 10 files changed, 18 insertions(+), 19 deletions(-)

New commits:
commit 1c134f45170df1832a982e4653a4054d53a08bf9
Author: Tanu Kaskinen <tanu.kaskinen at digia.com>
Date:   Wed Mar 28 14:47:20 2012 +0300

    dbus: Add assertions to get rid of warnings from Coverity.
    
    Coverity thinks that expected_method_sig can be NULL when
    it's dereferenced by pa_streq(). Adding assertions doesn't
    hurt here (in my opinion), and that should get rid of the
    warnings.

diff --git a/src/pulsecore/protocol-dbus.c b/src/pulsecore/protocol-dbus.c
index 03cebc1..adc1f38 100644
--- a/src/pulsecore/protocol-dbus.c
+++ b/src/pulsecore/protocol-dbus.c
@@ -360,7 +360,7 @@ static enum find_result_t find_handler_by_method(struct call_info *call_info) {
 
     PA_HASHMAP_FOREACH(call_info->iface_entry, call_info->obj_entry->interfaces, state) {
         if ((call_info->method_handler = pa_hashmap_get(call_info->iface_entry->method_handlers, call_info->method))) {
-            call_info->expected_method_sig = pa_hashmap_get(call_info->iface_entry->method_signatures, call_info->method);
+            pa_assert_se(call_info->expected_method_sig = pa_hashmap_get(call_info->iface_entry->method_signatures, call_info->method));
 
             if (pa_streq(call_info->method_sig, call_info->expected_method_sig))
                 return FOUND_METHOD;
@@ -469,7 +469,7 @@ static enum find_result_t find_handler(struct call_info *call_info) {
             return NO_SUCH_INTERFACE;
 
         else if ((call_info->method_handler = pa_hashmap_get(call_info->iface_entry->method_handlers, call_info->method))) {
-            call_info->expected_method_sig = pa_hashmap_get(call_info->iface_entry->method_signatures, call_info->method);
+            pa_assert_se(call_info->expected_method_sig = pa_hashmap_get(call_info->iface_entry->method_signatures, call_info->method));
 
             if (!pa_streq(call_info->method_sig, call_info->expected_method_sig))
                 return INVALID_METHOD_SIG;

commit 87479307477496d1e3f6720ed9c15d1c890e9b73
Author: Tanu Kaskinen <tanu.kaskinen at digia.com>
Date:   Wed Mar 28 12:27:26 2012 +0300

    device-manager: Add an assertion to get rid of a warning from Coverity.
    
    Coverity thinks that device_name can be NULL when it's
    dereferenced by strcmp. Adding an assertion doesn't hurt
    here (in my opinion), and that should get rid of the
    warning.

diff --git a/src/modules/module-device-manager.c b/src/modules/module-device-manager.c
index 2ce4c78..e11921d 100644
--- a/src/modules/module-device-manager.c
+++ b/src/modules/module-device-manager.c
@@ -576,7 +576,7 @@ static void update_highest_priority_device_indexes(struct userdata *u, const cha
             struct entry *e;
 
             name = pa_xstrndup(key.data, key.size);
-            device_name = get_name(name, prefix);
+            pa_assert_se(device_name = get_name(name, prefix));
 
             if ((e = entry_read(u, name))) {
                 for (uint32_t i = 0; i < NUM_ROLES; ++i) {

commit 9d640e4491772e9edacc802ac72ed49d1f86176f
Author: Tanu Kaskinen <tanu.kaskinen at digia.com>
Date:   Mon Mar 26 14:52:27 2012 +0300

    dbus: Add an assertion to get rid of a warning from Coverity.
    
    Coverity thinks that sample can be NULL when it's
    dereferenced after this line. Adding an assertion doesn't
    hurt here (in my opinion), and that should get rid of the
    warning.

diff --git a/src/modules/dbus/iface-core.c b/src/modules/dbus/iface-core.c
index 58abcb9..97a46a5 100644
--- a/src/modules/dbus/iface-core.c
+++ b/src/modules/dbus/iface-core.c
@@ -1401,7 +1401,7 @@ static void handle_upload_sample(DBusConnection *conn, DBusMessage *msg, void *u
         goto finish;
     }
 
-    sample = pa_idxset_get_by_index(c->core->scache, idx);
+    pa_assert_se(sample = pa_idxset_get_by_index(c->core->scache, idx));
 
     if (n_volume_entries > 0) {
         sample->volume.channels = n_channels;

commit 5a26404f12045c37988f53e2cd25004539476ca7
Author: Tanu Kaskinen <tanu.kaskinen at digia.com>
Date:   Mon Mar 26 14:35:30 2012 +0300

    alsa: Fix SND_MIXER_SCHN_LAST related stuff.
    
    Valid channel id range is from 0 to SND_MIXER_SCHN_LAST,
    inclusive, so the size of the masks array in pa_alsa_element
    has to be SND_MIXER_SCHN_LAST + 1. Similar "too small"
    arrays were also in alsa-sink's and alsa-source's userdata,
    but actually those arrays were not used at all so they were
    removed.
    
    element_is_subset() in alsa-mixer.c skipped the last channel
    id when iterating the element masks array; that's now fixed
    as well.
    
    Thanks to David Henningsson for spotting the too small
    arrays in alsa-sink and alsa-source and the
    element_is_subset() problem.

diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index ba31c79..abb12ee 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -1577,7 +1577,7 @@ static int element_probe(pa_alsa_element *e, snd_mixer_t *m) {
                          *
                          * The definition of e->masks is
                          *
-                         *     pa_channel_position_mask_t masks[SND_MIXER_SCHN_LAST][2];
+                         *     pa_channel_position_mask_t masks[SND_MIXER_SCHN_LAST + 1][2];
                          *
                          * Since the array size is fixed at 2, we obviously
                          * don't support elements with more than two
@@ -3105,7 +3105,7 @@ static pa_bool_t element_is_subset(pa_alsa_element *a, pa_alsa_element *b, snd_m
             /* If override-maps are different, they're not subsets */
             if (a->n_channels != b->n_channels)
                 return FALSE;
-            for (s = 0; s < SND_MIXER_SCHN_LAST; s++)
+            for (s = 0; s <= SND_MIXER_SCHN_LAST; s++)
                 if (a->masks[s][a->n_channels-1] != b->masks[s][b->n_channels-1]) {
                     pa_log_debug("Element %s is not a subset - mask a: 0x%" PRIx64 ", mask b: 0x%" PRIx64 ", at channel %d",
                         a->alsa_name, a->masks[s][a->n_channels-1], b->masks[s][b->n_channels-1], s);
diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
index 59bd3fb..fdcff76 100644
--- a/src/modules/alsa/alsa-mixer.h
+++ b/src/modules/alsa/alsa-mixer.h
@@ -145,7 +145,7 @@ struct pa_alsa_element {
     long volume_limit; /* -1 for no configured limit */
     double min_dB, max_dB;
 
-    pa_channel_position_mask_t masks[SND_MIXER_SCHN_LAST][2];
+    pa_channel_position_mask_t masks[SND_MIXER_SCHN_LAST + 1][2];
     unsigned n_channels;
 
     pa_channel_position_mask_t merged_mask;
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index c88f4cf..ea5188c 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -140,8 +140,6 @@ struct userdata {
 
     pa_rtpoll_item *alsa_rtpoll_item;
 
-    snd_mixer_selem_channel_id_t mixer_map[SND_MIXER_SCHN_LAST];
-
     pa_smoother *smoother;
     uint64_t write_count;
     uint64_t since_start;
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 3e59340..2680302 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -127,8 +127,6 @@ struct userdata {
 
     pa_rtpoll_item *alsa_rtpoll_item;
 
-    snd_mixer_selem_channel_id_t mixer_map[SND_MIXER_SCHN_LAST];
-
     pa_smoother *smoother;
     uint64_t read_count;
     pa_usec_t smoother_interval;

commit 191d60688d18591acb3b0ddeafb870a2b1007429
Author: Tanu Kaskinen <tanu.kaskinen at digia.com>
Date:   Fri Mar 23 11:36:39 2012 +0200

    device-manager: Fix a memory leak.

diff --git a/src/modules/module-device-manager.c b/src/modules/module-device-manager.c
index d7f30c6..2ce4c78 100644
--- a/src/modules/module-device-manager.c
+++ b/src/modules/module-device-manager.c
@@ -1443,6 +1443,8 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
             pa_xfree(devices[i]);
         }
 
+        pa_xfree(devices);
+
         if (!first) {
             trigger_save(u);
 

commit 2f7a586a23a7e8c595c4a0a1d11b75669953d794
Author: Tanu Kaskinen <tanu.kaskinen at digia.com>
Date:   Fri Mar 23 11:01:22 2012 +0200

    sample-util: Remove redundant check from pa_volume_memchunk.
    
    Add also an assertion for the sample spec validity. The
    existing code already does crash in case of an invalid
    sample spec, but the error would not be as obvious: the
    crash would happen due to a divide-by-zero operation in
    pa_frame_aligned().

diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c
index f2017aa..38201b2 100644
--- a/src/pulsecore/sample-util.c
+++ b/src/pulsecore/sample-util.c
@@ -721,6 +721,7 @@ void pa_volume_memchunk(
 
     pa_assert(c);
     pa_assert(spec);
+    pa_assert(pa_sample_spec_valid(spec));
     pa_assert(pa_frame_aligned(c->length, spec));
     pa_assert(volume);
 
@@ -735,11 +736,6 @@ void pa_volume_memchunk(
         return;
     }
 
-    if (spec->format < 0 || spec->format >= PA_SAMPLE_MAX) {
-      pa_log_warn("Unable to change volume of format");
-      return;
-    }
-
     do_volume = pa_get_volume_func(spec->format);
     pa_assert(do_volume);
 

commit c2c5e044cce27a25261d2603cc0a9e72806d3972
Author: Tanu Kaskinen <tanu.kaskinen at digia.com>
Date:   Fri Mar 23 10:11:21 2012 +0200

    padsp: Fix a double-free bug.

diff --git a/src/utils/padsp.c b/src/utils/padsp.c
index a8bc8d2..f6a3520 100644
--- a/src/utils/padsp.c
+++ b/src/utils/padsp.c
@@ -1444,6 +1444,7 @@ static int sndstat_open(int flags, int *_errno) {
 
     unlink(fn);
     pa_xfree(fn);
+    fn = NULL;
 
     if (write(fd, sndstat, sizeof(sndstat) -1) != sizeof(sndstat)-1) {
         *_errno = errno;

commit bce720c85dc5bade8b279af316bb112937a1e15d
Author: Tanu Kaskinen <tanu.kaskinen at digia.com>
Date:   Fri Mar 23 09:59:17 2012 +0200

    dbus: Fix device latency querying.

diff --git a/src/modules/dbus/iface-device.c b/src/modules/dbus/iface-device.c
index df64d36..a5af730 100644
--- a/src/modules/dbus/iface-device.c
+++ b/src/modules/dbus/iface-device.c
@@ -598,13 +598,17 @@ static void handle_get_latency(DBusConnection *conn, DBusMessage *msg, void *use
     pa_assert(msg);
     pa_assert(d);
 
-    if (d->type == PA_DEVICE_TYPE_SINK && !(d->sink->flags & PA_SINK_LATENCY))
+    if (d->type == PA_DEVICE_TYPE_SINK && !(d->sink->flags & PA_SINK_LATENCY)) {
         pa_dbus_send_error(conn, msg, PA_DBUS_ERROR_NO_SUCH_PROPERTY,
                            "Sink %s doesn't support latency querying.", d->sink->name);
-    else if (d->type == PA_DEVICE_TYPE_SOURCE && !(d->source->flags & PA_SOURCE_LATENCY))
+        return;
+    }
+
+    if (d->type == PA_DEVICE_TYPE_SOURCE && !(d->source->flags & PA_SOURCE_LATENCY)) {
         pa_dbus_send_error(conn, msg, PA_DBUS_ERROR_NO_SUCH_PROPERTY,
                            "Source %s doesn't support latency querying.", d->source->name);
-    return;
+        return;
+    }
 
     latency = (d->type == PA_DEVICE_TYPE_SINK) ? pa_sink_get_latency(d->sink) : pa_source_get_latency(d->source);
 



More information about the pulseaudio-commits mailing list