[gnome-builder] gstyle/colorpicker plugin: fix Coverity defects
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] gstyle/colorpicker plugin: fix Coverity defects
- Date: Tue, 19 Jul 2016 17:33:25 +0000 (UTC)
commit 7375badf797deac4e59be6dcb68b94bd9d5a089c
Author: Sebastien Lafargue <slafargue gnome org>
Date: Tue Jul 19 19:29:45 2016 +0200
gstyle/colorpicker plugin: fix Coverity defects
Fix defects introduce by gstyle/colorpicker
and detected by Coverity at today date.
contrib/gstyle/gstyle-color-panel.c | 19 +++++++++++++------
contrib/gstyle/gstyle-color-plane.c | 5 +++--
contrib/gstyle/gstyle-color-widget.c | 2 +-
contrib/gstyle/gstyle-palette-widget.c | 4 ++--
contrib/gstyle/gstyle-palette.c | 6 ++++--
contrib/gstyle/gstyle-revealer.c | 7 ++++---
contrib/gstyle/gstyle-slidein.c | 9 ++-------
7 files changed, 29 insertions(+), 23 deletions(-)
---
diff --git a/contrib/gstyle/gstyle-color-panel.c b/contrib/gstyle/gstyle-color-panel.c
index b8920d2..1ba50f6 100644
--- a/contrib/gstyle/gstyle-color-panel.c
+++ b/contrib/gstyle/gstyle-color-panel.c
@@ -197,7 +197,9 @@ update_hsv_saturation_color_ramp (GstyleColorPanel *self,
GstyleColorScale *scale,
GdkRGBA *rgba)
{
- gdouble hue, saturation, value;
+ gdouble hue = 0.0;
+ gdouble saturation = 0.0;
+ gdouble value = 0.0;
guint32 *data;
GdkRGBA dst_rgba = {0};
@@ -220,7 +222,9 @@ update_hsv_value_color_ramp (GstyleColorPanel *self,
GstyleColorScale *scale,
GdkRGBA *rgba)
{
- gdouble hue, saturation, value;
+ gdouble hue = 0.0;
+ gdouble saturation = 0.0;
+ gdouble value = 0.0;
guint32 *data;
GdkRGBA dst_rgba = {0};
@@ -670,11 +674,14 @@ search_color_entry_changed_cb (GstyleColorPanel *self,
else
{
ar = gstyle_color_fuzzy_parse_color_string (str);
- sum += ar->len;
- for (gint i = 0; i < ar->len; ++i)
+ if (ar != NULL)
{
- color = g_ptr_array_index (ar, i);
- search_list_add_color (self, color);
+ sum += ar->len;
+ for (gint i = 0; i < ar->len; ++i)
+ {
+ color = g_ptr_array_index (ar, i);
+ search_list_add_color (self, color);
+ }
}
ar_palette = gstyle_palette_widget_fuzzy_parse_color_string (self->palette_widget, str);
diff --git a/contrib/gstyle/gstyle-color-plane.c b/contrib/gstyle/gstyle-color-plane.c
index c47ca96..aa59b16 100644
--- a/contrib/gstyle/gstyle-color-plane.c
+++ b/contrib/gstyle/gstyle-color-plane.c
@@ -934,7 +934,7 @@ update_cursor (GstyleColorPlane *self,
GstyleColorPlanePrivate *priv = gstyle_color_plane_get_instance_private (self);
gint left_spacing;
gint top_spacing;
- GstyleXYZ xyz;
+ GstyleXYZ xyz = {0};
g_assert (GSTYLE_IS_COLOR_PLANE (self));
@@ -1199,7 +1199,7 @@ gstyle_color_plane_set_rgba (GstyleColorPlane *self,
const GdkRGBA *rgba)
{
GstyleColorPlanePrivate *priv;
- GstyleXYZ xyz;
+ GstyleXYZ xyz = {0};
g_return_if_fail (GSTYLE_IS_COLOR_PLANE (self));
g_return_if_fail (rgba != NULL);
@@ -1419,6 +1419,7 @@ gstyle_color_plane_set_property (GObject *object,
rgba_p = &rgba;
gstyle_color_plane_set_rgba (self, rgba_p);
+ break;
case PROP_XYZ:
xyz_p = (GstyleXYZ *)g_value_get_boxed (value);
diff --git a/contrib/gstyle/gstyle-color-widget.c b/contrib/gstyle/gstyle-color-widget.c
index 864dca7..20be38a 100644
--- a/contrib/gstyle/gstyle-color-widget.c
+++ b/contrib/gstyle/gstyle-color-widget.c
@@ -221,7 +221,7 @@ gstyle_color_widget_on_drag_motion (GtkWidget *widget,
gtk_drag_highlight (widget);
drag_action = gdk_drag_context_get_actions (context);
- if (drag_action | GDK_ACTION_COPY)
+ if ((drag_action | GDK_ACTION_COPY) != 0)
{
gdk_drag_status (context, GDK_ACTION_COPY, time);
return TRUE;
diff --git a/contrib/gstyle/gstyle-palette-widget.c b/contrib/gstyle/gstyle-palette-widget.c
index 0e25586..708ffb7 100644
--- a/contrib/gstyle/gstyle-palette-widget.c
+++ b/contrib/gstyle/gstyle-palette-widget.c
@@ -494,7 +494,7 @@ fuzzy_search_lookup (GstylePaletteWidget *self,
g_assert (fuzzy != NULL);
results = fuzzy_match (fuzzy, key, 1);
- if (ar!= NULL && ar->len > 0)
+ if (results!= NULL && results->len > 0)
{
match = &g_array_index (results, FuzzyMatch, 0);
if (g_strcmp0 (match->key, key))
@@ -1336,7 +1336,7 @@ flowbox_draw_cb (GtkWidget *flowbox,
GtkFlowBoxChild *bin_child;
GtkAllocation alloc;
gint len;
- gint x;
+ gint x = 0;
g_assert (GSTYLE_IS_PALETTE_WIDGET (self));
g_assert (GTK_IS_FLOW_BOX (flowbox));
diff --git a/contrib/gstyle/gstyle-palette.c b/contrib/gstyle/gstyle-palette.c
index 5c4dcb1..fec744d 100644
--- a/contrib/gstyle/gstyle-palette.c
+++ b/contrib/gstyle/gstyle-palette.c
@@ -872,14 +872,16 @@ gstyle_palette_set_id (GstylePalette *self,
g_return_if_fail (GSTYLE_IS_PALETTE (self));
- g_free (self->id);
if (gstyle_str_empty0 (id))
{
num_id = g_get_real_time ();
self->id = g_strdup_printf ("gb-cp-%lu", num_id);
}
else if (g_strcmp0 (self->id, id) != 0)
- self->id = g_strdup (id);
+ {
+ g_free (self->id);
+ self->id = g_strdup (id);
+ }
}
/**
diff --git a/contrib/gstyle/gstyle-revealer.c b/contrib/gstyle/gstyle-revealer.c
index ce98feb..39b18e1 100644
--- a/contrib/gstyle/gstyle-revealer.c
+++ b/contrib/gstyle/gstyle-revealer.c
@@ -134,8 +134,6 @@ gstyle_revealer_set_reveal_child (GstyleRevealer *self,
if (reveal)
{
- gtk_widget_get_allocated_size (GTK_WIDGET (self), &allocation, NULL);
-
self->src_offset = self->offset;
self->dst_offset = 1.0;
}
@@ -146,7 +144,10 @@ gstyle_revealer_set_reveal_child (GstyleRevealer *self,
}
if (GSTYLE_IS_PALETTE_WIDGET (child))
- self->max_height = allocation.height;
+ {
+ gtk_widget_get_allocated_size (GTK_WIDGET (self), &allocation, NULL);
+ self->max_height = allocation.height;
+ }
else
self->max_height = G_MAXINT;
diff --git a/contrib/gstyle/gstyle-slidein.c b/contrib/gstyle/gstyle-slidein.c
index c79e73a..d9fdcaf 100644
--- a/contrib/gstyle/gstyle-slidein.c
+++ b/contrib/gstyle/gstyle-slidein.c
@@ -641,12 +641,10 @@ event_window_button_press_event_cb (GstyleSlidein *self,
GstyleSlidein *unused)
{
GdkEventButton *button_event = (GdkEventButton *)event;
- GtkAllocation alloc;
GtkAllocation child_alloc;
gboolean is_in_slide;
GtkWidget *src_widget;
gint dest_x, dest_y;
- gint x1, y1;
g_assert (GSTYLE_IS_SLIDEIN (self));
@@ -656,10 +654,7 @@ event_window_button_press_event_cb (GstyleSlidein *self,
&dest_x, &dest_y);
gtk_widget_get_allocated_size (self->overlay_child, &child_alloc, NULL);
- x1 = alloc.x + child_alloc.width;
- y1 = alloc.y + child_alloc.height;
-
- is_in_slide = (alloc.x <= dest_x && dest_x <= x1 && alloc.y <= dest_y && dest_y <= y1);
+ is_in_slide = (0 <= dest_x && dest_x <= child_alloc.width && 0 <= dest_y && dest_y <= child_alloc.height);
if (!is_in_slide)
{
gtk_grab_remove (GTK_WIDGET (self));
@@ -676,7 +671,7 @@ gstyle_slidein_remove (GtkContainer *container,
GtkWidget *widget)
{
GstyleSlidein *self = (GstyleSlidein *)container;
- gboolean was_visible;
+ gboolean was_visible = FALSE;
g_assert (GSTYLE_IS_SLIDEIN (self));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]