mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 03:29:50 +00:00
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.
This commit is contained in:
parent
d13c1a7b10
commit
9894c90109
4 changed files with 63 additions and 26 deletions
|
@ -1,3 +1,12 @@
|
|||
2005-09-21 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* 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 <ensonic@users.sf.net>
|
||||
|
||||
* docs/gst/tmpl/.cvsignore:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue