dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone
Blob Blame History Raw
From e64aac5e33523f8473471b945403f0d9ba74c8cf Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Fri, 8 Jul 2016 15:27:23 +0200
Subject: [PATCH 08/18] sssctl: Fix warning maybe-uninitialized
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It looks like some special gcc optimalisation and special case
may cause to have unitialized output argument _dom when return
code is EOK

src/tools/sssctl/sssctl_cache.c: In function ‘sssctl_print_object’:
src/tools/sssctl/sssctl_cache.c:491:8: error: ‘dom’ may be used
  uninitialized in this function [-Werror=maybe-uninitialized]
     if (dom == NULL) {
        ^
src/tools/sssctl/sssctl_cache.c:447:15: error: ‘entry’ may be used
  uninitialized in this function [-Werror=maybe-uninitialized]
     *_entry = talloc_steal(mem_ctx, entry);
               ^~~~~~~~~~~~
src/tools/sssctl/sssctl_cache.c:412:25: note: ‘entry’ was declared here
     struct sysdb_attrs *entry;
                         ^~~~~

Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
(cherry picked from commit 64d664c201916d8678b5f4bd7e1559c7ece9217d)
---
 src/tools/sssctl/sssctl_cache.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/tools/sssctl/sssctl_cache.c b/src/tools/sssctl/sssctl_cache.c
index 28de6c139d844f98f9b06844492c935696e19643..e23bb89db95217e66a441b7e4d6d32e668486cc8 100644
--- a/src/tools/sssctl/sssctl_cache.c
+++ b/src/tools/sssctl/sssctl_cache.c
@@ -372,15 +372,19 @@ static errno_t sssctl_find_object(TALLOC_CTX *mem_ctx,
 
         ret = sssctl_query_cache(tmp_ctx, dom->sysdb, base_dn, filter,
                                  attrs, &entry);
-        if (ret == EOK) {
+        switch(ret) {
+        case EOK:
             /* Entry was found. */
             *_entry = talloc_steal(mem_ctx, entry);
             *_dom = dom;
             goto done;
-        } else if (ret == ENOENT && fqn_provided) {
-            /* Not found but a domain was provided in input. We're done. */
-            goto done;
-        } else if (ret != ENOENT) {
+        case ENOENT:
+            if (fqn_provided) {
+                /* Not found but a domain was provided in input. We're done. */
+                goto done;
+            }
+            break;
+        default:
             DEBUG(SSSDBG_CRIT_FAILURE, "Unable to query cache [%d]: %s\n",
                   ret, sss_strerror(ret));
             goto done;
-- 
2.4.11