[Xfce4-commits] <xfce4-weather-plugin:master> Get rid of arbitrary value in xfceweather_read_config().

Harald Judt noreply at xfce.org
Thu Jul 26 17:00:01 CEST 2012


Updating branch refs/heads/master
         to 76ff368964e80e359502e175eaa136449e7343e5 (commit)
       from 6b1a887e114da5eed4309ba11e26224670e628ca (commit)

commit 76ff368964e80e359502e175eaa136449e7343e5
Author: Harald Judt <h.judt at gmx.at>
Date:   Thu Jul 26 16:54:18 2012 +0200

    Get rid of arbitrary value in xfceweather_read_config().
    
    Simply abort reading when an invalid entry is found.

 panel-plugin/weather.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 35a75a7..41f540e 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -477,7 +477,7 @@ xfceweather_read_config(XfcePanelPlugin *plugin,
     const gchar *value;
     gchar *file;
     gchar label[10];
-    guint i;
+    guint label_count = 0;
     gint val;
 
     if (!(file = xfce_panel_plugin_lookup_rc_file(plugin)))
@@ -547,14 +547,13 @@ xfceweather_read_config(XfcePanelPlugin *plugin,
                               data->animation_transitions);
 
     data->labels = labels_clear(data->labels);
-    for (i = 0; i < 100 /* arbitrary */ ; ++i) {
-        g_snprintf(label, 10, "label%d", i);
+    val = 0;
+    while (val != -1) {
+        g_snprintf(label, 10, "label%d", label_count++);
 
         val = xfce_rc_read_int_entry(rc, label, -1);
         if (val >= 0)
             g_array_append_val(data->labels, val);
-        else
-            break;
     }
 
     xfce_rc_close(rc);


More information about the Xfce4-commits mailing list