# HG changeset patch # User Richard Laager # Date 1146515269 0 # Node ID ff25f6d2b4847be1aa136d845e5e8fb139e3864b # Parent 76d8b0032f504f94d1f3f8b21c35820e182f0b3e [gaim-migrate @ 16113] CID 154: File: gaim/src/prefs.c Function: gaim_prefs_rename_boolean_toggle Description: Pointer returned from "find_pref" is never used newpref was only examined in g_return_if_fail() statements, which can be compiled out. It's probably safer to do these sanity checks all the time, given that plugins could call this, etc. etc. committer: Tailor Script diff -r 76d8b0032f50 -r ff25f6d2b484 src/prefs.c --- a/src/prefs.c Mon May 01 19:48:57 2006 +0000 +++ b/src/prefs.c Mon May 01 20:27:49 2006 +0000 @@ -953,23 +953,42 @@ struct gaim_pref *oldpref, *newpref; oldpref = find_pref(oldname); - newpref = find_pref(newname); /* it's already been renamed, call off the cats */ if(!oldpref) return; - gaim_debug_info("prefs", "Renaming and toggling %s to %s\n", oldname, newname); + if (oldpref->type != GAIM_PREF_BOOLEAN) + { + gaim_debug_error("prefs", "Unable to rename %s to %s: old pref not a boolean\n", oldname, newname); + return; + } + + if (oldpref->first_child != NULL) /* can't rename parents */ + { + gaim_debug_error("prefs", "Unable to rename %s to %s: can't rename parents\n", oldname, newname); + return; + } + - g_return_if_fail(newpref != NULL); /* the new one needs to be created */ - g_return_if_fail(oldpref->type == newpref->type); - g_return_if_fail(oldpref->type == GAIM_PREF_BOOLEAN); - g_return_if_fail(oldpref->first_child == NULL); /* can't rename parents */ + newpref = find_pref(newname); + + if (newpref == NULL) + { + gaim_debug_error("prefs", "Unable to rename %s to %s: new pref not created\n", oldname, newname); + return; + } + if (oldpref->type != newpref->type) + { + gaim_debug_error("prefs", "Unable to rename %s to %s: differing types\n", oldname, newname); + return; + } + + gaim_debug_info("prefs", "Renaming and toggling %s to %s\n", oldname, newname); gaim_prefs_set_bool(newname, !(oldpref->value.boolean)); remove_pref(oldpref); - } guint