[Xfce4-commits] <xfce4-weather-plugin:master> Fix uninitialized variables and switch statements without default values.

Harald Judt noreply at xfce.org
Tue Mar 5 17:16:01 CET 2013


Updating branch refs/heads/master
         to 808242e32c2ce0708463cb47075b3becdef44c1c (commit)
       from a4c62fbb977f823ffb7d13c4793af187e14fc94f (commit)

commit 808242e32c2ce0708463cb47075b3becdef44c1c
Author: Harald Judt <h.judt at gmx.at>
Date:   Tue Mar 5 17:10:52 2013 +0100

    Fix uninitialized variables and switch statements without default values.

 panel-plugin/weather-config.c |   31 ++++++++++++++++---------------
 panel-plugin/weather-data.c   |    5 ++++-
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index 9be3467..c36a5f9 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -384,22 +384,23 @@ setup_altitude(xfceweather_dialog *dialog)
                                     G_CALLBACK(spin_alt_value_changed),
                                     dialog);
     switch (dialog->pd->units->altitude) {
-    case METERS:
+    case FEET:
         gtk_label_set_text(GTK_LABEL(dialog->label_alt_unit),
-                           _("meters"));
+                           _("feet"));
         gtk_spin_button_set_range(GTK_SPIN_BUTTON(dialog->spin_alt),
-                                  -420, 10000);
+                                  -1378.0, 32808);
         gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->spin_alt),
-                                  (gdouble) (dialog->pd->msl));
+                                  (gdouble) dialog->pd->msl / 0.3048);
         break;
 
-    case FEET:
+    case METERS:
+    default:
         gtk_label_set_text(GTK_LABEL(dialog->label_alt_unit),
-                           _("feet"));
+                           _("meters"));
         gtk_spin_button_set_range(GTK_SPIN_BUTTON(dialog->spin_alt),
-                                  -1378.0, 32808);
+                                  -420, 10000);
         gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->spin_alt),
-                                  (gdouble) dialog->pd->msl / 0.3048);
+                                  (gdouble) (dialog->pd->msl));
         break;
     }
     g_signal_handlers_unblock_by_func(dialog->spin_alt,
@@ -626,7 +627,7 @@ create_location_page(xfceweather_dialog *dialog)
 static void
 combo_unit_temperature_set_tooltip(GtkWidget *combo)
 {
-    gchar *text;
+    gchar *text = NULL;
     gint value = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
 
     switch (value) {
@@ -685,7 +686,7 @@ combo_unit_temperature_changed(GtkWidget *combo,
 static void
 combo_unit_pressure_set_tooltip(GtkWidget *combo)
 {
-    gchar *text;
+    gchar *text = NULL;
     gint value = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
 
     switch (value) {
@@ -743,7 +744,7 @@ combo_unit_pressure_changed(GtkWidget *combo,
 static void
 combo_unit_windspeed_set_tooltip(GtkWidget *combo)
 {
-    gchar *text;
+    gchar *text = NULL;
     gint value = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
 
     switch (value) {
@@ -793,7 +794,7 @@ combo_unit_windspeed_changed(GtkWidget *combo,
 static void
 combo_unit_precipitations_set_tooltip(GtkWidget *combo)
 {
-    gchar *text;
+    gchar *text = NULL;
     gint value = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
 
     switch (value) {
@@ -831,7 +832,7 @@ combo_unit_precipitations_changed(GtkWidget *combo,
 static void
 combo_unit_altitude_set_tooltip(GtkWidget *combo)
 {
-    gchar *text;
+    gchar *text = NULL;
     gint value = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
 
     switch (value) {
@@ -873,7 +874,7 @@ combo_unit_altitude_changed(GtkWidget *combo,
 static void
 combo_apparent_temperature_set_tooltip(GtkWidget *combo)
 {
-    gchar *text;
+    gchar *text = NULL;
     gint value = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
 
     switch (value) {
@@ -1114,7 +1115,7 @@ combo_tooltip_style_changed(GtkWidget *combo,
 static void
 combo_forecast_layout_set_tooltip(GtkWidget *combo)
 {
-    gchar *text;
+    gchar *text = NULL;
     gint value = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
 
     switch (value) {
diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
index 5615fb4..714cce4 100644
--- a/panel-plugin/weather-data.c
+++ b/panel-plugin/weather-data.c
@@ -259,6 +259,9 @@ calc_apparent_temperature(const xml_location *loc,
            Forecasting. 13, 1998, S. 1187–1193 */
         return 1.41 - 1.162 * windspeed + 0.980 * temp
             + 0.0124 * windspeed * windspeed + 0.0185 * windspeed * temp;
+
+    default:
+        return temp;
     }
 }
 
@@ -1127,7 +1130,7 @@ make_forecast_data(xml_weather *wd,
     xml_time *ts1, *ts2, *interval = NULL;
     struct tm point_tm, start_tm, end_tm, tm1, tm2;
     time_t point_t, start_t, end_t;
-    gint min, max, point, i, j;
+    gint min = 0, max = 0, point = 0, i, j;
 
     g_assert(wd != NULL);
     if (G_UNLIKELY(wd == NULL))


More information about the Xfce4-commits mailing list