From 4ae4e6398af89b341f0b32da74cb6f91b9fb5176 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 30 Jul 2012 12:03:21 +0200 Subject: [PATCH] =?utf8?q?Bug=20664072=20=E2=80=94=20Folks=20should=20only?= =?utf8?q?=20use=20assert*()=20for=20critical,=20program-terminating=20err?= =?utf8?q?ors?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Turn various assert()s into return[_val]_if_fail()s. Closes: https://bugzilla.gnome.org/show_bug.cgi?id=664072 --- NEWS | 2 ++ backends/telepathy/lib/tpf-persona-store.vala | 3 ++- folks/individual.vala | 14 +++++++------- folks/potential-match.vala | 8 ++++---- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index 9fc2d2a..065a869 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ Bugs fixed: • Bug 681346 — Individual id can be inconsistent • Bug 681420 — warning (vala 0.17.x): access to static class members through an instance variable +• Bug 664072 — Folks should only use assert*() for critical, program-terminating + errors Overview of changes from libfolks 0.7.2 to libfolks 0.7.3 ========================================================= diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala index bbff7c3..3fb9809 100644 --- a/backends/telepathy/lib/tpf-persona-store.vala +++ b/backends/telepathy/lib/tpf-persona-store.vala @@ -1554,7 +1554,8 @@ public class Tpf.PersonaStore : Folks.PersonaStore } /* Bail if a store already exists for this account. */ - assert (!PersonaStore._persona_stores_by_account.has_key (store.id)); + return_if_fail ( + !PersonaStore._persona_stores_by_account.has_key (store.id)); /* Add the store. */ PersonaStore._persona_stores_by_account.set (store.id, store); diff --git a/folks/individual.vala b/folks/individual.vala index d0bd428..e087b25 100644 --- a/folks/individual.vala +++ b/folks/individual.vala @@ -1258,8 +1258,8 @@ public class Folks.Individual : Object, { CompareDataFunc primary_compare_func = (a, b) => { - assert (a != null); - assert (b != null); + return_val_if_fail (a != null, 0); + return_val_if_fail (b != null, 0); /* Always prefer values which are set over those which aren't. */ var a_is_set = filter_func (a); @@ -1446,7 +1446,7 @@ public class Folks.Individual : Object, this._update_single_valued_property (typeof (AliasDetails), (p) => { var alias = ((AliasDetails) p).alias; - assert (alias != null); + return_val_if_fail (alias != null, false); return (alias.strip () != ""); /* empty aliases are unset */ }, (a, b) => @@ -1454,8 +1454,8 @@ public class Folks.Individual : Object, var a_alias = ((AliasDetails) a).alias; var b_alias = ((AliasDetails) b).alias; - assert (a_alias != null); - assert (b_alias != null); + return_val_if_fail (a_alias != null, 0); + return_val_if_fail (b_alias != null, 0); var a_is_empty = (a_alias.strip () == "") ? 1 : 0; var b_is_empty = (b_alias.strip () == "") ? 1 : 0; @@ -1670,7 +1670,7 @@ public class Folks.Individual : Object, this._update_single_valued_property (typeof (NameDetails), (p) => { var name = ((NameDetails) p).full_name; - assert (name != null); + return_val_if_fail (name != null, false); return (name.strip () != ""); /* empty names are unset */ }, (a, b) => @@ -1699,7 +1699,7 @@ public class Folks.Individual : Object, this._update_single_valued_property (typeof (NameDetails), (p) => { var nickname = ((NameDetails) p).nickname; - assert (nickname != null); + return_val_if_fail (nickname != null, false); return (nickname.strip () != ""); /* empty names are unset */ }, (a, b) => diff --git a/folks/potential-match.vala b/folks/potential-match.vala index aa58df9..31eac72 100644 --- a/folks/potential-match.vala +++ b/folks/potential-match.vala @@ -473,8 +473,8 @@ public class Folks.PotentialMatch : Object return false; } - assert (a.validate ()); - assert (b.validate ()); + return_val_if_fail (a.validate (), false); + return_val_if_fail (b.validate (), false); var a_stripped = this._strip_string ((!) a); var b_stripped = this._strip_string ((!) b); @@ -499,8 +499,8 @@ public class Folks.PotentialMatch : Object return false; } - assert (a.validate ()); - assert (b.validate ()); + return_val_if_fail (a.validate (), false); + return_val_if_fail (b.validate (), false); var a_stripped = this._strip_string ((!) a); var b_stripped = this._strip_string ((!) b); -- 2.7.4