[pulseaudio-discuss] [PATCH 3/4] Initialise variables

Maarten Bosmans mkbosmans at gmail.com
Sat Aug 13 04:43:20 PDT 2011


These were detected using clang static analyzer.
---
 src/modules/bluetooth/bluetooth-util.c     |    4 ++--
 src/modules/module-esound-compat-spawnfd.c |    3 ++-
 src/modules/module-native-protocol-fd.c    |    4 ++--
 src/modules/module-null-source.c           |    1 +
 src/pulsecore/protocol-native.c            |    3 ++-
 5 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index b24fe7a..4b85ce9 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -916,7 +916,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
     } else if (dbus_message_is_signal(m, "org.bluez.MediaTransport", "PropertyChanged")) {
         pa_bluetooth_device *d;
-        pa_bluetooth_transport *t;
+        pa_bluetooth_transport *t = NULL;
         void *state = NULL;
         DBusMessageIter arg_i;
 
@@ -1112,7 +1112,7 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
     const char *path, *dev_path = NULL, *uuid = NULL;
     uint8_t *config = NULL;
     int size = 0;
-    pa_bool_t nrec;
+    pa_bool_t nrec = FALSE;
     enum profile p;
     DBusMessageIter args, props;
     DBusMessage *r;
diff --git a/src/modules/module-esound-compat-spawnfd.c b/src/modules/module-esound-compat-spawnfd.c
index 617d5a1..e2488fc 100644
--- a/src/modules/module-esound-compat-spawnfd.c
+++ b/src/modules/module-esound-compat-spawnfd.c
@@ -47,7 +47,8 @@ static const char* const valid_modargs[] = {
 
 int pa__init(pa_module*m) {
     pa_modargs *ma = NULL;
-    int ret = -1, fd = -1;
+    int ret = -1;
+    int32_t fd = -1;
     char x = 1;
 
     pa_assert(m);
diff --git a/src/modules/module-native-protocol-fd.c b/src/modules/module-native-protocol-fd.c
index eed0505..7021a26 100644
--- a/src/modules/module-native-protocol-fd.c
+++ b/src/modules/module-native-protocol-fd.c
@@ -48,7 +48,7 @@ static const char* const valid_modargs[] = {
 int pa__init(pa_module*m) {
     pa_iochannel *io;
     pa_modargs *ma;
-    int32_t fd;
+    int32_t fd = -1;
     int r = -1;
     pa_native_options *options = NULL;
 
@@ -59,7 +59,7 @@ int pa__init(pa_module*m) {
         goto finish;
     }
 
-    if (pa_modargs_get_value_s32(ma, "fd", &fd) < 0) {
+    if (pa_modargs_get_value_s32(ma, "fd", &fd) < 0 || fd < 0) {
         pa_log("Invalid file descriptor.");
         goto finish;
     }
diff --git a/src/modules/module-null-source.c b/src/modules/module-null-source.c
index b2981c3..b3ece7b 100644
--- a/src/modules/module-null-source.c
+++ b/src/modules/module-null-source.c
@@ -192,6 +192,7 @@ int pa__init(pa_module*m) {
     }
 
     ss = m->core->default_sample_spec;
+    map = m->core->default_channel_map;
     if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_DEFAULT) < 0) {
         pa_log("Invalid sample format specification or channel map");
         goto fail;
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 3ed9f1a..c71345e 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -1061,7 +1061,8 @@ static playback_stream* playback_stream_new(
     /* Note: This function takes ownership of the 'formats' param, so we need
      * to take extra care to not leak it */
 
-    playback_stream *s, *ssync;
+    playback_stream *ssync;
+    playback_stream *s = NULL;
     pa_sink_input *sink_input = NULL;
     pa_memchunk silence;
     uint32_t idx;
-- 
1.7.4.1



More information about the pulseaudio-discuss mailing list