session: Pick directly first policy in list
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Wed, 31 Oct 2012 09:33:29 +0000 (10:33 +0100)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Mon, 5 Nov 2012 12:40:58 +0000 (14:40 +0200)
There is no point in iterating over the list when we always
pick the first element in the list.

src/session.c

index e489742..c981bef 100644 (file)
@@ -220,18 +220,13 @@ static char *service2bearer(enum connman_service_type type)
 
 static int assign_policy_plugin(struct connman_session *session)
 {
-       GSList *list;
-       struct connman_session_policy *policy;
-
        if (session->policy != NULL)
                return -EALREADY;
 
-       for (list = policy_list; list != NULL; list = list->next) {
-               policy = list->data;
+       if (policy_list == NULL)
+               return 0;
 
-               session->policy = policy;
-               break;
-       }
+       session->policy = policy_list->data;
 
        return 0;
 }