aboutsummaryrefslogtreecommitdiff
path: root/plugins/sierra
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/sierra')
-rw-r--r--plugins/sierra/mm-broadband-modem-sierra.c41
-rw-r--r--plugins/sierra/mm-common-sierra.c4
-rw-r--r--plugins/sierra/mm-modem-helpers-sierra.c16
3 files changed, 25 insertions, 36 deletions
diff --git a/plugins/sierra/mm-broadband-modem-sierra.c b/plugins/sierra/mm-broadband-modem-sierra.c
index 3ac20808..bae8e344 100644
--- a/plugins/sierra/mm-broadband-modem-sierra.c
+++ b/plugins/sierra/mm-broadband-modem-sierra.c
@@ -624,7 +624,7 @@ load_current_modes_finish (MMIfaceModem *self,
MMModemMode *preferred,
GError **error)
{
- LoadCurrentModesResult *result;
+ g_autofree LoadCurrentModesResult *result = NULL;
result = g_task_propagate_pointer (G_TASK (res), error);
if (!result)
@@ -632,7 +632,6 @@ load_current_modes_finish (MMIfaceModem *self,
*allowed = result->allowed;
*preferred = result->preferred;
- g_free (result);
return TRUE;
}
@@ -641,11 +640,11 @@ selrat_query_ready (MMBaseModem *self,
GAsyncResult *res,
GTask *task)
{
- LoadCurrentModesResult *result;
- const gchar *response;
- GError *error = NULL;
- GRegex *r = NULL;
- GMatchInfo *match_info = NULL;
+ g_autofree LoadCurrentModesResult *result = NULL;
+ const gchar *response;
+ GError *error = NULL;
+ g_autoptr(GRegex) r = NULL;
+ g_autoptr(GMatchInfo) match_info = NULL;
response = mm_base_modem_at_command_full_finish (self, res, &error);
if (!response) {
@@ -727,15 +726,10 @@ selrat_query_ready (MMBaseModem *self,
"Could not parse allowed mode response: Response didn't match: '%s'",
response);
- g_match_info_free (match_info);
- g_regex_unref (r);
-
- if (error) {
- g_free (result);
+ if (error)
g_task_return_error (task, error);
- } else
- g_task_return_pointer (task, result, g_free);
-
+ else
+ g_task_return_pointer (task, g_steal_pointer (&result), g_free);
g_object_unref (task);
}
@@ -1630,11 +1624,16 @@ parse_time (const gchar *response,
const gchar *tag,
GError **error)
{
- GRegex *r;
- GMatchInfo *match_info = NULL;
- GError *match_error = NULL;
- guint year, month, day, hour, minute, second;
- gchar *result = NULL;
+ g_autoptr(GRegex) r = NULL;
+ g_autoptr(GMatchInfo) match_info = NULL;
+ GError *match_error = NULL;
+ guint year;
+ guint month;
+ guint day;
+ guint hour;
+ guint minute;
+ guint second;
+ gchar *result = NULL;
r = g_regex_new (regex, 0, 0, NULL);
g_assert (r != NULL);
@@ -1665,8 +1664,6 @@ parse_time (const gchar *response,
}
}
- g_match_info_free (match_info);
- g_regex_unref (r);
return result;
}
diff --git a/plugins/sierra/mm-common-sierra.c b/plugins/sierra/mm-common-sierra.c
index 341006d6..72cbc34f 100644
--- a/plugins/sierra/mm-common-sierra.c
+++ b/plugins/sierra/mm-common-sierra.c
@@ -480,7 +480,7 @@ mm_common_sierra_setup_ports (MMBroadbandModem *self)
{
MMPortSerialAt *ports[2];
guint i;
- GRegex *pacsp_regex;
+ g_autoptr(GRegex) pacsp_regex = NULL;
pacsp_regex = g_regex_new ("\\r\\n\\+PACSP.*\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
@@ -505,8 +505,6 @@ mm_common_sierra_setup_ports (MMBroadbandModem *self)
pacsp_regex,
NULL, NULL, NULL);
}
-
- g_regex_unref (pacsp_regex);
}
/*****************************************************************************/
diff --git a/plugins/sierra/mm-modem-helpers-sierra.c b/plugins/sierra/mm-modem-helpers-sierra.c
index ac07c9ee..821be199 100644
--- a/plugins/sierra/mm-modem-helpers-sierra.c
+++ b/plugins/sierra/mm-modem-helpers-sierra.c
@@ -23,16 +23,15 @@ GList *
mm_sierra_parse_scact_read_response (const gchar *reply,
GError **error)
{
- GError *inner_error = NULL;
- GRegex *r;
- GMatchInfo *match_info;
- GList *list;
+ g_autoptr(GRegex) r = NULL;
+ g_autoptr(GMatchInfo) match_info = NULL;
+ GError *inner_error = NULL;
+ GList *list = NULL;
if (!reply || !reply[0])
/* Nothing configured, all done */
return NULL;
- list = NULL;
r = g_regex_new ("!SCACT:\\s*(\\d+),(\\d+)",
G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW, 0, &inner_error);
g_assert (r);
@@ -66,9 +65,6 @@ mm_sierra_parse_scact_read_response (const gchar *reply,
g_match_info_next (match_info, &inner_error);
}
- g_match_info_free (match_info);
- g_regex_unref (r);
-
if (inner_error) {
mm_3gpp_pdp_context_active_list_free (list);
g_propagate_error (error, inner_error);
@@ -76,7 +72,5 @@ mm_sierra_parse_scact_read_response (const gchar *reply,
return NULL;
}
- list = g_list_sort (list, (GCompareFunc) mm_3gpp_pdp_context_active_cmp);
-
- return list;
+ return g_list_sort (list, (GCompareFunc) mm_3gpp_pdp_context_active_cmp);
}