diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2014-01-09 19:28:51 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2014-01-09 19:28:51 +0100 |
commit | 02868b4dc0e9c3c6d6f2659e8f617d658ba21f6c (patch) | |
tree | 0f5c60568b34fed58dcf00d98f8a20b571274386 /src | |
parent | 73eb2564f363848d379261fd68da9fc16b80e00f (diff) | |
download | weechat-02868b4dc0e9c3c6d6f2659e8f617d658ba21f6c.zip |
core: optimize xxx_valid() functions: return immediately if pointer is NULL
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-hook.c | 3 | ||||
-rw-r--r-- | src/core/wee-infolist.c | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc-channel.c | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc-nick.c | 2 | ||||
-rw-r--r-- | src/plugins/plugin-script.c | 2 |
5 files changed, 9 insertions, 3 deletions
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index 762705bcb..150bbc168 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -344,6 +344,9 @@ hook_valid (struct t_hook *hook) int type; struct t_hook *ptr_hook; + if (!hook) + return 0; + for (type = 0; type < HOOK_NUM_TYPES; type++) { for (ptr_hook = weechat_hooks[type]; ptr_hook; diff --git a/src/core/wee-infolist.c b/src/core/wee-infolist.c index 2a4a66479..a2b323bc6 100644 --- a/src/core/wee-infolist.c +++ b/src/core/wee-infolist.c @@ -287,6 +287,9 @@ infolist_valid (struct t_infolist *infolist) { struct t_infolist *ptr_infolist; + if (!infolist) + return 0; + for (ptr_infolist = weechat_infolists; ptr_infolist; ptr_infolist = ptr_infolist->next_infolist) { diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index 8b677faf4..5ed8287e0 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -51,7 +51,7 @@ irc_channel_valid (struct t_irc_server *server, struct t_irc_channel *channel) { struct t_irc_channel *ptr_channel; - if (!server) + if (!server || !channel) return 0; for (ptr_channel = server->channels; ptr_channel; diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index 1e96f7201..c9b6763af 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -48,7 +48,7 @@ irc_nick_valid (struct t_irc_channel *channel, struct t_irc_nick *nick) { struct t_irc_nick *ptr_nick; - if (!channel) + if (!channel || !nick) return 0; for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) diff --git a/src/plugins/plugin-script.c b/src/plugins/plugin-script.c index 8c64fad11..60a547ffd 100644 --- a/src/plugins/plugin-script.c +++ b/src/plugins/plugin-script.c @@ -256,7 +256,7 @@ plugin_script_valid (struct t_plugin_script *scripts, { struct t_plugin_script *ptr_script; - if (!script) + if (!scripts || !script) return 0; for (ptr_script = scripts; ptr_script; |