From: Patrik Flykt <[email protected]>

Factor out keyfile loading from connman_provider_load() into
a fuction of its own.
---
 src/provider.c |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/provider.c b/src/provider.c
index a041f91..1f95282 100644
--- a/src/provider.c
+++ b/src/provider.c
@@ -76,20 +76,14 @@ void __connman_provider_append_properties(struct 
connman_provider *provider,
                                                 &provider->type);
 }
 
-static int connman_provider_load(struct connman_provider *provider)
+static int provider_load_from_keyfile(struct connman_provider *provider,
+               GKeyFile *keyfile)
 {
        gsize idx = 0;
-       GKeyFile *keyfile;
        gchar **settings;
        gchar *key, *value;
        gsize length;
 
-       DBG("provider %p", provider);
-
-       keyfile = __connman_storage_load_provider(provider->identifier);
-       if (keyfile == NULL)
-               return -ENOENT;
-
        settings = g_key_file_get_keys(keyfile, provider->identifier, &length,
                                NULL);
        if (settings == NULL) {
@@ -99,7 +93,6 @@ static int connman_provider_load(struct connman_provider 
*provider)
 
        while (idx < length) {
                key = settings[idx];
-               DBG("found key %s", key);
                if (key != NULL) {
                        value = g_key_file_get_string(keyfile,
                                                provider->identifier,
@@ -111,6 +104,21 @@ static int connman_provider_load(struct connman_provider 
*provider)
        }
        g_strfreev(settings);
 
+       return 0;
+}
+
+static int connman_provider_load(struct connman_provider *provider)
+{
+       GKeyFile *keyfile;
+
+       DBG("provider %p", provider);
+
+       keyfile = __connman_storage_load_provider(provider->identifier);
+       if (keyfile == NULL)
+               return -ENOENT;
+
+       provider_load_from_keyfile(provider, keyfile);
+
        g_key_file_free(keyfile);
        return 0;
 }
-- 
1.7.2.5

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to