core: Correctly handle unset port in configs
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Wed, 2 Sep 2009 19:09:15 +0000 (22:09 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Wed, 2 Sep 2009 19:09:15 +0000 (22:09 +0300)
src/rygel/rygel-cmdline-config.vala
src/rygel/rygel-user-config.vala

index a6a77eb..01931cd 100644 (file)
@@ -34,7 +34,7 @@ public errordomain Rygel.CmdlineConfigError {
  */
 public class Rygel.CmdlineConfig : GLib.Object, Configuration {
     private static string host_ip;
-    private static int port;
+    private static int port = -1;
 
     private static bool no_transcoding;
     private static bool no_mp3_trans;
@@ -117,6 +117,10 @@ public class Rygel.CmdlineConfig : GLib.Object, Configuration {
     }
 
     public int get_port () throws GLib.Error {
+        if (this.port == -1) {
+            throw new ConfigurationError.NO_VALUE_SET ("No value available");
+        }
+
         return port;
     }
 
index 5508261..6802619 100644 (file)
@@ -210,7 +210,7 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
                         throws GLib.Error {
         int val = this.key_file.get_integer (section, key);
 
-        if (val < min || val > max) {
+        if (val == 0 || val < min || val > max) {
             throw new ConfigurationError.VALUE_OUT_OF_RANGE (
                                         "Value of '%s' out of range", key);
         }