From 3cc99c9f8c87a0d3ee29041fa7b18f6e55a3e996 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 12 Mar 2020 14:39:27 +0100 Subject: [PATCH] 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. --- clients/cli/utils.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/clients/cli/utils.c b/clients/cli/utils.c index 64a7cde07..6dcb97b9f 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);