Mercurial > pidgin
changeset 13709:ff25f6d2b484
[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 <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 01 May 2006 20:27:49 +0000 |
parents | 76d8b0032f50 |
children | 848c9685ecc7 |
files | src/prefs.c |
diffstat | 1 files changed, 26 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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