# HG changeset patch # User Mark Doliner # Date 1204710211 0 # Node ID 31fb78b1184c21f4f376873c7371c903d569274f # Parent c5a3a92255f58a030c78c882582add97621b81a3 Short circuit and return out of the function early if gconftool-2 isn't in our path. This allows us to not indent the entire function. diff -r c5a3a92255f5 -r 31fb78b1184c libpurple/proxy.c --- a/libpurple/proxy.c Wed Mar 05 09:40:16 2008 +0000 +++ b/libpurple/proxy.c Wed Mar 05 09:43:31 2008 +0000 @@ -211,53 +211,53 @@ purple_gnome_proxy_get_info(void) { static PurpleProxyInfo info = {0, NULL, 0, NULL, NULL}; - gchar *path; - if ((path = g_find_program_in_path("gconftool-2"))) { - gchar *tmp; + gchar *tmp; - g_free(path); + tmp = g_find_program_in_path("gconftool-2"); + if (tmp == NULL) + return purple_global_proxy_get_info(); + + g_free(tmp); - /* See whether to use a proxy. */ - if (!g_spawn_command_line_sync("gconftool-2 -g /system/proxy/mode", &tmp, - NULL, NULL, NULL)) - return purple_global_proxy_get_info(); - if (!strcmp(tmp, "none\n")) { - info.type = PURPLE_PROXY_NONE; - g_free(tmp); - return &info; - } else if (strcmp(tmp, "manual\n")) { - g_free(tmp); - return purple_global_proxy_get_info(); - } + /* See whether to use a proxy. */ + if (!g_spawn_command_line_sync("gconftool-2 -g /system/proxy/mode", &tmp, + NULL, NULL, NULL)) + return purple_global_proxy_get_info(); + if (!strcmp(tmp, "none\n")) { + info.type = PURPLE_PROXY_NONE; + g_free(tmp); + return &info; + } else if (strcmp(tmp, "manual\n")) { + g_free(tmp); + return purple_global_proxy_get_info(); + } - g_free(tmp); - info.type = PURPLE_PROXY_HTTP; + g_free(tmp); + info.type = PURPLE_PROXY_HTTP; - /* Get the new ones */ - if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/host", &info.host, - NULL, NULL, NULL)) - return purple_global_proxy_get_info(); - g_strchomp(info.host); + /* Get the new ones */ + if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/host", &info.host, + NULL, NULL, NULL)) + return purple_global_proxy_get_info(); + g_strchomp(info.host); - if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_user", &info.username, - NULL, NULL, NULL)) - return purple_global_proxy_get_info(); - g_strchomp(info.username); + if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_user", &info.username, + NULL, NULL, NULL)) + return purple_global_proxy_get_info(); + g_strchomp(info.username); - if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_password", &info.password, - NULL, NULL, NULL)) - return purple_global_proxy_get_info(); - g_strchomp(info.password); + if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_password", &info.password, + NULL, NULL, NULL)) + return purple_global_proxy_get_info(); + g_strchomp(info.password); - if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/port", &tmp, - NULL, NULL, NULL)) - return purple_global_proxy_get_info(); - info.port = atoi(tmp); - g_free(tmp); + if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/port", &tmp, + NULL, NULL, NULL)) + return purple_global_proxy_get_info(); + info.port = atoi(tmp); + g_free(tmp); - return &info; - } - return purple_global_proxy_get_info(); + return &info; } /************************************************************************** * Proxy API