Merge branch 'lcopyfail' into 'master'

gobject: Handle runtime checks as such

See merge request GNOME/glib!1505
This commit is contained in:
Philip Withnall 2020-05-20 16:49:17 +00:00
commit 8f291487fe
6 changed files with 40 additions and 58 deletions

View File

@ -256,8 +256,7 @@ boxed_proxy_lcopy_value (const GValue *value,
{
gpointer *boxed_p = collect_values[0].v_pointer;
if (!boxed_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (boxed_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
if (!value->data[0].v_pointer)
*boxed_p = NULL;

View File

@ -167,10 +167,9 @@ value_flags_enum_lcopy_value (const GValue *value,
guint collect_flags)
{
gint *int_p = collect_values[0].v_pointer;
if (!int_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (int_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
*int_p = value->data[0].v_long;
return NULL;

View File

@ -4021,9 +4021,8 @@ g_value_object_lcopy_value (const GValue *value,
guint collect_flags)
{
GObject **object_p = collect_values[0].v_pointer;
if (!object_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (object_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
if (!value->data[0].v_pointer)
*object_p = NULL;

View File

@ -871,8 +871,7 @@ value_param_lcopy_value (const GValue *value,
{
GParamSpec **param_p = collect_values[0].v_pointer;
if (!param_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (param_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
if (!value->data[0].v_pointer)
*param_p = NULL;

View File

@ -1178,17 +1178,13 @@ struct _GInterfaceInfo
* array. To deviate from our string example for a moment, and taking
* a look at an exemplary implementation for collect_value() of
* #GObject:
* |[<!-- language="C" -->
* if (collect_values[0].v_pointer)
* {
* |[<!-- language="C" -->
* GObject *object = G_OBJECT (collect_values[0].v_pointer);
* g_return_val_if_fail (object != NULL,
* g_strdup_printf ("Object passed as invalid NULL pointer"));
* // never honour G_VALUE_NOCOPY_CONTENTS for ref-counted types
* value->data[0].v_pointer = g_object_ref (object);
* return NULL;
* }
* else
* return g_strdup_printf ("Object passed as invalid NULL pointer");
* }
* ]|
* The reference count for valid objects is always incremented,
* regardless of @collect_flags. For invalid objects, the example
@ -1220,8 +1216,8 @@ struct _GInterfaceInfo
* To complete the string example:
* |[<!-- language="C" -->
* gchar **string_p = collect_values[0].v_pointer;
* if (!string_p)
* return g_strdup_printf ("string location passed as NULL");
* g_return_val_if_fail (string_p != NULL,
* g_strdup_printf ("string location passed as NULL"));
* if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
* *string_p = value->data[0].v_pointer;
* else
@ -1231,8 +1227,8 @@ struct _GInterfaceInfo
* reference-counted types:
* |[<!-- language="C" -->
* GObject **object_p = collect_values[0].v_pointer;
* if (!object_p)
* return g_strdup_printf ("object location passed as NULL");
* g_return_val_if_fail (object_p != NULL,
* g_strdup_printf ("object location passed as NULL"));
* if (!value->data[0].v_pointer)
* *object_p = NULL;
* else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) // always honour

View File

@ -55,10 +55,9 @@ value_lcopy_char (const GValue *value,
guint collect_flags)
{
gint8 *int8_p = collect_values[0].v_pointer;
if (!int8_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (int8_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
*int8_p = value->data[0].v_int;
return NULL;
@ -71,10 +70,9 @@ value_lcopy_boolean (const GValue *value,
guint collect_flags)
{
gboolean *bool_p = collect_values[0].v_pointer;
if (!bool_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (bool_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
*bool_p = value->data[0].v_int;
return NULL;
@ -98,10 +96,9 @@ value_lcopy_int (const GValue *value,
guint collect_flags)
{
gint *int_p = collect_values[0].v_pointer;
if (!int_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (int_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
*int_p = value->data[0].v_int;
return NULL;
@ -125,10 +122,9 @@ value_lcopy_long (const GValue *value,
guint collect_flags)
{
glong *long_p = collect_values[0].v_pointer;
if (!long_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (long_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
*long_p = value->data[0].v_long;
return NULL;
@ -165,10 +161,9 @@ value_lcopy_int64 (const GValue *value,
guint collect_flags)
{
gint64 *int64_p = collect_values[0].v_pointer;
if (!int64_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (int64_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
*int64_p = value->data[0].v_int64;
return NULL;
@ -205,10 +200,9 @@ value_lcopy_float (const GValue *value,
guint collect_flags)
{
gfloat *float_p = collect_values[0].v_pointer;
if (!float_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (float_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
*float_p = value->data[0].v_float;
return NULL;
@ -245,10 +239,9 @@ value_lcopy_double (const GValue *value,
guint collect_flags)
{
gdouble *double_p = collect_values[0].v_pointer;
if (!double_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (double_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
*double_p = value->data[0].v_double;
return NULL;
@ -309,10 +302,9 @@ value_lcopy_string (const GValue *value,
guint collect_flags)
{
gchar **string_p = collect_values[0].v_pointer;
if (!string_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (string_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
if (!value->data[0].v_pointer)
*string_p = NULL;
else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
@ -361,8 +353,7 @@ value_lcopy_pointer (const GValue *value,
{
gpointer *pointer_p = collect_values[0].v_pointer;
if (!pointer_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (pointer_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
*pointer_p = value->data[0].v_pointer;
@ -414,8 +405,7 @@ value_lcopy_variant (const GValue *value,
{
GVariant **variant_p = collect_values[0].v_pointer;
if (!variant_p)
return g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value));
g_return_val_if_fail (variant_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
if (!value->data[0].v_pointer)
*variant_p = NULL;