[PATCH 2/4] ofono: Use goto error-handling semantics in 'add_cm_context'.
Grant Erickson <[email protected]>
| Newsgroups | dev.linux.lists.connman |
|---|---|
| Message-ID | <176e12723e92e75ea8b62cad6b622306002cfcf1.1739403363.git.gerickson@nuovations.com> |
Eases current and future debugging of ofono cellular context additions
by allowing for a single point of DBG instrumentation for the
'add_cm_context' return value, indicating whether or not the proposed
context was added successfully.
---
plugins/ofono.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 47f289f605e0..b7a5f80bda5c 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -1160,12 +1160,15 @@ static int add_cm_context(struct modem_data *modem, const char *context_path,
struct network_context *context = NULL;
dbus_bool_t active = FALSE;
const char *ip_protocol = NULL;
+ int err = 0;
DBG("%s context path %s", modem->path, context_path);
context = network_context_alloc(context_path);
- if (!context)
- return -ENOMEM;
+ if (!context) {
+ err = -ENOMEM;
+ goto done;
+ }
while (dbus_message_iter_get_arg_type(dict) == DBUS_TYPE_DICT_ENTRY) {
DBusMessageIter entry, value;
@@ -1217,7 +1220,8 @@ static int add_cm_context(struct modem_data *modem, const char *context_path,
if (g_strcmp0(context_type, "internet") != 0) {
network_context_unref(context);
- return -EINVAL;
+ err = -EINVAL;
+ goto done;
}
if (ip_protocol)
@@ -1232,7 +1236,10 @@ static int add_cm_context(struct modem_data *modem, const char *context_path,
has_interface(modem->interfaces, OFONO_API_NETREG))
add_network(modem, context);
- return 0;
+done:
+ DBG("err %d", err);
+
+ return err;
}
static void remove_cm_context(struct modem_data *modem,
--
2.45.0