[cheese] Avoid warnings from -Wswitch-enum
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Avoid warnings from -Wswitch-enum
- Date: Mon, 16 Feb 2015 21:44:47 +0000 (UTC)
commit 5c98c8d5ba6f59a6e51b45839efdaf227eb890d7
Author: David King <amigadave amigadave com>
Date: Thu Jan 29 13:08:22 2015 +0000
Avoid warnings from -Wswitch-enum
Check switch statements where several cases are intentionally not
handled by using an if instead.
libcheese/cheese-camera.c | 22 +++++++---------------
libcheese/cheese-widget.c | 10 +++-------
2 files changed, 10 insertions(+), 22 deletions(-)
---
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index a98ef16..49cd837 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -190,10 +190,11 @@ static void
cheese_camera_bus_message_cb (GstBus *bus, GstMessage *message, CheeseCamera *camera)
{
CheeseCameraPrivate *priv = cheese_camera_get_instance_private (camera);
+ GstMessageType type;
- switch (GST_MESSAGE_TYPE (message))
- {
- case GST_MESSAGE_WARNING:
+ type = GST_MESSAGE_TYPE (message);
+
+ if (type == GST_MESSAGE_WARNING)
{
GError *err = NULL;
gchar *debug = NULL;
@@ -207,9 +208,8 @@ cheese_camera_bus_message_cb (GstBus *bus, GstMessage *message, CheeseCamera *ca
}
g_free (debug);
- break;
}
- case GST_MESSAGE_ERROR:
+ else if (type == GST_MESSAGE_ERROR)
{
GError *err = NULL;
gchar *debug = NULL;
@@ -226,9 +226,8 @@ cheese_camera_bus_message_cb (GstBus *bus, GstMessage *message, CheeseCamera *ca
g_signal_emit (camera, camera_signals[STATE_FLAGS_CHANGED], 0,
GST_STATE_NULL);
g_free (debug);
- break;
}
- case GST_MESSAGE_STATE_CHANGED:
+ else if (type == GST_MESSAGE_STATE_CHANGED)
{
if (strcmp (GST_MESSAGE_SRC_NAME (message), "camerabin") == 0)
{
@@ -241,9 +240,8 @@ cheese_camera_bus_message_cb (GstBus *bus, GstMessage *message, CheeseCamera *ca
priv->effect_pipeline_is_playing);
}
}
- break;
}
- case GST_MESSAGE_ELEMENT:
+ else if (type == GST_MESSAGE_ELEMENT)
{
const GstStructure *structure;
GstSample *sample;
@@ -286,13 +284,7 @@ cheese_camera_bus_message_cb (GstBus *bus, GstMessage *message, CheeseCamera *ca
priv->is_recording = FALSE;
}
}
- break;
}
- default:
- {
- break;
- }
- }
}
/*
diff --git a/libcheese/cheese-widget.c b/libcheese/cheese-widget.c
index 23619d6..586824d 100644
--- a/libcheese/cheese-widget.c
+++ b/libcheese/cheese-widget.c
@@ -283,14 +283,10 @@ static void
webcam_state_changed (CheeseCamera *camera, GstState state,
CheeseWidget *widget)
{
- switch (state)
+ if (state == GST_STATE_NULL)
{
- case GST_STATE_NULL:
- cheese_widget_set_problem_page (widget, "error");
- break;
- default:
- /* TODO: Handle other cases. */
- break;
+ cheese_widget_set_problem_page (widget, "error");
+ /* TODO: Handle other cases. */
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]