From 386ed5d6b0d19cd1f62d87b444227be2f364c3d1 Mon Sep 17 00:00:00 2001 From: Alexey Tikhonov Date: Wed, 18 Oct 2023 20:50:47 +0200 Subject: [PATCH] SSS_INI: remove 'const' specifier from getter `sss_ini_get_string_config_value()` is a wrapper around `ini_get_string_config_value()`, whose docs says ``` Returned value needs to be freed after use. ``` But an attempt to free 'const char *' results in discarded-qualifiers warning. --- src/tools/sssd_check_socket_activated_responders.c | 3 ++- src/util/sss_ini.c | 2 +- src/util/sss_ini.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tools/sssd_check_socket_activated_responders.c b/src/tools/sssd_check_socket_activated_responders.c index f8ef1feab55..dddc02ee24e 100644 --- a/src/tools/sssd_check_socket_activated_responders.c +++ b/src/tools/sssd_check_socket_activated_responders.c @@ -30,7 +30,7 @@ static errno_t check_socket_activated_responder(const char *responder) { errno_t ret; - const char *services; + char *services = NULL; const char *str; TALLOC_CTX *tmp_ctx; struct sss_ini *init_data; @@ -90,6 +90,7 @@ static errno_t check_socket_activated_responder(const char *responder) ret = EOK; done: + free(services); talloc_free(tmp_ctx); return ret; diff --git a/src/util/sss_ini.c b/src/util/sss_ini.c index 4b8397f41db..e4233559a9d 100644 --- a/src/util/sss_ini.c +++ b/src/util/sss_ini.c @@ -395,7 +395,7 @@ int sss_ini_get_int_config_value(struct sss_ini *self, /* Get string value */ -const char *sss_ini_get_string_config_value(struct sss_ini *self, +char *sss_ini_get_string_config_value(struct sss_ini *self, int *error) { return ini_get_string_config_value(self->obj, error); diff --git a/src/util/sss_ini.h b/src/util/sss_ini.h index 97d2df3a1a3..a41e1c96c39 100644 --- a/src/util/sss_ini.h +++ b/src/util/sss_ini.h @@ -136,7 +136,7 @@ int sss_ini_get_int_config_value(struct sss_ini *self, /** * @brief Get string value */ -const char *sss_ini_get_string_config_value(struct sss_ini *self, +char *sss_ini_get_string_config_value(struct sss_ini *self, int *error); /**