diff options
author | Aleksander Morgado <aleksandermj@chromium.org> | 2022-08-24 16:42:45 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksandermj@chromium.org> | 2022-09-05 17:37:14 +0000 |
commit | e6c40349b81ac2915ce90b7e399eb33719a1fd24 (patch) | |
tree | 07bbc8ce290ab78ba409c5ce19835d31a1ac2e0e | |
parent | 845667c7b3d36f0e776d5a0e582ad62d48cdeb02 (diff) |
modem-helpers-cinterion: rework CNMI test response parser
We setup all output variables with g_autoptr() and then use
g_steal_pointer() to return the needed ones.
-rw-r--r-- | plugins/cinterion/mm-modem-helpers-cinterion.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/plugins/cinterion/mm-modem-helpers-cinterion.c b/plugins/cinterion/mm-modem-helpers-cinterion.c index 0bf3a078..9219bff4 100644 --- a/plugins/cinterion/mm-modem-helpers-cinterion.c +++ b/plugins/cinterion/mm-modem-helpers-cinterion.c @@ -556,12 +556,12 @@ mm_cinterion_parse_cnmi_test (const gchar *response, { g_autoptr(GRegex) r = NULL; g_autoptr(GMatchInfo) match_info = NULL; + g_autoptr(GArray) tmp_supported_mode = NULL; + g_autoptr(GArray) tmp_supported_mt = NULL; + g_autoptr(GArray) tmp_supported_bm = NULL; + g_autoptr(GArray) tmp_supported_ds = NULL; + g_autoptr(GArray) tmp_supported_bfr = NULL; GError *inner_error = NULL; - GArray *tmp_supported_mode = NULL; - GArray *tmp_supported_mt = NULL; - GArray *tmp_supported_bm = NULL; - GArray *tmp_supported_ds = NULL; - GArray *tmp_supported_bfr = NULL; if (!response) { g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Missing response"); @@ -619,25 +619,20 @@ mm_cinterion_parse_cnmi_test (const gchar *response, out: if (inner_error) { - g_clear_pointer (&tmp_supported_mode, g_array_unref); - g_clear_pointer (&tmp_supported_mt, g_array_unref); - g_clear_pointer (&tmp_supported_bm, g_array_unref); - g_clear_pointer (&tmp_supported_ds, g_array_unref); - g_clear_pointer (&tmp_supported_bfr, g_array_unref); g_propagate_error (error, inner_error); return FALSE; } if (supported_mode) - *supported_mode = tmp_supported_mode; + *supported_mode = g_steal_pointer (&tmp_supported_mode); if (supported_mt) - *supported_mt = tmp_supported_mt; + *supported_mt = g_steal_pointer (&tmp_supported_mt); if (supported_bm) - *supported_bm = tmp_supported_bm; + *supported_bm = g_steal_pointer (&tmp_supported_bm); if (supported_ds) - *supported_ds = tmp_supported_ds; + *supported_ds = g_steal_pointer (&tmp_supported_ds); if (supported_bfr) - *supported_bfr = tmp_supported_bfr; + *supported_bfr = g_steal_pointer (&tmp_supported_bfr); return TRUE; } |