From 9e5319dbc0cf2667ad988b82adc0b4bdd372bc76 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 17 Feb 2017 10:53:33 +0100 Subject: [PATCH] core: use define for atomic-section-prefix setting for NMConfig main() should pass the same atomic-section-prefix setting to it's NMConfig instances. Currently both are NULL, but make it a define to make this explicit. Also, make static array @default_values const and sanitize value when setting PROP_ATOMIC_SECTION_PREFIXES property. --- src/main.c | 6 ++++-- src/nm-config-data.c | 2 +- src/nm-config.c | 6 +++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 57902dd652..157bec2093 100644 --- a/src/main.c +++ b/src/main.c @@ -59,6 +59,8 @@ #define NM_DEFAULT_PID_FILE NMRUNDIR "/NetworkManager.pid" #define NM_DEFAULT_SYSTEM_STATE_FILE NMSTATEDIR "/NetworkManager.state" +#define CONFIG_ATOMIC_SECTION_PREFIXES ((char **) NULL) + static GMainLoop *main_loop = NULL; static gboolean configure_and_quit = FALSE; @@ -167,7 +169,7 @@ print_config (NMConfigCmdLineOptions *config_cli) nm_logging_setup ("OFF", "ALL", NULL, NULL); - config = nm_config_new (config_cli, NULL, &error); + config = nm_config_new (config_cli, CONFIG_ATOMIC_SECTION_PREFIXES, &error); if (config == NULL) { fprintf (stderr, _("Failed to read configuration: %s\n"), error->message); return 7; @@ -300,7 +302,7 @@ main (int argc, char *argv[]) } /* Read the config file and CLI overrides */ - config = nm_config_setup (config_cli, NULL, &error); + config = nm_config_setup (config_cli, CONFIG_ATOMIC_SECTION_PREFIXES, &error); nm_config_cmd_line_options_free (config_cli); config_cli = NULL; if (config == NULL) { diff --git a/src/nm-config-data.c b/src/nm-config-data.c index 1226c9a353..d2fd1ff311 100644 --- a/src/nm-config-data.c +++ b/src/nm-config-data.c @@ -561,7 +561,7 @@ _nm_config_data_log_sort (const char **pa, const char **pb, gpointer dummy) return g_strcmp0 (a, b); } -static struct { +static const struct { const char *group; const char *key; const char *value; diff --git a/src/nm-config.c b/src/nm-config.c index cc2baba441..32faace562 100644 --- a/src/nm-config.c +++ b/src/nm-config.c @@ -2230,6 +2230,7 @@ set_property (GObject *object, guint prop_id, NMConfig *self = NM_CONFIG (object); NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE (self); NMConfigCmdLineOptions *cli; + char **strv; switch (prop_id) { case PROP_CMD_LINE_OPTIONS: @@ -2242,7 +2243,10 @@ set_property (GObject *object, guint prop_id, break; case PROP_ATOMIC_SECTION_PREFIXES: /* construct-only */ - priv->atomic_section_prefixes = g_strdupv (g_value_get_boxed (value)); + strv = g_value_get_boxed (value); + if (strv && !strv[0]) + strv = NULL; + priv->atomic_section_prefixes = g_strdupv (strv); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);