aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavan@src.gnome.org>2007-09-03 03:00:36 +0800
committerSrinivasa Ragavan <sragavan@src.gnome.org>2007-09-03 03:00:36 +0800
commita10f8e5fbd157a403e0a968ea2e59309a4751aae (patch)
tree60cac5ff42a832a2e966729fbca7c3f506ace772
parentd440df54a8a719d6da8f9d6556e1191bfdb38924 (diff)
downloadgsoc2013-evolution-a10f8e5fbd157a403e0a968ea2e59309a4751aae.tar
gsoc2013-evolution-a10f8e5fbd157a403e0a968ea2e59309a4751aae.tar.gz
gsoc2013-evolution-a10f8e5fbd157a403e0a968ea2e59309a4751aae.tar.bz2
gsoc2013-evolution-a10f8e5fbd157a403e0a968ea2e59309a4751aae.tar.lz
gsoc2013-evolution-a10f8e5fbd157a403e0a968ea2e59309a4751aae.tar.xz
gsoc2013-evolution-a10f8e5fbd157a403e0a968ea2e59309a4751aae.tar.zst
gsoc2013-evolution-a10f8e5fbd157a403e0a968ea2e59309a4751aae.zip
** Fix for bug #471791 (Move away from asserts to g_ret*)
svn path=/trunk/; revision=34160
-rw-r--r--filter/ChangeLog23
-rw-r--r--filter/filter-option.c4
-rw-r--r--filter/filter-rule.c44
-rw-r--r--filter/rule-context.c56
-rw-r--r--filter/rule-editor.c4
5 files changed, 77 insertions, 54 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 039e87175b..bb54d81a2c 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,26 @@
+2007-09-03 Srinivasa Ragavan <sragavan@novell.com>
+
+ ** Fix for bug #471791 (Move away from asserts to g_ret*)
+
+ * filter-option.c: (filter_option_set_current),
+ (filter_option_add):
+ * filter-rule.c: (filter_rule_clone), (filter_rule_set_name),
+ (filter_rule_set_source), (filter_rule_validate), (filter_rule_eq),
+ (filter_rule_xml_encode), (filter_rule_xml_decode),
+ (filter_rule_copy), (filter_rule_add_part),
+ (filter_rule_remove_part), (filter_rule_replace_part),
+ (filter_rule_build_code), (filter_rule_emit_changed):
+ * rule-context.c: (rule_context_add_part_set),
+ (rule_context_add_rule_set), (rule_context_set_error),
+ (rule_context_load), (rule_context_save), (rule_context_revert),
+ (rule_context_find_part), (rule_context_create_part),
+ (rule_context_next_part), (rule_context_next_rule),
+ (rule_context_find_rule), (rule_context_add_part),
+ (rule_context_add_rule), (rule_context_add_rule_gui),
+ (rule_context_remove_rule), (rule_context_rank_rule),
+ (rule_context_get_rank_rule), (rule_context_find_rank_rule):
+ * rule-editor.c: (rule_move), (cursor_changed):
+
2007-08-13 Ross Burton <ross@openedhand.com>
* rule-context.c:
diff --git a/filter/filter-option.c b/filter/filter-option.c
index 23962c0867..7fc8e1602a 100644
--- a/filter/filter-option.c
+++ b/filter/filter-option.c
@@ -157,7 +157,7 @@ find_option (FilterOption *fo, const char *name)
void
filter_option_set_current (FilterOption *option, const char *name)
{
- g_assert(IS_FILTER_OPTION(option));
+ g_return_if_fail (IS_FILTER_OPTION(option));
option->current = find_option (option, name);
}
@@ -168,7 +168,7 @@ filter_option_add(FilterOption *fo, const char *value, const char *title, const
{
struct _filter_option *op;
- g_assert(IS_FILTER_OPTION(fo));
+ g_return_val_if_fail (IS_FILTER_OPTION(fo), NULL);
g_return_val_if_fail(find_option(fo, value) == NULL, NULL);
op = g_malloc(sizeof(*op));
diff --git a/filter/filter-rule.c b/filter/filter-rule.c
index 865fb16e12..9dba4ddf10 100644
--- a/filter/filter-rule.c
+++ b/filter/filter-rule.c
@@ -156,7 +156,7 @@ filter_rule_clone (FilterRule *base)
{
FilterRule *rule;
- g_assert (IS_FILTER_RULE (base));
+ g_return_val_if_fail (IS_FILTER_RULE (base), NULL);
rule = g_object_new (G_OBJECT_TYPE (base), NULL, NULL);
filter_rule_copy (rule, base);
@@ -167,7 +167,7 @@ filter_rule_clone (FilterRule *base)
void
filter_rule_set_name (FilterRule *fr, const char *name)
{
- g_assert (IS_FILTER_RULE (fr));
+ g_return_if_fail (IS_FILTER_RULE (fr));
if ((fr->name && name && strcmp (fr->name, name) == 0)
|| (fr->name == NULL && name == NULL))
@@ -182,7 +182,7 @@ filter_rule_set_name (FilterRule *fr, const char *name)
void
filter_rule_set_source (FilterRule *fr, const char *source)
{
- g_assert (IS_FILTER_RULE (fr));
+ g_return_if_fail (IS_FILTER_RULE (fr));
if ((fr->source && source && strcmp (fr->source, source) == 0)
|| (fr->source == NULL && source == NULL))
@@ -197,7 +197,7 @@ filter_rule_set_source (FilterRule *fr, const char *source)
int
filter_rule_validate (FilterRule *fr)
{
- g_assert (IS_FILTER_RULE (fr));
+ g_return_val_if_fail (IS_FILTER_RULE (fr), 0);
return FILTER_RULE_GET_CLASS (fr)->validate (fr);
}
@@ -232,8 +232,8 @@ validate (FilterRule *fr)
int
filter_rule_eq (FilterRule *fr, FilterRule *cm)
{
- g_assert (IS_FILTER_RULE (fr));
- g_assert (IS_FILTER_RULE (cm));
+ g_return_val_if_fail (IS_FILTER_RULE (fr), 0);
+ g_return_val_if_fail (IS_FILTER_RULE (cm), 0);
return (FILTER_RULE_GET_CLASS (fr) == FILTER_RULE_GET_CLASS (cm))
&& FILTER_RULE_GET_CLASS (fr)->eq (fr, cm);
@@ -270,7 +270,7 @@ rule_eq (FilterRule *fr, FilterRule *cm)
xmlNodePtr
filter_rule_xml_encode (FilterRule *fr)
{
- g_assert (IS_FILTER_RULE (fr));
+ g_return_val_if_fail (IS_FILTER_RULE (fr), NULL);
return FILTER_RULE_GET_CLASS (fr)->xml_encode (fr);
}
@@ -365,9 +365,9 @@ filter_rule_xml_decode (FilterRule *fr, xmlNodePtr node, RuleContext *f)
{
int res;
- g_assert (IS_FILTER_RULE (fr));
- g_assert (IS_RULE_CONTEXT (f));
- g_assert (node != NULL);
+ g_return_val_if_fail (IS_FILTER_RULE (fr), 0);
+ g_return_val_if_fail (IS_RULE_CONTEXT (f), 0);
+ g_return_val_if_fail (node != NULL, 0);
fr->priv->frozen++;
res = FILTER_RULE_GET_CLASS (fr)->xml_decode (fr, node, f);
@@ -475,8 +475,8 @@ rule_copy (FilterRule *dest, FilterRule *src)
void
filter_rule_copy (FilterRule *dest, FilterRule *src)
{
- g_assert (IS_FILTER_RULE (dest));
- g_assert (IS_FILTER_RULE (src));
+ g_return_if_fail (IS_FILTER_RULE (dest));
+ g_return_if_fail (IS_FILTER_RULE (src));
FILTER_RULE_GET_CLASS (dest)->copy (dest, src);
@@ -486,8 +486,8 @@ filter_rule_copy (FilterRule *dest, FilterRule *src)
void
filter_rule_add_part (FilterRule *fr, FilterPart *fp)
{
- g_assert (IS_FILTER_RULE (fr));
- g_assert (IS_FILTER_PART (fp));
+ g_return_if_fail (IS_FILTER_RULE (fr));
+ g_return_if_fail (IS_FILTER_PART (fp));
fr->parts = g_list_append (fr->parts, fp);
@@ -497,8 +497,8 @@ filter_rule_add_part (FilterRule *fr, FilterPart *fp)
void
filter_rule_remove_part (FilterRule *fr, FilterPart *fp)
{
- g_assert (IS_FILTER_RULE (fr));
- g_assert (IS_FILTER_PART (fp));
+ g_return_if_fail (IS_FILTER_RULE (fr));
+ g_return_if_fail (IS_FILTER_PART (fp));
fr->parts = g_list_remove (fr->parts, fp);
@@ -510,9 +510,9 @@ filter_rule_replace_part (FilterRule *fr, FilterPart *fp, FilterPart *new)
{
GList *l;
- g_assert (IS_FILTER_RULE (fr));
- g_assert (IS_FILTER_PART (fp));
- g_assert (IS_FILTER_PART (new));
+ g_return_if_fail (IS_FILTER_RULE (fr));
+ g_return_if_fail (IS_FILTER_PART (fp));
+ g_return_if_fail (IS_FILTER_PART (new));
l = g_list_find (fr->parts, fp);
if (l) {
@@ -527,8 +527,8 @@ filter_rule_replace_part (FilterRule *fr, FilterPart *fp, FilterPart *new)
void
filter_rule_build_code (FilterRule *fr, GString *out)
{
- g_assert (IS_FILTER_RULE (fr));
- g_assert (out != NULL);
+ g_return_if_fail (IS_FILTER_RULE (fr));
+ g_return_if_fail (out != NULL);
FILTER_RULE_GET_CLASS (fr)->build_code (fr, out);
@@ -538,7 +538,7 @@ filter_rule_build_code (FilterRule *fr, GString *out)
void
filter_rule_emit_changed(FilterRule *fr)
{
- g_assert (IS_FILTER_RULE (fr));
+ g_return_if_fail (IS_FILTER_RULE (fr));
if (fr->priv->frozen == 0)
g_signal_emit (fr, signals[CHANGED], 0);
diff --git a/filter/rule-context.c b/filter/rule-context.c
index d63c792786..33f69a3925 100644
--- a/filter/rule-context.c
+++ b/filter/rule-context.c
@@ -225,7 +225,7 @@ rule_context_add_part_set(RuleContext *rc, const char *setname, GType part_type,
{
struct _part_set_map *map;
- g_assert(g_hash_table_lookup(rc->part_set_map, setname) == NULL);
+ g_return_if_fail (g_hash_table_lookup(rc->part_set_map, setname) == NULL);
map = g_malloc0(sizeof(*map));
map->type = part_type;
@@ -242,7 +242,7 @@ rule_context_add_rule_set(RuleContext *rc, const char *setname, GType rule_type,
{
struct _rule_set_map *map;
- g_assert(g_hash_table_lookup(rc->rule_set_map, setname) == NULL);
+ g_return_if_fail (g_hash_table_lookup(rc->rule_set_map, setname) == NULL);
map = g_malloc0(sizeof(*map));
map->type = rule_type;
@@ -264,7 +264,7 @@ rule_context_add_rule_set(RuleContext *rc, const char *setname, GType rule_type,
static void
rule_context_set_error(RuleContext *rc, char *error)
{
- g_assert(rc);
+ g_return_if_fail (rc);
g_free(rc->error);
rc->error = error;
@@ -285,7 +285,7 @@ rule_context_load(RuleContext *rc, const char *system, const char *user)
{
int res;
- g_assert(rc);
+ g_return_val_if_fail (rc, -1);
d(printf("rule_context: loading %s %s\n", system, user));
@@ -417,8 +417,8 @@ load(RuleContext *rc, const char *system, const char *user)
int
rule_context_save(RuleContext *rc, const char *user)
{
- g_assert(rc);
- g_assert(user);
+ g_return_val_if_fail (rc, -1);
+ g_return_val_if_fail (user, -1);
return RULE_CONTEXT_GET_CLASS(rc)->save(rc, user);
}
@@ -473,7 +473,7 @@ save(RuleContext *rc, const char *user)
int
rule_context_revert(RuleContext *rc, const char *user)
{
- g_assert(rc);
+ g_return_val_if_fail (rc, 0);
d(printf("rule_context: restoring %s\n", user));
@@ -609,8 +609,8 @@ revert(RuleContext *rc, const char *user)
FilterPart *
rule_context_find_part(RuleContext *rc, const char *name)
{
- g_assert(rc);
- g_assert(name);
+ g_return_val_if_fail (rc, NULL);
+ g_return_val_if_fail (name, NULL);
d(printf("find part : "));
return filter_part_find_list(rc->parts, name);
@@ -621,8 +621,8 @@ rule_context_create_part(RuleContext *rc, const char *name)
{
FilterPart *part;
- g_assert(rc);
- g_assert(name);
+ g_return_val_if_fail (rc, NULL);
+ g_return_val_if_fail (name, NULL);
if ((part = rule_context_find_part(rc, name)))
return filter_part_clone(part);
@@ -633,7 +633,7 @@ rule_context_create_part(RuleContext *rc, const char *name)
FilterPart *
rule_context_next_part(RuleContext *rc, FilterPart *last)
{
- g_assert(rc);
+ g_return_val_if_fail (rc, NULL);
return filter_part_next_list(rc->parts, last);
}
@@ -641,7 +641,7 @@ rule_context_next_part(RuleContext *rc, FilterPart *last)
FilterRule *
rule_context_next_rule(RuleContext *rc, FilterRule *last, const char *source)
{
- g_assert(rc);
+ g_return_val_if_fail (rc, NULL);
return filter_rule_next_list(rc->rules, last, source);
}
@@ -649,8 +649,8 @@ rule_context_next_rule(RuleContext *rc, FilterRule *last, const char *source)
FilterRule *
rule_context_find_rule(RuleContext *rc, const char *name, const char *source)
{
- g_assert(name);
- g_assert(rc);
+ g_return_val_if_fail (name, NULL);
+ g_return_val_if_fail (rc, NULL);
return filter_rule_find_list(rc->rules, name, source);
}
@@ -658,8 +658,8 @@ rule_context_find_rule(RuleContext *rc, const char *name, const char *source)
void
rule_context_add_part(RuleContext *rc, FilterPart *part)
{
- g_assert(rc);
- g_assert(part);
+ g_return_if_fail (rc);
+ g_return_if_fail (part);
rc->parts = g_list_append(rc->parts, part);
}
@@ -667,8 +667,8 @@ rule_context_add_part(RuleContext *rc, FilterPart *part)
void
rule_context_add_rule(RuleContext *rc, FilterRule *new)
{
- g_assert(rc);
- g_assert(new);
+ g_return_if_fail (rc);
+ g_return_if_fail (new);
d(printf("add rule '%s'\n", new->name));
@@ -716,8 +716,8 @@ rule_context_add_rule_gui(RuleContext *rc, FilterRule *rule, const char *title,
d(printf("add rule gui '%s'\n", rule->name));
- g_assert(rc);
- g_assert(rule);
+ g_return_if_fail (rc);
+ g_return_if_fail (rule);
widget = filter_rule_get_widget(rule, rc);
gtk_widget_show(widget);
@@ -751,8 +751,8 @@ rule_context_add_rule_gui(RuleContext *rc, FilterRule *rule, const char *title,
void
rule_context_remove_rule(RuleContext *rc, FilterRule *rule)
{
- g_assert(rc);
- g_assert(rule);
+ g_return_if_fail (rc);
+ g_return_if_fail (rule);
d(printf("remove rule '%s'\n", rule->name));
@@ -770,8 +770,8 @@ rule_context_rank_rule(RuleContext *rc, FilterRule *rule, const char *source, in
GList *node;
int i = 0, index = 0;
- g_assert(rc);
- g_assert(rule);
+ g_return_if_fail (rc);
+ g_return_if_fail (rule);
if (rule_context_get_rank_rule (rc, rule, source) == rank)
return;
@@ -807,8 +807,8 @@ rule_context_get_rank_rule(RuleContext *rc, FilterRule *rule, const char *source
GList *node;
int i = 0;
- g_assert(rc);
- g_assert(rule);
+ g_return_val_if_fail (rc, -1);
+ g_return_val_if_fail (rule, -1);
d(printf("getting rank of rule '%s'\n", rule->name));
@@ -836,7 +836,7 @@ rule_context_find_rank_rule(RuleContext *rc, int rank, const char *source)
GList *node;
int i = 0;
- g_assert(rc);
+ g_return_val_if_fail (rc, NULL);
d(printf("getting rule at rank %d source '%s'\n", rank, source?source:"<any>"));
diff --git a/filter/rule-editor.c b/filter/rule-editor.c
index cef7bcb5ad..0517403f5a 100644
--- a/filter/rule-editor.c
+++ b/filter/rule-editor.c
@@ -550,7 +550,7 @@ rule_move (RuleEditor *re, int from, int to)
gtk_tree_path_free (path);
gtk_tree_model_get (GTK_TREE_MODEL (re->model), &iter, 1, &rule, -1);
- g_assert (rule != NULL);
+ g_return_if_fail (rule != NULL);
/* remove and then re-insert the row at the new location */
gtk_list_store_remove (re->model, &iter);
@@ -680,7 +680,7 @@ cursor_changed (GtkTreeView *treeview, RuleEditor *re)
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
gtk_tree_model_get (GTK_TREE_MODEL (re->model), &iter, 1, &re->current, -1);
- g_assert (re->current);
+ g_return_if_fail (re->current);
rule_editor_set_sensitive (re);
}