summaryrefslogtreecommitdiff
path: root/clients/cli/nmcli.h
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-03-30 14:56:19 +0200
committerThomas Haller <thaller@redhat.com>2017-03-30 14:56:21 +0200
commit29bcfc25221fcbc63ce9bc7670097b07b7fab827 (patch)
treec1f38ed28645fde792dfa8567ede0360c1c41329 /clients/cli/nmcli.h
parent85acdd70e7daba3257a3811c819a5f9a243bdfa6 (diff)
downloadNetworkManager-29bcfc25221fcbc63ce9bc7670097b07b7fab827.tar.gz
cli: don't track output data in global NmCli structure
We should not violate the global data to track the output data while it is constructed and printed. Most of the time, we actually clear the output data anyway -- either before constructing it, or after printing it. In some cases we didn't, but I think that is a bug. It's really hard to keep track of this. The output data should belong to a certain scope and get destroyed afterwards. Passing it around is very confusing. Don't do that.
Diffstat (limited to 'clients/cli/nmcli.h')
-rw-r--r--clients/cli/nmcli.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/clients/cli/nmcli.h b/clients/cli/nmcli.h
index b78d7ff265..1b9c3e72e1 100644
--- a/clients/cli/nmcli.h
+++ b/clients/cli/nmcli.h
@@ -172,7 +172,6 @@ typedef struct _NmCli {
NmcConfig nmc_config_mutable;
};
char *required_fields; /* Required fields in output: '--fields' option */
- NmcOutputData out;
gboolean ask; /* Ask for missing parameters: option '--ask' */
gboolean complete; /* Autocomplete the command line */
gboolean show_secrets; /* Whether to display secrets (both input and output): option '--show-secrets' */
@@ -193,4 +192,11 @@ void nmc_clear_sigint (void);
void nmc_set_sigquit_internal (void);
void nmc_exit (void);
+void nmc_empty_output_fields (NmcOutputData *output_data);
+
+#define NMC_OUTPUT_DATA_DEFINE_SCOPED(out) \
+ nm_auto (nmc_empty_output_fields) NmcOutputData out = { \
+ .output_data = g_ptr_array_new_full (20, g_free), \
+ }
+
#endif /* NMC_NMCLI_H */