Send connman mailing list submissions to
        [email protected]

To subscribe or unsubscribe via email, send a message with subject or
body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."

Today's Topics:

   1. [PATCH v2 0/3] Simplify settings save code (Daniel Wagner)
   2. [PATCH v2 2/3] ipconfig: Refactor keyfile store and load operations
      (Daniel Wagner)
   3. [PATCH v2 1/3] service: Store configuration in empty keyfile
      (Daniel Wagner)
   4. [PATCH v2 3/3] storage: Remove unused __connman_storage_open_service()
      (Daniel Wagner)


----------------------------------------------------------------------

Date: Wed,  1 Jan 2020 16:22:57 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH v2 0/3] Simplify settings save code
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>

Start with an empty kefile for storing the current configuration. Thus
we can drop the configuration update code. While at it also refactor
the keyfile code in ipconfig and save around 1k of code.

Daniel Wagner (3):
  service: Store configuration in empty keyfile
  ipconfig: Refactor keyfile store and load operations
  storage: Remove unused __connman_storage_open_service()

 src/connman.h  |   5 +-
 src/ipconfig.c | 269 ++++++++++++++++++++++++++-----------------------
 src/service.c  |  59 ++++-------
 src/storage.c  |  22 ----
 4 files changed, 161 insertions(+), 194 deletions(-)

-- 
2.24.1

------------------------------

Date: Wed,  1 Jan 2020 16:22:59 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH v2 2/3] ipconfig: Refactor keyfile store and load
        operations
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>

Move the open coded lookup key generation into a small helpers which
create the ipconfig prefix (IPv4 or IPv6). Also move the checks into
the helper which are generic. This makes the save and load functions
less cluttered.
---
 src/connman.h  |   4 +-
 src/ipconfig.c | 265 ++++++++++++++++++++++++++-----------------------
 2 files changed, 141 insertions(+), 128 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index e64739f2e4f4..2ae61c71847f 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -423,9 +423,9 @@ void __connman_ipconfig_set_dhcpv6_prefixes(struct 
connman_ipconfig *ipconfig,
                                        char **prefixes);
 char **__connman_ipconfig_get_dhcpv6_prefixes(struct connman_ipconfig 
*ipconfig);
 
-int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
+void __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
                GKeyFile *keyfile, const char *identifier, const char *prefix);
-int __connman_ipconfig_save(struct connman_ipconfig *ipconfig,
+void __connman_ipconfig_save(struct connman_ipconfig *ipconfig,
                GKeyFile *keyfile, const char *identifier, const char *prefix);
 bool __connman_ipconfig_ipv6_privacy_enabled(struct connman_ipconfig 
*ipconfig);
 int __connman_ipconfig_ipv6_reset_privacy(struct connman_ipconfig *ipconfig);
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 4a9d575039bc..d375fe0df2fd 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -85,10 +85,103 @@ struct connman_ipdevice {
        int ipv6_privacy;
 };
 
+struct ipconfig_store {
+       GKeyFile *file;
+       const char *group;
+       const char *prefix;
+};
+
 static GHashTable *ipdevice_hash = NULL;
 static GList *ipconfig_list = NULL;
 static bool is_ipv6_supported = false;
 
+static void store_set_str(struct ipconfig_store *store,
+                       const char *key, const char *val)
+
+{
+       char *pk;
+
+       if (!val || strlen(val) == 0)
+               return;
+
+       pk = g_strdup_printf("%s%s", store->prefix, key);
+       g_key_file_set_string(store->file, store->group, pk, val);
+       g_free(pk);
+}
+
+static char *store_get_str(struct ipconfig_store *store, const char *key)
+{
+       char *pk, *val;
+
+       pk = g_strdup_printf("%s%s", store->prefix, key);
+       val = g_key_file_get_string(store->file, store->group, pk, NULL);
+       g_free(pk);
+
+       return val;
+}
+
+static void store_set_strs(struct ipconfig_store *store,
+                       const char *key, char **val)
+{
+       guint len;
+       char *pk;
+
+       if (!val)
+               return;
+
+       len = g_strv_length(val);
+       if (len == 0)
+               return;
+
+       pk = g_strdup_printf("%s%s", store->prefix, key);
+       g_key_file_set_string_list(store->file, store->group,
+                               pk, (const gchar **)val, len);
+       g_free(pk);
+}
+
+static char **store_get_strs(struct ipconfig_store *store, const char *key)
+{
+       gsize len;
+       char *pk, **val;
+
+       pk = g_strdup_printf("%s%s", store->prefix, key);
+       val = g_key_file_get_string_list(store->file, store->group,
+                                       pk, &len, NULL);
+       g_free(pk);
+
+       if (val && len == 0) {
+               g_free(val);
+               return NULL;
+       }
+
+       return val;
+}
+
+static void store_set_int(struct ipconfig_store *store,
+                       const char *key, int val)
+{
+       char *pk;
+
+       if (val == 0)
+               return;
+
+       pk = g_strdup_printf("%s%s", store->prefix, key);
+       g_key_file_set_integer(store->file, store->group, key, val);
+       g_free(pk);
+}
+
+static int store_get_int(struct ipconfig_store *store, const char *key)
+{
+       int val;
+       char *pk;
+
+       pk = g_strdup_printf("%s%s", store->prefix, key);
+       val = g_key_file_get_integer(store->file, store->group, key, 0);
+       g_free(pk);
+
+       return val;
+}
+
 void __connman_ipconfig_clear_address(struct connman_ipconfig *ipconfig)
 {
        if (!ipconfig)
@@ -2124,65 +2217,56 @@ void __connman_ipconfig_append_ethernet(struct 
connman_ipconfig *ipconfig,
                                        DBUS_TYPE_UINT16, &ipdevice->mtu);
 }
 
-int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
+void __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
                GKeyFile *keyfile, const char *identifier, const char *prefix)
 {
        char *method;
-       char *key;
        char *str;
+       struct ipconfig_store is = { .file = keyfile,
+                                    .group = identifier,
+                                    .prefix = prefix };
 
        DBG("ipconfig %p identifier %s", ipconfig, identifier);
 
-       key = g_strdup_printf("%smethod", prefix);
-       method = g_key_file_get_string(keyfile, identifier, key, NULL);
+       method = store_get_str(&is, "method");
        if (!method) {
                switch (ipconfig->type) {
                case CONNMAN_IPCONFIG_TYPE_IPV4:
                        ipconfig->method = CONNMAN_IPCONFIG_METHOD_DHCP;
                        break;
+
                case CONNMAN_IPCONFIG_TYPE_IPV6:
                        ipconfig->method = CONNMAN_IPCONFIG_METHOD_AUTO;
                        break;
+
                case CONNMAN_IPCONFIG_TYPE_UNKNOWN:
                case CONNMAN_IPCONFIG_TYPE_ALL:
                        ipconfig->method = CONNMAN_IPCONFIG_METHOD_OFF;
                        break;
                }
-       } else
+       } else {
                ipconfig->method = __connman_ipconfig_string2method(method);
+               g_free(method);
+       }
 
        if (ipconfig->method == CONNMAN_IPCONFIG_METHOD_UNKNOWN)
                ipconfig->method = CONNMAN_IPCONFIG_METHOD_OFF;
 
        if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6) {
-               gsize length;
-               char *pprefix;
-
                if (ipconfig->method == CONNMAN_IPCONFIG_METHOD_AUTO ||
-                       ipconfig->method == CONNMAN_IPCONFIG_METHOD_MANUAL) {
+                               ipconfig->method == 
CONNMAN_IPCONFIG_METHOD_MANUAL) {
                        char *privacy;
 
-                       pprefix = g_strdup_printf("%sprivacy", prefix);
-                       privacy = g_key_file_get_string(keyfile, identifier,
-                                                       pprefix, NULL);
+                       privacy = store_get_str(&is, "privacy");
                        ipconfig->ipv6_privacy_config = string2privacy(privacy);
-                       g_free(pprefix);
                        g_free(privacy);
                }
 
-               pprefix = g_strdup_printf("%sDHCP.LastPrefixes", prefix);
+               g_strfreev(ipconfig->last_dhcpv6_prefixes);
                ipconfig->last_dhcpv6_prefixes =
-                       g_key_file_get_string_list(keyfile, identifier, pprefix,
-                                               &length, NULL);
-               if (ipconfig->last_dhcpv6_prefixes && length == 0) {
-                       g_free(ipconfig->last_dhcpv6_prefixes);
-                       ipconfig->last_dhcpv6_prefixes = NULL;
-               }
-               g_free(pprefix);
+                       store_get_strs(&is, "DHCP.LastPrefixes");
        }
 
-       g_free(method);
-       g_free(key);
 
        switch (ipconfig->method) {
        case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
@@ -2191,39 +2275,27 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
 
        case CONNMAN_IPCONFIG_METHOD_FIXED:
        case CONNMAN_IPCONFIG_METHOD_MANUAL:
+               ipconfig->address->prefixlen =
+                       store_get_int(&is, "netmask_prefixlen");
 
-               key = g_strdup_printf("%snetmask_prefixlen", prefix);
-               ipconfig->address->prefixlen = g_key_file_get_integer(
-                               keyfile, identifier, key, NULL);
-               g_free(key);
-
-               key = g_strdup_printf("%slocal_address", prefix);
                g_free(ipconfig->address->local);
-               ipconfig->address->local = g_key_file_get_string(
-                       keyfile, identifier, key, NULL);
-               g_free(key);
+               ipconfig->address->local =
+                       store_get_str(&is, "local_address");
 
-               key = g_strdup_printf("%speer_address", prefix);
                g_free(ipconfig->address->peer);
-               ipconfig->address->peer = g_key_file_get_string(
-                               keyfile, identifier, key, NULL);
-               g_free(key);
+               ipconfig->address->peer =
+                       store_get_str(&is, "peer_address");
 
-               key = g_strdup_printf("%sbroadcast_address", prefix);
                g_free(ipconfig->address->broadcast);
-               ipconfig->address->broadcast = g_key_file_get_string(
-                               keyfile, identifier, key, NULL);
-               g_free(key);
+               ipconfig->address->broadcast =
+                       store_get_str(&is, "broadcast_address");
 
-               key = g_strdup_printf("%sgateway", prefix);
                g_free(ipconfig->address->gateway);
-               ipconfig->address->gateway = g_key_file_get_string(
-                               keyfile, identifier, key, NULL);
-               g_free(key);
+               ipconfig->address->gateway =
+                       store_get_str(&is, "gateway");
                break;
 
        case CONNMAN_IPCONFIG_METHOD_AUTO:
-
                if (ipconfig->type != CONNMAN_IPCONFIG_TYPE_IPV4)
                        break;
 
@@ -2237,120 +2309,61 @@ int __connman_ipconfig_load(struct connman_ipconfig 
*ipconfig,
                /* fall through */
 
        case CONNMAN_IPCONFIG_METHOD_DHCP:
-
-               key = g_strdup_printf("%sDHCP.LastAddress", prefix);
-               str = g_key_file_get_string(keyfile, identifier, key, NULL);
+               str = store_get_str(&is, "DHCP.LastAddress");
                if (str) {
                        g_free(ipconfig->last_dhcp_address);
                        ipconfig->last_dhcp_address = str;
                }
-               g_free(key);
 
                break;
        }
-
-       return 0;
 }
 
-int __connman_ipconfig_save(struct connman_ipconfig *ipconfig,
+void __connman_ipconfig_save(struct connman_ipconfig *ipconfig,
                GKeyFile *keyfile, const char *identifier, const char *prefix)
 {
        const char *method;
-       char *key;
+       struct ipconfig_store is = { .file = keyfile,
+                                    .group = identifier,
+                                    .prefix = prefix };
 
        method = __connman_ipconfig_method2string(ipconfig->method);
-
        DBG("ipconfig %p identifier %s method %s", ipconfig, identifier,
                                                                method);
-       if (method) {
-               key = g_strdup_printf("%smethod", prefix);
-               g_key_file_set_string(keyfile, identifier, key, method);
-               g_free(key);
-       }
+       store_set_str(&is, "method", method);
 
        if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6) {
-               const char *privacy;
-               privacy = privacy2string(ipconfig->ipv6_privacy_config);
-               key = g_strdup_printf("%sprivacy", prefix);
-               g_key_file_set_string(keyfile, identifier, key, privacy);
-               g_free(key);
-
-               if (ipconfig->last_dhcp_address &&
-                               strlen(ipconfig->last_dhcp_address) > 0) {
-                       key = g_strdup_printf("%sDHCP.LastAddress", prefix);
-                       g_key_file_set_string(keyfile, identifier, key,
-                                       ipconfig->last_dhcp_address);
-                       g_free(key);
-               }
+               store_set_str(&is, "privacy",
+                               privacy2string(ipconfig->ipv6_privacy_config));
 
-               if (ipconfig->last_dhcpv6_prefixes &&
-                               ipconfig->last_dhcpv6_prefixes[0]) {
-                       guint len =
-                               g_strv_length(ipconfig->last_dhcpv6_prefixes);
-                       key = g_strdup_printf("%sDHCP.LastPrefixes", prefix);
+               store_set_str(&is, "DHCP.LastAddress",
+                               ipconfig->last_dhcp_address);
 
-                       g_key_file_set_string_list(keyfile, identifier, key,
-                               (const gchar **)ipconfig->last_dhcpv6_prefixes,
-                                               len);
-                       g_free(key);
-               }
+               store_set_strs(&is, "DHCP.LastPrefixes",
+                               ipconfig->last_dhcpv6_prefixes);
        }
 
        switch (ipconfig->method) {
        case CONNMAN_IPCONFIG_METHOD_FIXED:
        case CONNMAN_IPCONFIG_METHOD_MANUAL:
                break;
+
        case CONNMAN_IPCONFIG_METHOD_DHCP:
-               if (ipconfig->last_dhcp_address &&
-                               strlen(ipconfig->last_dhcp_address) > 0) {
-                       key = g_strdup_printf("%sDHCP.LastAddress", prefix);
-                       g_key_file_set_string(keyfile, identifier, key,
-                                       ipconfig->last_dhcp_address);
-                       g_free(key);
-               }
+               store_set_str(&is, "DHCP.LastAddress",
+                               ipconfig->last_dhcp_address);
                /* fall through */
+
        case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
        case CONNMAN_IPCONFIG_METHOD_OFF:
        case CONNMAN_IPCONFIG_METHOD_AUTO:
-               return 0;
-       }
-
-       if (ipconfig->address->prefixlen != 0) {
-               key = g_strdup_printf("%snetmask_prefixlen", prefix);
-               g_key_file_set_integer(keyfile, identifier,
-                               key, ipconfig->address->prefixlen);
-               g_free(key);
-       }
-
-       if (ipconfig->address->local) {
-               key = g_strdup_printf("%slocal_address", prefix);
-               g_key_file_set_string(keyfile, identifier,
-                               key, ipconfig->address->local);
-               g_free(key);
-       }
-
-       if (ipconfig->address->peer) {
-               key = g_strdup_printf("%speer_address", prefix);
-               g_key_file_set_string(keyfile, identifier,
-                               key, ipconfig->address->peer);
-               g_free(key);
-       }
-
-       if (ipconfig->address->broadcast) {
-               key = g_strdup_printf("%sbroadcast_address", prefix);
-               g_key_file_set_string(keyfile, identifier,
-                       key, ipconfig->address->broadcast);
-               g_free(key);
-       }
-
-       if (ipconfig->address->gateway) {
-               key = g_strdup_printf("%sgateway", prefix);
-               g_key_file_set_string(keyfile, identifier,
-                       key, ipconfig->address->gateway);
-               g_free(key);
+               return;
        }
 
-       return 0;
+       store_set_int(&is, "netmask_prefixlen", ipconfig->address->prefixlen);
+       store_set_str(&is, "local_address", ipconfig->address->local);
+       store_set_str(&is, "peer_address", ipconfig->address->peer);
+       store_set_str(&is, "broadcast_address", ipconfig->address->broadcast);
+       store_set_str(&is, "gateway", ipconfig->address->gateway);
 }
 
 int __connman_ipconfig_init(void)
-- 
2.24.1

------------------------------

Date: Wed,  1 Jan 2020 16:22:58 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH v2 1/3] service: Store configuration in empty keyfile
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>

Instead loading the keyfile from disk with the old configuration,
start with an empty configuration. Because we do not have a previous
configuration which needs to be updated we can drop all the remove
code. This avoids complex code paths when switching from one
connnection method to the next one (dhcp to manual and back).
---
 src/ipconfig.c | 62 +++++++++++++++++++++++++-------------------------
 src/service.c  | 59 +++++++++++++++--------------------------------
 2 files changed, 49 insertions(+), 72 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index 25657733571a..4a9d575039bc 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -2275,27 +2275,25 @@ int __connman_ipconfig_save(struct connman_ipconfig 
*ipconfig,
                g_key_file_set_string(keyfile, identifier, key, privacy);
                g_free(key);
 
-               key = g_strdup_printf("%sDHCP.LastAddress", prefix);
                if (ipconfig->last_dhcp_address &&
-                               strlen(ipconfig->last_dhcp_address) > 0)
+                               strlen(ipconfig->last_dhcp_address) > 0) {
+                       key = g_strdup_printf("%sDHCP.LastAddress", prefix);
                        g_key_file_set_string(keyfile, identifier, key,
                                        ipconfig->last_dhcp_address);
-               else
-                       g_key_file_remove_key(keyfile, identifier, key, NULL);
-               g_free(key);
+                       g_free(key);
+               }
 
-               key = g_strdup_printf("%sDHCP.LastPrefixes", prefix);
                if (ipconfig->last_dhcpv6_prefixes &&
                                ipconfig->last_dhcpv6_prefixes[0]) {
                        guint len =
                                g_strv_length(ipconfig->last_dhcpv6_prefixes);
+                       key = g_strdup_printf("%sDHCP.LastPrefixes", prefix);
 
                        g_key_file_set_string_list(keyfile, identifier, key,
                                (const gchar **)ipconfig->last_dhcpv6_prefixes,
                                                len);
-               } else
-                       g_key_file_remove_key(keyfile, identifier, key, NULL);
-               g_free(key);
+                       g_free(key);
+               }
        }
 
        switch (ipconfig->method) {
@@ -2303,14 +2301,13 @@ int __connman_ipconfig_save(struct connman_ipconfig 
*ipconfig,
        case CONNMAN_IPCONFIG_METHOD_MANUAL:
                break;
        case CONNMAN_IPCONFIG_METHOD_DHCP:
-               key = g_strdup_printf("%sDHCP.LastAddress", prefix);
                if (ipconfig->last_dhcp_address &&
-                               strlen(ipconfig->last_dhcp_address) > 0)
+                               strlen(ipconfig->last_dhcp_address) > 0) {
+                       key = g_strdup_printf("%sDHCP.LastAddress", prefix);
                        g_key_file_set_string(keyfile, identifier, key,
                                        ipconfig->last_dhcp_address);
-               else
-                       g_key_file_remove_key(keyfile, identifier, key, NULL);
-               g_free(key);
+                       g_free(key);
+               }
                /* fall through */
        case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
        case CONNMAN_IPCONFIG_METHOD_OFF:
@@ -2318,37 +2315,40 @@ int __connman_ipconfig_save(struct connman_ipconfig 
*ipconfig,
                return 0;
        }
 
-       key = g_strdup_printf("%snetmask_prefixlen", prefix);
-       if (ipconfig->address->prefixlen != 0)
+       if (ipconfig->address->prefixlen != 0) {
+               key = g_strdup_printf("%snetmask_prefixlen", prefix);
                g_key_file_set_integer(keyfile, identifier,
                                key, ipconfig->address->prefixlen);
-       g_free(key);
+               g_free(key);
+       }
 
-       key = g_strdup_printf("%slocal_address", prefix);
-       if (ipconfig->address->local)
+       if (ipconfig->address->local) {
+               key = g_strdup_printf("%slocal_address", prefix);
                g_key_file_set_string(keyfile, identifier,
                                key, ipconfig->address->local);
-       g_free(key);
+               g_free(key);
+       }
 
-       key = g_strdup_printf("%speer_address", prefix);
-       if (ipconfig->address->peer)
+       if (ipconfig->address->peer) {
+               key = g_strdup_printf("%speer_address", prefix);
                g_key_file_set_string(keyfile, identifier,
                                key, ipconfig->address->peer);
-       g_free(key);
+               g_free(key);
+       }
 
-       key = g_strdup_printf("%sbroadcast_address", prefix);
-       if (ipconfig->address->broadcast)
+       if (ipconfig->address->broadcast) {
+               key = g_strdup_printf("%sbroadcast_address", prefix);
                g_key_file_set_string(keyfile, identifier,
                        key, ipconfig->address->broadcast);
-       g_free(key);
+               g_free(key);
+       }
 
-       key = g_strdup_printf("%sgateway", prefix);
-       if (ipconfig->address->gateway)
+       if (ipconfig->address->gateway) {
+               key = g_strdup_printf("%sgateway", prefix);
                g_key_file_set_string(keyfile, identifier,
                        key, ipconfig->address->gateway);
-       else
-               g_key_file_remove_key(keyfile, identifier, key, NULL);
-       g_free(key);
+               g_free(key);
+       }
 
        return 0;
 }
diff --git a/src/service.c b/src/service.c
index 22e94f7bf3c7..4d1235e3cf1e 100644
--- a/src/service.c
+++ b/src/service.c
@@ -631,7 +631,7 @@ static int service_save(struct connman_service *service)
        if (service->new_service)
                return -ESRCH;
 
-       keyfile = __connman_storage_open_service(service->identifier);
+       keyfile = g_key_file_new();
        if (!keyfile)
                return -EIO;
 
@@ -693,9 +693,6 @@ static int service_save(struct connman_service *service)
                g_key_file_set_boolean(keyfile, service->identifier,
                                        "Favorite", service->favorite);
 
-               g_key_file_remove_key(keyfile, service->identifier,
-                               "Failure", NULL);
-
                /* fall through */
 
        case CONNMAN_SERVICE_TYPE_ETHERNET:
@@ -708,54 +705,45 @@ static int service_save(struct connman_service *service)
        str = util_timeval_to_iso8601(&service->modified);
        if (str) {
                g_key_file_set_string(keyfile, service->identifier,
-                                                       "Modified", str);
+                               "Modified", str);
                g_free(str);
        }
 
        if (service->passphrase && strlen(service->passphrase) > 0)
                g_key_file_set_string(keyfile, service->identifier,
-                                       "Passphrase", service->passphrase);
-       else
-               g_key_file_remove_key(keyfile, service->identifier,
-                                                       "Passphrase", NULL);
+                               "Passphrase", service->passphrase);
 
        if (service->ipconfig_ipv4)
                __connman_ipconfig_save(service->ipconfig_ipv4, keyfile,
-                                       service->identifier, "IPv4.");
+                               service->identifier, "IPv4.");
 
        if (service->ipconfig_ipv6)
                __connman_ipconfig_save(service->ipconfig_ipv6, keyfile,
-                                               service->identifier, "IPv6.");
+                               service->identifier, "IPv6.");
 
        if (service->nameservers_config) {
                guint len = g_strv_length(service->nameservers_config);
 
                g_key_file_set_string_list(keyfile, service->identifier,
-                                                               "Nameservers",
+                               "Nameservers",
                                (const gchar **) service->nameservers_config, 
len);
-       } else
-       g_key_file_remove_key(keyfile, service->identifier,
-                                                       "Nameservers", NULL);
+       }
 
        if (service->timeservers_config) {
                guint len = g_strv_length(service->timeservers_config);
 
                g_key_file_set_string_list(keyfile, service->identifier,
-                                                               "Timeservers",
+                               "Timeservers",
                                (const gchar **) service->timeservers_config, 
len);
-       } else
-               g_key_file_remove_key(keyfile, service->identifier,
-                                                       "Timeservers", NULL);
+       }
 
        if (service->domains) {
                guint len = g_strv_length(service->domains);
 
                g_key_file_set_string_list(keyfile, service->identifier,
-                                                               "Domains",
+                               "Domains",
                                (const gchar **) service->domains, len);
-       } else
-               g_key_file_remove_key(keyfile, service->identifier,
-                                                       "Domains", NULL);
+       }
 
        cst_str = proxymethod2string(service->proxy_config);
        if (cst_str)
@@ -768,9 +756,7 @@ static int service_save(struct connman_service *service)
                g_key_file_set_string_list(keyfile, service->identifier,
                                "Proxy.Servers",
                                (const gchar **) service->proxies, len);
-       } else
-               g_key_file_remove_key(keyfile, service->identifier,
-                                               "Proxy.Servers", NULL);
+       }
 
        if (service->excludes) {
                guint len = g_strv_length(service->excludes);
@@ -778,34 +764,25 @@ static int service_save(struct connman_service *service)
                g_key_file_set_string_list(keyfile, service->identifier,
                                "Proxy.Excludes",
                                (const gchar **) service->excludes, len);
-       } else
-               g_key_file_remove_key(keyfile, service->identifier,
-                                               "Proxy.Excludes", NULL);
+       }
 
        if (service->pac && strlen(service->pac) > 0)
                g_key_file_set_string(keyfile, service->identifier,
-                                       "Proxy.URL", service->pac);
-       else
-               g_key_file_remove_key(keyfile, service->identifier,
-                                                       "Proxy.URL", NULL);
+                               "Proxy.URL", service->pac);
 
        if (service->mdns_config)
                g_key_file_set_boolean(keyfile, service->identifier,
-                                                               "mDNS", TRUE);
-       else
-               g_key_file_remove_key(keyfile, service->identifier,
-                                                               "mDNS", NULL);
+                               "mDNS", TRUE);
 
        if (service->hidden_service)
-               g_key_file_set_boolean(keyfile, service->identifier, "Hidden",
-                                                                       TRUE);
+               g_key_file_set_boolean(keyfile, service->identifier,
+                               "Hidden", TRUE);
 
        if (service->config_file && strlen(service->config_file) > 0)
                g_key_file_set_string(keyfile, service->identifier,
                                "Config.file", service->config_file);
 
-       if (service->config_entry &&
-                                       strlen(service->config_entry) > 0)
+       if (service->config_entry && strlen(service->config_entry) > 0)
                g_key_file_set_string(keyfile, service->identifier,
                                "Config.ident", service->config_entry);
 
-- 
2.24.1

------------------------------

Date: Wed,  1 Jan 2020 16:23:00 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH v2 3/3] storage: Remove unused
        __connman_storage_open_service()
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>

There is no user left for __connman_storage_open_service(). Thus
remove it.
---
 src/connman.h |  1 -
 src/storage.c | 22 ----------------------
 2 files changed, 23 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 2ae61c71847f..61526bb58947 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -273,7 +273,6 @@ void __connman_storage_delete_global(void);
 GKeyFile *__connman_storage_load_config(const char *ident);
 GKeyFile *__connman_storage_load_provider_config(const char *ident);
 
-GKeyFile *__connman_storage_open_service(const char *ident);
 int __connman_storage_save_service(GKeyFile *keyfile, const char *ident);
 GKeyFile *__connman_storage_load_provider(const char *identifier);
 void __connman_storage_save_provider(GKeyFile *keyfile, const char 
*identifier);
diff --git a/src/storage.c b/src/storage.c
index 5e877ef10375..90f03ebc76e3 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -161,28 +161,6 @@ GKeyFile *__connman_storage_load_provider_config(const 
char *ident)
        return keyfile;
 }
 
-GKeyFile *__connman_storage_open_service(const char *service_id)
-{
-       gchar *pathname;
-       GKeyFile *keyfile = NULL;
-
-       pathname = g_strdup_printf("%s/%s/%s", STORAGEDIR, service_id, 
SETTINGS);
-       if (!pathname)
-               return NULL;
-
-       keyfile =  storage_load(pathname);
-       if (keyfile) {
-               g_free(pathname);
-               return keyfile;
-       }
-
-       g_free(pathname);
-
-       keyfile = g_key_file_new();
-
-       return keyfile;
-}
-
 gchar **connman_storage_get_services(void)
 {
        struct dirent *d;
-- 
2.24.1

------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list -- [email protected]
To unsubscribe send an email to [email protected]


------------------------------

End of connman Digest, Vol 51, Issue 1
**************************************

Reply via email to