summaryrefslogtreecommitdiff
path: root/glib
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-09-30 14:02:29 +0100
committerMatthias Clasen <mclasen@redhat.com>2012-01-15 23:21:03 -0500
commit6d9f874330ee27ea09b383cb30718a492f6539dd (patch)
treed69522a6bf595cf4c8e6ff7c671c74b5252bab2b /glib
parent186c15fc879606866215b40f1bfb730b1c47a727 (diff)
downloadglib-6d9f874330ee27ea09b383cb30718a492f6539dd.tar.gz
g_error_new_valist, g_error_copy: warn if domain is 0 or message is NULL
Neither of those usages is valid, but there's a lot of use of 0 as a domain "in the wild", so we can't g_return_if_fail yet. Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Bug: https://bugzilla.gnome.org/show_bug.cgi?id=660371
Diffstat (limited to 'glib')
-rw-r--r--glib/gerror.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/glib/gerror.c b/glib/gerror.c
index 7e2d636fa..6cc3cfb5d 100644
--- a/glib/gerror.c
+++ b/glib/gerror.c
@@ -382,6 +382,14 @@ g_error_new_valist (GQuark domain,
{
GError *error;
+ /* Historically, GError allowed this (although it was never meant to work),
+ * and it has significant use in the wild, which g_return_val_if_fail
+ * would break. It should maybe g_return_val_if_fail in GLib 4.
+ * (GNOME#660371, GNOME#560482)
+ */
+ g_warn_if_fail (domain != 0);
+ g_warn_if_fail (format != NULL);
+
error = g_slice_new (GError);
error->domain = domain;
@@ -484,6 +492,9 @@ g_error_copy (const GError *error)
GError *copy;
g_return_val_if_fail (error != NULL, NULL);
+ /* See g_error_new_valist for why these don't return */
+ g_warn_if_fail (error->domain != 0);
+ g_warn_if_fail (error->message != NULL);
copy = g_slice_new (GError);