From d72d5337ee3821ab5d10b60cbaa38ab0436a22cc Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Wed, 28 Aug 2024 13:54:56 +0200 Subject: [PATCH] Include error message when loading config file fails So we can get a little bit more information in the logs when g_key_file_load_from_file fails to load the file. --- src/udisksconfigmanager.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/udisksconfigmanager.c b/src/udisksconfigmanager.c index 97d7484565..ae61233577 100644 --- a/src/udisksconfigmanager.c +++ b/src/udisksconfigmanager.c @@ -151,6 +151,7 @@ parse_config_file (UDisksConfigManager *manager, gchar *module_i; gchar **modules; gchar **modules_tmp; + GError *l_error = NULL; /* Get modules and means of loading */ conf_filename = g_build_filename (G_DIR_SEPARATOR_S, @@ -163,7 +164,7 @@ parse_config_file (UDisksConfigManager *manager, /* Load config */ config_file = g_key_file_new (); g_key_file_set_list_separator (config_file, ','); - if (g_key_file_load_from_file (config_file, conf_filename, G_KEY_FILE_NONE, NULL)) + if (g_key_file_load_from_file (config_file, conf_filename, G_KEY_FILE_NONE, &l_error)) { if (out_modules != NULL) { @@ -225,7 +226,16 @@ parse_config_file (UDisksConfigManager *manager, } else { - udisks_warning ("Can't load configuration file %s", conf_filename); + if (l_error != NULL) + { + udisks_warning ("Can't load configuration file %s: %s", conf_filename, l_error->message); + g_error_free (l_error); + } + else + { + udisks_warning ("Can't load configuration file %s", conf_filename); + } + } g_key_file_free (config_file);