summaryrefslogtreecommitdiffstats
path: root/binding
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2019-06-03 15:02:42 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2019-06-03 15:03:09 -0700
commit19d20dfc03fc1f430c15ec2b4db45e9ec26a9937 (patch)
tree012b17635374732fab48c6987526f79d6d4154e1 /binding
parent4d31aa48b0c43612532d1e4dd965291554d3b399 (diff)
binding: telephony: remove indents in ofono_manager_set_default_modem()
Reduce indents in ofono_manager_set_default_modem() function to make it more concise. Bug-AGL: SPEC-2481 Change-Id: I8aabd42c024792afbd95abd0938d1d487afcb318 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding')
-rw-r--r--binding/gdbus/ofono_manager.c86
1 files changed, 42 insertions, 44 deletions
diff --git a/binding/gdbus/ofono_manager.c b/binding/gdbus/ofono_manager.c
index 98d8c5b..8db5df3 100644
--- a/binding/gdbus/ofono_manager.c
+++ b/binding/gdbus/ofono_manager.c
@@ -48,56 +48,54 @@ int ofono_manager_set_default_modem(const char *address)
const gchar *name = NULL, *type = NULL, *serial = NULL;
gboolean powered = FALSE, online = FALSE;
GVariantIter *iter, *iter2 = NULL;
- int ret = 0;
/* Fetch all visible modems */
org_ofono_manager_call_get_modems_sync(manager, &out_arg, NULL, &error);
- if (error == NULL) {
- g_variant_get(out_arg, "a(oa{sv})", &iter);
- /* Iterate over each modem */
- while ((next = g_variant_iter_next_value(iter))) {
- g_variant_get(next, "(oa{sv})", &path, &iter2);
- while (g_variant_iter_loop(iter2, "{sv}", &key, &value)) {
- if (!strcmp(key, "Name"))
- name = g_variant_get_string(value, NULL);
- else if (!strcmp(key, "Online"))
- online = g_variant_get_boolean(value);
- else if (!strcmp(key, "Powered"))
- powered = g_variant_get_boolean(value);
- else if (!strcmp(key, "Serial"))
- serial = g_variant_get_string(value, NULL);
- else if (!strcmp(key, "Type"))
- type = g_variant_get_string(value, NULL);
- }
-
- /* If not a HFP modem then continue */
- if (g_strcmp0(type, "hfp"))
- continue;
-
- /* If address is NULL then use the first modem as default,
- * and if not then continue if doesn't match address.
- */
- if (address && g_strcmp0(address, serial))
- continue;
-
- /* If powered, and online then set as default */
- if (powered && online) {
- default_modem.address = serial;
- default_modem.path = path;
- default_modem.name = name;
- default_modem.type = type;
- default_modem.powered = powered;
- default_modem.online = online;
- default_modem.valid = TRUE;
- AFB_NOTICE("New modem: %s (%s)", name, serial);
- break;
- }
+ if (error != NULL)
+ return -1;
+
+ g_variant_get(out_arg, "a(oa{sv})", &iter);
+ /* Iterate over each modem */
+ while ((next = g_variant_iter_next_value(iter))) {
+ g_variant_get(next, "(oa{sv})", &path, &iter2);
+ while (g_variant_iter_loop(iter2, "{sv}", &key, &value)) {
+ if (!strcmp(key, "Name"))
+ name = g_variant_get_string(value, NULL);
+ else if (!strcmp(key, "Online"))
+ online = g_variant_get_boolean(value);
+ else if (!strcmp(key, "Powered"))
+ powered = g_variant_get_boolean(value);
+ else if (!strcmp(key, "Serial"))
+ serial = g_variant_get_string(value, NULL);
+ else if (!strcmp(key, "Type"))
+ type = g_variant_get_string(value, NULL);
+ }
+
+ /* If not a HFP modem then continue */
+ if (g_strcmp0(type, "hfp"))
+ continue;
+
+ /* If address is NULL then use the first modem as default,
+ * and if not then continue if doesn't match address.
+ */
+ if (address && g_strcmp0(address, serial))
+ continue;
+
+ /* If powered, and online then set as default */
+ if (powered && online) {
+ default_modem.address = serial;
+ default_modem.path = path;
+ default_modem.name = name;
+ default_modem.type = type;
+ default_modem.powered = powered;
+ default_modem.online = online;
+ default_modem.valid = TRUE;
+ AFB_NOTICE("New modem: %s (%s)", name, serial);
+ break;
}
- } else {
- ret = -1;
}
- return ret;
+ return 0;
}
int ofono_manager_init()