From cf660c7f9de390be9f8c441069c20ced3939768e Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Tue, 26 Jul 2022 16:13:57 +0300 Subject: [PATCH] (mc_config_has_param): use g_key_file_get_value()... to check if a parameter exists. Signed-off-by: Andrew Borodin --- lib/mcconfig/common.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/mcconfig/common.c b/lib/mcconfig/common.c index 1901adb32..288a73880 100644 --- a/lib/mcconfig/common.c +++ b/lib/mcconfig/common.c @@ -161,10 +161,16 @@ mc_config_deinit (mc_config_t * mc_config) gboolean mc_config_has_param (const mc_config_t * mc_config, const char *group, const gchar * param) { - if (mc_config == NULL || group == NULL || param == NULL) - return FALSE; + char *value; + gboolean ret; - return g_key_file_has_key (mc_config->handle, group, param, NULL); + g_return_val_if_fail (mc_config != NULL, FALSE); + + value = g_key_file_get_value (mc_config->handle, group, param, NULL); + ret = value != NULL; + g_free (value); + + return ret; } /* --------------------------------------------------------------------------------------------- */