From 9894c90109fb3ccf26e3a52ba9c1b2e765fb9649 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 21 Sep 2005 11:52:04 +0000 Subject: [PATCH] gst/: Don't put functional code in g_return_if_fail() or g_return_val_if_fail() statements, otherwise things will bre... Original commit message from CVS: * gst/base/gstbasetransform.c: (gst_base_transform_transform_size): * gst/gstutils.c: (gst_util_set_value_from_string), (gst_util_set_object_arg): Don't put functional code in g_return_if_fail() or g_return_val_if_fail() statements, otherwise things will break when G_DISABLE_CHECKS is defined during compilation. --- ChangeLog | 9 +++++ gst/base/gstbasetransform.c | 12 ++++--- gst/gstutils.c | 56 ++++++++++++++++++++++---------- libs/gst/base/gstbasetransform.c | 12 ++++--- 4 files changed, 63 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 094fff19c6..9088b6d4b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-09-21 Tim-Philipp Müller + + * gst/base/gstbasetransform.c: (gst_base_transform_transform_size): + * gst/gstutils.c: (gst_util_set_value_from_string), + (gst_util_set_object_arg): + Don't put functional code in g_return_if_fail() or + g_return_val_if_fail() statements, otherwise things will + break when G_DISABLE_CHECKS is defined during compilation. + 2005-09-21 Stefan Kost * docs/gst/tmpl/.cvsignore: diff --git a/gst/base/gstbasetransform.c b/gst/base/gstbasetransform.c index 0558e99452..b9b8cc66f2 100644 --- a/gst/base/gstbasetransform.c +++ b/gst/base/gstbasetransform.c @@ -430,8 +430,11 @@ gst_base_transform_transform_size (GstBaseTransform * trans, ret = klass->transform_size (trans, direction, caps, size, othercaps, othersize); } else { - g_return_val_if_fail (gst_base_transform_get_unit_size (trans, caps, - &inunitsize), FALSE); + gboolean got_in_unit_size, got_out_unit_size; + + got_in_unit_size = gst_base_transform_get_unit_size (trans, caps, + &inunitsize); + g_return_val_if_fail (got_in_unit_size == TRUE, FALSE); GST_DEBUG_OBJECT (trans, "input size %d, input unit size %d", size, inunitsize); g_return_val_if_fail (inunitsize != 0, FALSE); @@ -441,8 +444,9 @@ gst_base_transform_transform_size (GstBaseTransform * trans, } units = size / inunitsize; - g_return_val_if_fail (gst_base_transform_get_unit_size (trans, othercaps, - &outunitsize), FALSE); + got_out_unit_size = gst_base_transform_get_unit_size (trans, othercaps, + &outunitsize); + g_return_val_if_fail (got_out_unit_size == TRUE, FALSE); *othersize = units * outunitsize; GST_DEBUG_OBJECT (trans, "transformed size to %d", *othersize); diff --git a/gst/gstutils.c b/gst/gstutils.c index 00a486a810..75abe3d9e4 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -87,6 +87,7 @@ gst_util_dump_mem (const guchar * mem, guint size) void gst_util_set_value_from_string (GValue * value, const gchar * value_str) { + gint sscanf_ret; g_return_if_fail (value != NULL); g_return_if_fail (value_str != NULL); @@ -102,35 +103,39 @@ gst_util_set_value_from_string (GValue * value, const gchar * value_str) case G_TYPE_INT:{ gint i; - g_return_if_fail (sscanf (value_str, "%d", &i) == 1); + sscanf_ret = sscanf (value_str, "%d", &i); + g_return_if_fail (sscanf_ret == 1); g_value_set_int (value, i); break; } case G_TYPE_UINT:{ guint i; - g_return_if_fail (sscanf (value_str, "%u", &i) == 1); + sscanf_ret = sscanf (value_str, "%u", &i); + g_return_if_fail (sscanf_ret == 1); g_value_set_uint (value, i); break; } case G_TYPE_LONG:{ glong i; - g_return_if_fail (sscanf (value_str, "%ld", &i) == 1); + sscanf_ret = sscanf (value_str, "%ld", &i); + g_return_if_fail (sscanf_ret == 1); g_value_set_long (value, i); break; } case G_TYPE_ULONG:{ gulong i; - g_return_if_fail (sscanf (value_str, "%lu", &i) == 1); + sscanf_ret = sscanf (value_str, "%lu", &i); + g_return_if_fail (sscanf_ret == 1); g_value_set_ulong (value, i); break; } case G_TYPE_BOOLEAN:{ gboolean i = FALSE; - if (!strncmp ("true", value_str, 4)) + if (!g_ascii_strncasecmp ("true", value_str, 4)) i = TRUE; g_value_set_boolean (value, i); break; @@ -138,28 +143,32 @@ gst_util_set_value_from_string (GValue * value, const gchar * value_str) case G_TYPE_CHAR:{ gchar i; - g_return_if_fail (sscanf (value_str, "%c", &i) == 1); + sscanf_ret = sscanf (value_str, "%c", &i); + g_return_if_fail (sscanf_ret == 1); g_value_set_char (value, i); break; } case G_TYPE_UCHAR:{ guchar i; - g_return_if_fail (sscanf (value_str, "%c", &i) == 1); + sscanf_ret = sscanf (value_str, "%c", &i); + g_return_if_fail (sscanf_ret == 1); g_value_set_uchar (value, i); break; } case G_TYPE_FLOAT:{ gfloat i; - g_return_if_fail (sscanf (value_str, "%f", &i) == 1); + sscanf_ret = sscanf (value_str, "%f", &i); + g_return_if_fail (sscanf_ret == 1); g_value_set_float (value, i); break; } case G_TYPE_DOUBLE:{ gfloat i; - g_return_if_fail (sscanf (value_str, "%g", &i) == 1); + sscanf_ret = sscanf (value_str, "%g", &i); + g_return_if_fail (sscanf_ret == 1); g_value_set_double (value, (gdouble) i); break; } @@ -181,6 +190,8 @@ void gst_util_set_object_arg (GObject * object, const gchar * name, const gchar * value) { + gboolean sscanf_ret; + if (name && value) { GParamSpec *paramspec; @@ -203,28 +214,32 @@ gst_util_set_object_arg (GObject * object, const gchar * name, case G_TYPE_INT:{ gint i; - g_return_if_fail (sscanf (value, "%d", &i) == 1); + sscanf_ret = sscanf (value, "%d", &i); + g_return_if_fail (sscanf_ret == 1); g_object_set (G_OBJECT (object), name, i, NULL); break; } case G_TYPE_UINT:{ guint i; - g_return_if_fail (sscanf (value, "%u", &i) == 1); + sscanf_ret = sscanf (value, "%u", &i); + g_return_if_fail (sscanf_ret == 1); g_object_set (G_OBJECT (object), name, i, NULL); break; } case G_TYPE_LONG:{ glong i; - g_return_if_fail (sscanf (value, "%ld", &i) == 1); + sscanf_ret = sscanf (value, "%ld", &i); + g_return_if_fail (sscanf_ret == 1); g_object_set (G_OBJECT (object), name, i, NULL); break; } case G_TYPE_ULONG:{ gulong i; - g_return_if_fail (sscanf (value, "%lu", &i) == 1); + sscanf_ret = sscanf (value, "%lu", &i); + g_return_if_fail (sscanf_ret == 1); g_object_set (G_OBJECT (object), name, i, NULL); break; } @@ -239,28 +254,32 @@ gst_util_set_object_arg (GObject * object, const gchar * name, case G_TYPE_CHAR:{ gchar i; - g_return_if_fail (sscanf (value, "%c", &i) == 1); + sscanf_ret = sscanf (value, "%c", &i); + g_return_if_fail (sscanf_ret == 1); g_object_set (G_OBJECT (object), name, i, NULL); break; } case G_TYPE_UCHAR:{ guchar i; - g_return_if_fail (sscanf (value, "%c", &i) == 1); + sscanf_ret = sscanf (value, "%c", &i); + g_return_if_fail (sscanf_ret == 1); g_object_set (G_OBJECT (object), name, i, NULL); break; } case G_TYPE_FLOAT:{ gfloat i; - g_return_if_fail (sscanf (value, "%f", &i) == 1); + sscanf_ret = sscanf (value, "%f", &i); + g_return_if_fail (sscanf_ret == 1); g_object_set (G_OBJECT (object), name, i, NULL); break; } case G_TYPE_DOUBLE:{ gfloat i; - g_return_if_fail (sscanf (value, "%g", &i) == 1); + sscanf_ret = sscanf (value, "%g", &i); + g_return_if_fail (sscanf_ret == 1); g_object_set (G_OBJECT (object), name, (gdouble) i, NULL); break; } @@ -268,7 +287,8 @@ gst_util_set_object_arg (GObject * object, const gchar * name, if (G_IS_PARAM_SPEC_ENUM (paramspec)) { gint i; - g_return_if_fail (sscanf (value, "%d", &i) == 1); + sscanf_ret = sscanf (value, "%d", &i); + g_return_if_fail (sscanf_ret == 1); g_object_set (G_OBJECT (object), name, i, NULL); } else if (paramspec->value_type == GST_TYPE_URI) { g_object_set (G_OBJECT (object), name, value, NULL); diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index 0558e99452..b9b8cc66f2 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -430,8 +430,11 @@ gst_base_transform_transform_size (GstBaseTransform * trans, ret = klass->transform_size (trans, direction, caps, size, othercaps, othersize); } else { - g_return_val_if_fail (gst_base_transform_get_unit_size (trans, caps, - &inunitsize), FALSE); + gboolean got_in_unit_size, got_out_unit_size; + + got_in_unit_size = gst_base_transform_get_unit_size (trans, caps, + &inunitsize); + g_return_val_if_fail (got_in_unit_size == TRUE, FALSE); GST_DEBUG_OBJECT (trans, "input size %d, input unit size %d", size, inunitsize); g_return_val_if_fail (inunitsize != 0, FALSE); @@ -441,8 +444,9 @@ gst_base_transform_transform_size (GstBaseTransform * trans, } units = size / inunitsize; - g_return_val_if_fail (gst_base_transform_get_unit_size (trans, othercaps, - &outunitsize), FALSE); + got_out_unit_size = gst_base_transform_get_unit_size (trans, othercaps, + &outunitsize); + g_return_val_if_fail (got_out_unit_size == TRUE, FALSE); *othersize = units * outunitsize; GST_DEBUG_OBJECT (trans, "transformed size to %d", *othersize); -- 2.34.1