URL: https://github.com/SSSD/sssd/pull/5750
Author: pbrezina
 Title: #5750: fix compilation warnings
Action: opened

PR body:
"""
None
"""

To pull the PR as Git branch:
git remote add ghsssd https://github.com/SSSD/sssd
git fetch ghsssd pull/5750/head:pr5750
git checkout pr5750
From f53e803a274619b1a2c2bdd0b2d8911bf13de5f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrez...@redhat.com>
Date: Tue, 17 Aug 2021 12:26:31 +0200
Subject: [PATCH 1/2] remove deprecated talloc_autofree_context()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

```
/home/pbrezina/workspace/sssd/src/util/server.c: In function ‘server_setup’:
/home/pbrezina/workspace/sssd/src/util/server.c:545:5: error: ‘talloc_autofree_context’ is deprecated [-Werror=deprecated-declarations]
  545 |     event_ctx = tevent_context_init(talloc_autofree_context());
      |     ^~~~~~~~~
In file included from /usr/include/ldb.h:50,
                 from /home/pbrezina/workspace/sssd/src/util/server.c:33:
/usr/include/talloc.h:1071:16: note: declared here
 1071 | _PUBLIC_ void *talloc_autofree_context(void) _DEPRECATED_;
      |                ^~~~~~~~~~~~~~~~~~~~~~~
```
---
 src/util/server.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/util/server.c b/src/util/server.c
index 4fe29f96b8..9d386d3cde 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -264,6 +264,11 @@ static void default_quit(struct tevent_context *ev,
 {
     struct main_context *ctx = talloc_get_type(private_data, struct main_context);
     talloc_free(ctx);
+
+    /* It is ok to free ev (ctx->event_ctx; a top level context) here as well
+     * since we never go back to the event loop from here. */
+    talloc_free(ev);
+
     orderly_shutdown(0);
 }
 
@@ -542,7 +547,7 @@ int server_setup(const char *name, int flags,
 
     /* the event context is the top level structure.
      * Everything else should hang off that */
-    event_ctx = tevent_context_init(talloc_autofree_context());
+    event_ctx = tevent_context_init(NULL);
     if (event_ctx == NULL) {
         DEBUG(SSSDBG_FATAL_FAILURE,
               "The event context initialization failed\n");

From b8c1924ddf22d11cf58bc6df45ca006b7fbd7482 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrez...@redhat.com>
Date: Tue, 17 Aug 2021 12:24:39 +0200
Subject: [PATCH 2/2] fix warnings around sss_getenv()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Introduced in
- 44525a9995c775ac284a6203d0e505dc4bf0d459
- c1dd121142fb22648793a38e45257b348d658460

```
/home/pbrezina/workspace/sssd/src/db/sysdb_init.c: In function ‘sysdb_ldb_connect’:
/home/pbrezina/workspace/sssd/src/db/sysdb_init.c:82:49: error: passing argument 3 of ‘sss_getenv’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   82 |     ret = sss_getenv(tmp_ctx, LDB_MODULES_PATH, &mod_path);
      |                                                 ^~~~~~~~~
      |                                                 |
      |                                                 const char **
In file included from /home/pbrezina/workspace/sssd/src/db/sysdb_init.c:23:
/home/pbrezina/workspace/sssd/src/util/util.h:806:75: note: expected ‘char **’ but argument is of type ‘const char **’
  806 | errno_t sss_getenv(TALLOC_CTX *mem_ctx, const char *variable_name, char **_value);

/home/pbrezina/workspace/sssd/src/providers/files/files_init.c: In function ‘files_init_file_sources’:
/home/pbrezina/workspace/sssd/src/providers/files/files_init.c:61:26: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   61 |         dfl_passwd_files = DEFAULT_PASSWD_FILE;
      |                          ^
/home/pbrezina/workspace/sssd/src/providers/files/files_init.c:77:25: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   77 |         env_group_files = DEFAULT_GROUP_FILE;
      |                         ^
```

Resolves: https://github.com/SSSD/sssd/issues/XXXX
---
 src/db/sysdb_init.c              |  2 +-
 src/providers/files/files_init.c | 12 ++++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/db/sysdb_init.c b/src/db/sysdb_init.c
index e84d76129d..c3c2ba4f50 100644
--- a/src/db/sysdb_init.c
+++ b/src/db/sysdb_init.c
@@ -54,7 +54,7 @@ errno_t sysdb_ldb_connect(TALLOC_CTX *mem_ctx,
     TALLOC_CTX *tmp_ctx = NULL;
     errno_t ret;
     struct ldb_context *ldb;
-    const char *mod_path = NULL;
+    char *mod_path = NULL;
 
     tmp_ctx = talloc_new(NULL);
     if (tmp_ctx == NULL) {
diff --git a/src/providers/files/files_init.c b/src/providers/files/files_init.c
index f4a522b318..55503c2db2 100644
--- a/src/providers/files/files_init.c
+++ b/src/providers/files/files_init.c
@@ -58,7 +58,11 @@ static errno_t files_init_file_sources(TALLOC_CTX *mem_ctx,
                 "this should only be used for testing!\n",
                 dfl_passwd_files);
     } else if (ret == ENOENT) {
-        dfl_passwd_files = DEFAULT_PASSWD_FILE;
+        dfl_passwd_files = talloc_strdup(tmp_ctx, DEFAULT_PASSWD_FILE);
+        if (dfl_passwd_files == NULL) {
+            ret = ENOMEM;
+            goto done;
+        }
     } else {
         sss_log(SSS_LOG_ALERT, "sss_getenv() failed");
         goto done;
@@ -74,7 +78,11 @@ static errno_t files_init_file_sources(TALLOC_CTX *mem_ctx,
                 "this should only be used for testing!\n",
                 env_group_files);
     } else if (ret == ENOENT) {
-        env_group_files = DEFAULT_GROUP_FILE;
+        env_group_files = talloc_strdup(tmp_ctx, DEFAULT_GROUP_FILE);
+        if (env_group_files == NULL) {
+            ret = ENOMEM;
+            goto done;
+        }
     } else {
         sss_log(SSS_LOG_ALERT, "sss_getenv() failed");
         goto done;
_______________________________________________
sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org
To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/sssd-devel@lists.fedorahosted.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to