[gnome-dvb-daemon] Make sure out parameters are always assigned a value



commit fd8667dad30f5814a3d6b3ab8b6328c960e39101
Author: Sebastian PÃlsterl <sebp k-d-w org>
Date:   Thu Sep 22 14:59:31 2011 +0200

    Make sure out parameters are always assigned a value

 src/ChannelList.vala                             |    1 +
 src/EventStorage.vala                            |    2 +-
 src/Recorder.vala                                |   15 ++++++++++---
 src/RecordingsStore.vala                         |   20 ++++++++++++++---
 src/Schedule.vala                                |   24 ++++++++++++++-------
 src/Utils.vala                                   |    1 +
 src/database/sqlite/SqliteConfigTimersStore.vala |    4 +++
 7 files changed, 50 insertions(+), 17 deletions(-)
---
diff --git a/src/ChannelList.vala b/src/ChannelList.vala
index e523643..1787c5e 100644
--- a/src/ChannelList.vala
+++ b/src/ChannelList.vala
@@ -277,6 +277,7 @@ namespace DVB {
                     channel_group_id);
             } catch (SqlError e) {
                 log.error ("%s", e.message);
+                channel_ids = new uint[0];
                 return false;
             }
 
diff --git a/src/EventStorage.vala b/src/EventStorage.vala
index f321da3..391c1ee 100644
--- a/src/EventStorage.vala
+++ b/src/EventStorage.vala
@@ -77,7 +77,7 @@ namespace DVB {
         }
 
         public EventStorage () {
-            this.events = new Sequence<EventElement> (EventElement.destroy);
+            this.events = new Sequence<EventElement> ();
             this.event_id_map = new HashMap<uint, unowned SequenceIter<EventElement>> ();
         }
 
diff --git a/src/Recorder.vala b/src/Recorder.vala
index ab6c310..8073ade 100644
--- a/src/Recorder.vala
+++ b/src/Recorder.vala
@@ -138,11 +138,14 @@ namespace DVB {
             }
             return ret;
         }
-        
-        public bool add_timer (Timer new_timer, out uint32 timer_id) {
-            if (new_timer.has_expired()) return false;
 
+        public bool add_timer (Timer new_timer, out uint32 timer_id) {
             bool ret = false;
+            timer_id = 0;
+
+            if (new_timer.has_expired())
+                return ret;
+
             lock (this.timers) {
                 bool has_conflict = false;
                 int conflict_count = 0;
@@ -363,6 +366,8 @@ namespace DVB {
                 if (this.timers.has_key (timer_id)) {
                     duration = this.timers.get(timer_id).Duration;
                     ret = true;
+                } else {
+                    duration = 0;
                 }
             }
             return ret;
@@ -431,9 +436,11 @@ namespace DVB {
                     Event? event = t.Channel.Schedule.get_event (t.EventID);
                     title = (event == null) ? "" : event.name;
                     ret = true;
+                } else {
+                    title = "";
                 }
             }
-            if (!ret) title = "";
+
             return ret;
         }
 
diff --git a/src/RecordingsStore.vala b/src/RecordingsStore.vala
index 2daf6a1..f41464f 100644
--- a/src/RecordingsStore.vala
+++ b/src/RecordingsStore.vala
@@ -135,9 +135,11 @@ namespace DVB {
                 if (this.recordings.has_key (rec_id)) {
                     location = this.recordings.get(rec_id).Location.get_uri ();
                     ret = true;
+                } else {
+                    location = "";
                 }
             }
-            if (!ret) location = "";
+
             return ret;
         }
         
@@ -154,9 +156,11 @@ namespace DVB {
                     string val = this.recordings.get(rec_id).Name;
                     name = (val == null) ? "" : val;
                     ret = true;
+                } else {
+                    name = "";
                 }
             }
-            if (!ret) name = "";
+
             return ret;
         }
         
@@ -173,9 +177,11 @@ namespace DVB {
                     string val = this.recordings.get(rec_id).Description;
                     description = (val == null) ? "" : val;
                     ret = true;
+                } else {
+                    description = "";
                 }
             }
-            if (!ret) description = "";
+
             return ret;
         }
         
@@ -210,6 +216,8 @@ namespace DVB {
                 if (this.recordings.has_key (rec_id)) {
                     timestamp = (int64)this.recordings.get(rec_id).StartTime.mktime ();
                     ret = true;
+                } else {
+                    timestamp = 0;
                 }
             }
             
@@ -227,6 +235,8 @@ namespace DVB {
                 if (this.recordings.has_key (rec_id)) {
                     length = this.recordings.get(rec_id).Length;
                     ret = true;
+                } else {
+                    length = 0;
                 }
             }
            
@@ -274,9 +284,11 @@ namespace DVB {
                     Recording rec = this.recordings.get (rec_id);
                     name = rec.ChannelName;
                     ret = true;
+                } else {
+                    name = "";
                 }
             }
-            if (!ret) name = "";
+
             return ret;
         }
         
diff --git a/src/Schedule.vala b/src/Schedule.vala
index 164c745..652625a 100644
--- a/src/Schedule.vala
+++ b/src/Schedule.vala
@@ -341,6 +341,7 @@ namespace DVB {
                 throws DBusError
         {
             bool ret;
+            event_info = EventInfo();
             
             lock (this.events) {        
                 if (this.events.contains_event_with_id (event_id)) {
@@ -396,6 +397,7 @@ namespace DVB {
         
         public bool GetName (uint32 event_id, out string name) throws DBusError {
             bool ret = false;
+            name = "";
 
             lock (this.events) {        
                 if (this.events.contains_event_with_id (event_id)) {
@@ -408,7 +410,7 @@ namespace DVB {
                     log.debug ("No event with id %u", event_id);
                 }
             }
-            if (!ret) name = "";
+
             return ret;
         }
         
@@ -416,6 +418,7 @@ namespace DVB {
                 out string description) throws DBusError
         {
             bool ret = false;
+            description = "";
             
             lock (this.events) {
                 if (this.events.contains_event_with_id (event_id)) {
@@ -428,7 +431,7 @@ namespace DVB {
                     log.debug ("No event with id %u", event_id);
                 }
             }
-            if (!ret) description = "";
+
             return ret;
         }
         
@@ -436,6 +439,7 @@ namespace DVB {
                 out string description) throws DBusError
         {
             bool ret = false;
+            description = "";
             
             lock (this.events) {
                 if (this.events.contains_event_with_id (event_id)) {
@@ -448,7 +452,7 @@ namespace DVB {
                     log.debug ("No event with id %u", event_id);
                 }
             }
-            if (!ret) description = "";
+
             return ret;
         }
         
@@ -456,6 +460,7 @@ namespace DVB {
                 throws DBusError
         {
             bool ret = false;
+            duration = 0;
         
             lock (this.events) {
                 if (this.events.contains_event_with_id (event_id)) {
@@ -468,7 +473,7 @@ namespace DVB {
                     log.debug ("No event with id %u", event_id);
                 }
             }
-            
+
             return ret;
         }
         
@@ -476,6 +481,7 @@ namespace DVB {
                 throws DBusError
         {
             bool ret = false;
+            start_time = new uint[0];
         
             lock (this.events) {
                 if (this.events.contains_event_with_id (event_id)) {
@@ -487,11 +493,8 @@ namespace DVB {
                     }
                 } else {
                     log.debug ("No event with id %u", event_id);
-                    start_time = new uint[] {};
                 }
             }
-
-            if (!ret) start_time = new uint[0];
             
             return ret;
         }
@@ -500,6 +503,8 @@ namespace DVB {
                 throws DBusError
         {
             bool ret = false;
+            timestamp = 0;
+
             lock (this.events) {
                 if (this.events.contains_event_with_id (event_id)) {
                     Event? event = this.get_extended_event_by_id (event_id);
@@ -510,6 +515,7 @@ namespace DVB {
                     }
                 }
             }
+
             return ret;
         }
         
@@ -517,6 +523,7 @@ namespace DVB {
                 throws DBusError
         {
             bool ret = false;
+            running = false;
         
             lock (this.events) {
                 if (this.events.contains_event_with_id (event_id)) {
@@ -537,6 +544,7 @@ namespace DVB {
                 throws DBusError
         {
             bool ret = false;
+            scrambled = false;
         
             lock (this.events) {
                 if (this.events.contains_event_with_id (event_id)) {
@@ -549,7 +557,7 @@ namespace DVB {
                     log.debug ("No event with id %u", event_id);
                 }
             }
-            
+
             return ret;
         }
 
diff --git a/src/Utils.vala b/src/Utils.vala
index db0a90f..efdd6ea 100644
--- a/src/Utils.vala
+++ b/src/Utils.vala
@@ -42,6 +42,7 @@ namespace DVB.Utils {
         
         if (eval == null) {
             Main.log.error ("Enum has no member named %s", name);
+            evalue = 0;
             return false;
         } else {
             evalue = eval.value;
diff --git a/src/database/sqlite/SqliteConfigTimersStore.vala b/src/database/sqlite/SqliteConfigTimersStore.vala
index 73a4252..1b1d280 100644
--- a/src/database/sqlite/SqliteConfigTimersStore.vala
+++ b/src/database/sqlite/SqliteConfigTimersStore.vala
@@ -353,6 +353,8 @@ namespace DVB.database.sqlite {
         }
 
         public bool get_parent_group (uint adapter, uint frontend, out uint group_id) throws SqlError {
+            group_id = 0;
+
             if (this.select_group_of_device_statement.bind_int (1, (int)adapter) != Sqlite.OK
                 || this.select_group_of_device_statement.bind_int (2, (int)frontend) != Sqlite.OK)
             {
@@ -563,6 +565,8 @@ namespace DVB.database.sqlite {
         }
 
         public bool add_channel_group (string name, out int channel_group_id) throws SqlError {
+            channel_group_id = -1;
+
             if (this.insert_channel_group_statement.bind_text (1, name) != Sqlite.OK)
             {
                 this.throw_last_error ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]