diff options
author | Thomas Haller <thaller@redhat.com> | 2020-03-12 14:39:27 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-03-16 13:44:09 +0100 |
commit | 3cc99c9f8c87a0d3ee29041fa7b18f6e55a3e996 (patch) | |
tree | b83a490cff94b6c651ed8cc8f8e958bdddc13796 | |
parent | a01355ba64ec7c1e56cbe5a1a6fd603c3e27820c (diff) | |
download | NetworkManager-3cc99c9f8c87a0d3ee29041fa7b18f6e55a3e996.tar.gz |
cli: return typed PrintDataCol array from _output_selection_parse()
It makes debugging and understanding the code slightly simpler, if we
have a pointer of correct type, instead of returning a GArray. We don't
need the GArray at this point anymore.
-rw-r--r-- | clients/cli/utils.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/clients/cli/utils.c b/clients/cli/utils.c index 64a7cde07e..6dcb97b9fc 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -773,7 +773,8 @@ _output_selection_complete (GArray *cols) static gboolean _output_selection_parse (const NMMetaAbstractInfo *const*fields, const char *fields_str, - GArray **out_cols, + PrintDataCol **out_cols_data, + guint *out_cols_len, GPtrArray **out_gfree_keeper, GError **error) { @@ -807,7 +808,8 @@ _output_selection_parse (const NMMetaAbstractInfo *const*fields, _output_selection_complete (cols); - *out_cols = g_steal_pointer (&cols); + *out_cols_len = cols->len; + *out_cols_data = (PrintDataCol *) g_array_free (g_steal_pointer (&cols), FALSE); *out_gfree_keeper = g_steal_pointer (&gfree_keeper); return TRUE; } @@ -1374,20 +1376,24 @@ nmc_print (const NmcConfig *nmc_config, GError **error) { gs_unref_ptrarray GPtrArray *gfree_keeper = NULL; - gs_unref_array GArray *cols = NULL; + gs_free PrintDataCol *cols_data = NULL; + guint cols_len; gs_unref_array GArray *header_row = NULL; gs_unref_array GArray *cells = NULL; - if (!_output_selection_parse (fields, fields_str, - &cols, &gfree_keeper, + if (!_output_selection_parse (fields, + fields_str, + &cols_data, + &cols_len, + &gfree_keeper, error)) return FALSE; _print_fill (nmc_config, targets, targets_data, - &g_array_index (cols, PrintDataCol, 0), - cols->len, + cols_data, + cols_len, &header_row, &cells); |