[goffice] Compilation: fix clang warnings.



commit 9ce90aa3480460af8342ad75d4eea40013b30988
Author: Morten Welinder <terra gnome org>
Date:   Sat Feb 16 16:25:33 2013 -0500

    Compilation: fix clang warnings.
    
    One of them pointing out a real bug.

 ChangeLog                        |    5 +++++
 goffice/graph/gog-guru.c         |    5 +++--
 goffice/graph/gog-series.c       |    2 +-
 goffice/gtk/go-3d-rotation-sel.c |    2 +-
 goffice/gtk/go-color-palette.c   |    6 +++---
 goffice/gtk/go-format-sel.c      |    2 +-
 goffice/gtk/go-rotation-sel.c    |    2 +-
 goffice/math/go-regression.c     |    2 +-
 goffice/utils/go-gradient.c      |    3 ++-
 goffice/utils/go-line.c          |    6 +++---
 goffice/utils/go-marker.c        |    3 ++-
 goffice/utils/go-pattern.c       |    3 ++-
 12 files changed, 25 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 07419ec..aa5f74f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-02-16  Morten Welinder  <terra gnome org>
+
+       * goffice/math/go-regression.c (general_linear_regression): memset
+       the right size.
+
 2013-02-15  Morten Welinder  <terra gnome org>
 
        * goffice/gtk/go-selector.c (go_selector_new): Remove check for
diff --git a/goffice/graph/gog-guru.c b/goffice/graph/gog-guru.c
index 254a8e0..37234f7 100644
--- a/goffice/graph/gog-guru.c
+++ b/goffice/graph/gog-guru.c
@@ -1161,8 +1161,9 @@ typesel_set_selection_color (GraphGuruTypeSelector *typesel)
 
        gtk_style_context_get_background_color (style_context,
                                                gtk_widget_has_focus (typesel->canvas)
-                                                                                       ? GTK_STATE_SELECTED 
: GTK_STATE_ACTIVE,
-                                            &rgba);
+                                               ? GTK_STATE_FLAG_SELECTED
+                                               : GTK_STATE_FLAG_ACTIVE,
+                                               &rgba);
        if (rgba.alpha > 0.40)
                                rgba.alpha = 0.40;
        select_color = GO_COLOR_FROM_GDK_RGBA (rgba);
diff --git a/goffice/graph/gog-series.c b/goffice/graph/gog-series.c
index ade93c3..f47d451 100644
--- a/goffice/graph/gog-series.c
+++ b/goffice/graph/gog-series.c
@@ -1328,7 +1328,7 @@ gog_series_populate_fill_type_combo (GogSeries const *series, GtkComboBox *combo
        gtk_list_store_clear (GTK_LIST_STORE (gtk_combo_box_get_model (combo)));
        for (i = 0; series_klass->valid_fill_type_list[i] != GOG_SERIES_FILL_TYPE_INVALID; i++) {
                fill_type = series_klass->valid_fill_type_list[i];
-               if (fill_type >= 0 && fill_type < GOG_SERIES_FILL_TYPE_INVALID) {
+               if (fill_type < GOG_SERIES_FILL_TYPE_INVALID) {
                        go_gtk_combo_box_append_text (combo, _(_fill_type_infos[fill_type].label));
                        if (fill_type == series->fill_type)
                                gtk_combo_box_set_active (combo, i);
diff --git a/goffice/gtk/go-3d-rotation-sel.c b/goffice/gtk/go-3d-rotation-sel.c
index 1a4db4a..c6c258b 100644
--- a/goffice/gtk/go-3d-rotation-sel.c
+++ b/goffice/gtk/go-3d-rotation-sel.c
@@ -195,7 +195,7 @@ cb_rotate_canvas_realize (GocCanvas *canvas, GO3DRotationSel *g3d)
        GdkRGBA color = {1., 1., 1., 1.};
 
        gtk_widget_override_background_color (GTK_WIDGET (canvas),
-                                             GTK_STATE_NORMAL, &color);
+                                             GTK_STATE_FLAG_NORMAL, &color);
 
        for (i = 0; i < 6; ++i) {
                g3d->cube_polygons[i] = goc_item_new (group,
diff --git a/goffice/gtk/go-color-palette.c b/goffice/gtk/go-color-palette.c
index 08823e1..c639e4a 100644
--- a/goffice/gtk/go-color-palette.c
+++ b/goffice/gtk/go-color-palette.c
@@ -269,7 +269,7 @@ cb_history_changed (GOColorPalette *pal)
        GOColorGroup *group = pal->group;
 
        for (i = 0 ; i < GO_COLOR_GROUP_HISTORY_SIZE ; i++)
-               gtk_widget_override_background_color (pal->swatches [i], GTK_STATE_NORMAL,
+               gtk_widget_override_background_color (pal->swatches [i], GTK_STATE_FLAG_NORMAL,
                        go_color_to_gdk_rgba (group->history[i], &gdk));
 #if 0
        if (next_swatch != NULL) {
@@ -300,7 +300,7 @@ swatch_activated (GOColorPalette *pal, GtkBin *button)
        g_return_if_fail (swatch != NULL);
 
        style_ctx = gtk_widget_get_style_context (swatch);
-       gtk_style_context_get_background_color (style_ctx, GTK_STATE_NORMAL, &rgba);
+       gtk_style_context_get_background_color (style_ctx, GTK_STATE_FLAG_NORMAL, &rgba);
        set_color (pal, GO_COLOR_FROM_GDK_RGBA (rgba),
                   FALSE, TRUE, FALSE);
 }
@@ -353,7 +353,7 @@ go_color_palette_button_new (GOColorPalette *pal, GtkGrid *grid,
        swatch = gtk_drawing_area_new ();
        g_signal_connect (G_OBJECT (swatch), "draw", G_CALLBACK (draw_color_cb),
                          GUINT_TO_POINTER (color_name->color));
-       gtk_widget_override_background_color (swatch, GTK_STATE_NORMAL,
+       gtk_widget_override_background_color (swatch, GTK_STATE_FLAG_NORMAL,
                go_color_to_gdk_rgba (color_name->color, &gdk));
        gtk_widget_set_size_request (swatch, COLOR_PREVIEW_WIDTH, COLOR_PREVIEW_HEIGHT);
 
diff --git a/goffice/gtk/go-format-sel.c b/goffice/gtk/go-format-sel.c
index 48a7f79..ecade1b 100644
--- a/goffice/gtk/go-format-sel.c
+++ b/goffice/gtk/go-format-sel.c
@@ -1517,7 +1517,7 @@ nfs_init (GOFormatSel *gfs)
                /* request width in number of chars */
                context = gtk_widget_get_pango_context (w);
                metrics = pango_context_get_metrics (context,
-                                                    gtk_style_context_get_font (gtk_widget_get_style_context 
(w), GTK_STATE_NORMAL),
+                                                    gtk_style_context_get_font (gtk_widget_get_style_context 
(w), GTK_STATE_FLAG_NORMAL),
                                                     pango_context_get_language (context));
                char_width = pango_font_metrics_get_approximate_char_width (metrics);
                gtk_widget_set_size_request (w, PANGO_PIXELS (char_width) * FORMAT_PREVIEW_MAX, -1);
diff --git a/goffice/gtk/go-rotation-sel.c b/goffice/gtk/go-rotation-sel.c
index 42b613c..fd8fb87 100644
--- a/goffice/gtk/go-rotation-sel.c
+++ b/goffice/gtk/go-rotation-sel.c
@@ -103,7 +103,7 @@ cb_rotate_canvas_realize (GocCanvas *canvas, GORotationSel *grs)
        double x0 = grs->full? 100.: 15.;
 
        gtk_widget_override_background_color (GTK_WIDGET (canvas),
-                                             GTK_STATE_NORMAL, &color);
+                                             GTK_STATE_FLAG_NORMAL, &color);
 
        for (i = 0 ; i <= maxint ; i++) {
                double rad = (i-6) * M_PI / 12.;
diff --git a/goffice/math/go-regression.c b/goffice/math/go-regression.c
index 9cb2c75..75c4af5 100644
--- a/goffice/math/go-regression.c
+++ b/goffice/math/go-regression.c
@@ -884,7 +884,7 @@ SUFFIX(general_linear_regression) (CONSTMATRIX xssT, int n,
        if (!has_stat)
                stat_ = SUFFIX(go_regression_stat_new)();
 
-       memset (stat_, 0, sizeof (stat_));
+       memset (stat_, 0, sizeof (*stat_));
 
        if (n > m) {
                regerr = GO_REG_not_enough_data;
diff --git a/goffice/utils/go-gradient.c b/goffice/utils/go-gradient.c
index 887e53f..bd478cd 100644
--- a/goffice/utils/go-gradient.c
+++ b/goffice/utils/go-gradient.c
@@ -85,6 +85,7 @@ go_gradient_dir_from_str (char const *name)
 char const *
 go_gradient_dir_as_str (GOGradientDirection dir)
 {
-       return (dir < 0 || dir >= GO_GRADIENT_MAX) ? "gradient"
+       return (unsigned)dir >= GO_GRADIENT_MAX
+               ? "gradient"
                : grad_dir_names[dir];
 }
diff --git a/goffice/utils/go-line.c b/goffice/utils/go-line.c
index 833e205..fb42077 100644
--- a/goffice/utils/go-line.c
+++ b/goffice/utils/go-line.c
@@ -262,7 +262,7 @@ go_line_dash_get_length (GOLineDashType type)
 {
        GOLineDashDesc const *dash_desc;
 
-       if (type < 0 || type >= G_N_ELEMENTS (line_dashes))
+       if ((unsigned)type >= G_N_ELEMENTS (line_dashes))
                return 1.0;
 
        dash_desc = line_dashes[type].dash_desc;
@@ -285,7 +285,7 @@ go_line_dash_get_sequence (GOLineDashType type, double scale)
        GOLineDashSequence *sequence = NULL;
        GOLineDashDesc const *dash_desc;
 
-       if (type < 0 || type >= G_N_ELEMENTS (line_dashes))
+       if ((unsigned)type >= G_N_ELEMENTS (line_dashes))
                return NULL;
 
        dash_desc = line_dashes[type].dash_desc;
@@ -430,7 +430,7 @@ static struct {
        GOArrowType typ;
        char const *name;
 } arrow_types[] = {
-       { GO_LINE_NONE, "none" },
+       { GO_ARROW_NONE, "none" },
        { GO_ARROW_KITE, "kite" },
        { GO_ARROW_OVAL, "oval" }
 };
diff --git a/goffice/utils/go-marker.c b/goffice/utils/go-marker.c
index 8b6ca54..38ff3e0 100644
--- a/goffice/utils/go-marker.c
+++ b/goffice/utils/go-marker.c
@@ -141,7 +141,8 @@ go_marker_shape_from_str (char const *str)
 char const *
 go_marker_shape_as_str (GOMarkerShape shape)
 {
-       return (shape < 0 || shape >= GO_MARKER_MAX) ? "pattern"
+       return (unsigned)shape >= GO_MARKER_MAX
+               ? "pattern"
                : marker_shapes[shape].str;
 }
 
diff --git a/goffice/utils/go-pattern.c b/goffice/utils/go-pattern.c
index 425c6a4..abc2e93 100644
--- a/goffice/utils/go-pattern.c
+++ b/goffice/utils/go-pattern.c
@@ -123,7 +123,8 @@ go_pattern_from_str (char const *str)
 char const *
 go_pattern_as_str (GOPatternType pattern)
 {
-       return (pattern < 0 || pattern >= GO_PATTERN_MAX) ?  "none"
+       return (unsigned)pattern >= GO_PATTERN_MAX
+               ? "none"
                : go_patterns[pattern].str;
 }
 


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