Remove some heavy nesting that is not needed at all
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 23 Mar 2010 02:32:47 +0000 (19:32 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 23 Mar 2010 02:32:47 +0000 (19:32 -0700)
gatchat/ppp_cp.c

index ac5dcb3..458b7c7 100644 (file)
@@ -1057,21 +1057,21 @@ static void verify_config_option(gpointer elem, gpointer user_data)
 {
        struct ppp_option *config = elem;
        struct pppcp_data *data = user_data;
-       GList *list = NULL;
-       struct ppp_option *option;
+       guint type = config->type;
+       GList *list;
 
        /*
         * determine whether this config option is in the
         * acceptable options list
         */
-       if (g_list_length(data->acceptable_options)) {
-               guint type = config->type;
+       if (g_list_length(data->acceptable_options) == 0)
+               return;
 
-               list = g_list_find_custom(data->acceptable_options,
+       list = g_list_find_custom(data->acceptable_options,
                                GUINT_TO_POINTER(type), is_option);
-       }
-
        if (!list) {
+               struct ppp_option *option;
+
                /*
                 * if the option did not exist, we need to store a copy
                 * of the option in the unacceptable_options list so it
@@ -1080,33 +1080,33 @@ static void verify_config_option(gpointer elem, gpointer user_data)
                option = g_try_malloc0(config->length);
                if (option == NULL)
                        return;
+
                option->type = config->type;
                option->length = config->length;
                data->unacceptable_options =
                        g_list_append(data->unacceptable_options, option);
        }
-
 }
 
 static void remove_config_option(gpointer elem, gpointer user_data)
 {
        struct ppp_option *config = elem;
        struct pppcp_data *data = user_data;
+       guint type = config->type;
        GList *list;
 
        /*
         * determine whether this config option is in the
         * applied options list
         */
-       if (g_list_length(data->config_options)) {
-               guint type = config->type;
+       if (g_list_length(data->config_options) == 0)
+               return;
 
-               list = g_list_find_custom(data->config_options,
-                                       GUINT_TO_POINTER(type), is_option);
-               if (list)
-                       data->config_options =
+       list = g_list_find_custom(data->config_options,
+                               GUINT_TO_POINTER(type), is_option);
+       if (list)
+               data->config_options =
                                g_list_delete_link(data->config_options, list);
-       }
 }
 
 static guint8 pppcp_process_configure_request(struct pppcp_data *data,