Blame SOURCES/0016-Ticket-48919-Compiler-warnings-while-building-389-ds.patch

7c7f29
From 6f55a77b49ecdec56817039308f7c07da820fb62 Mon Sep 17 00:00:00 2001
7c7f29
From: Noriko Hosoi <nhosoi@redhat.com>
7c7f29
Date: Thu, 14 Jul 2016 19:09:21 -0700
7c7f29
Subject: [PATCH] Ticket #48919 - Compiler warnings while building 389-ds-base
7c7f29
 on RHEL7
7c7f29
7c7f29
Description: Fixing additional covscan errors.
7c7f29
1. RESOURCE_LEAK
7c7f29
   ldap/servers/slapd/agtmmap.c
7c7f29
   agt_mopen_stats - leaked_handle: Handle variable "fd" going out of scope leaks the handle.
7c7f29
2. CHECKED_RETURN
7c7f29
   ldap/servers/slapd/back-ldbm/cache.c
7c7f29
   entrycache_return - check_return: Calling "remove_hash" without checking return value
7c7f29
3. NULL_RETURNS
7c7f29
   ldap/systools/idsktune.c
7c7f29
   linux_check_cpu_features - dereference: Dereferencing a pointer that might be null "cpuinfo" when calling "fclose".
7c7f29
4. UNINIT
7c7f29
   ldap/servers/slapd/detach.c
7c7f29
   detach - uninit_use: Using uninitialized value "rc".
7c7f29
7c7f29
https://fedorahosted.org/389/ticket/48919
7c7f29
(cherry picked from commit 381caf52a06ad8cefa9daa99586878249a4aa4f2)
7c7f29
---
7c7f29
 ldap/servers/slapd/agtmmap.c         | 1 +
7c7f29
 ldap/servers/slapd/back-ldbm/cache.c | 6 ++++--
7c7f29
 ldap/servers/slapd/detach.c          | 3 ++-
7c7f29
 ldap/systools/idsktune.c             | 4 ++++
7c7f29
 4 files changed, 11 insertions(+), 3 deletions(-)
7c7f29
7c7f29
diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c
7c7f29
index 629bc1b..b9d66d9 100644
7c7f29
--- a/ldap/servers/slapd/agtmmap.c
7c7f29
+++ b/ldap/servers/slapd/agtmmap.c
7c7f29
@@ -167,6 +167,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
7c7f29
 #endif
7c7f29
                        rc = err;
7c7f29
                        free (buf);
7c7f29
+                       close(fd);
7c7f29
                        goto bail;
7c7f29
                    }
7c7f29
                    free (buf);
7c7f29
diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c
7c7f29
index bb4e55e..015cd48 100644
7c7f29
--- a/ldap/servers/slapd/back-ldbm/cache.c
7c7f29
+++ b/ldap/servers/slapd/back-ldbm/cache.c
7c7f29
@@ -1142,7 +1142,9 @@ entrycache_return(struct cache *cache, struct backentry **bep)
7c7f29
                      * so we need to remove the entry from the DN cache because
7c7f29
                      * we don't/can't always call cache_remove().
7c7f29
                      */
7c7f29
-                    remove_hash(cache->c_dntable, (void *)ndn, strlen(ndn));
7c7f29
+                    if (remove_hash(cache->c_dntable, (void *)ndn, strlen(ndn)) == 0) {
7c7f29
+                        LOG("entrycache_return: failed to remove %s from dn table\n", ndn, 0, 0);
7c7f29
+                    }
7c7f29
                 }
7c7f29
                 backentry_free(bep);
7c7f29
             } else {
7c7f29
@@ -1392,7 +1394,7 @@ entrycache_add_int(struct cache *cache, struct backentry *e, int state,
7c7f29
                 return 0;
7c7f29
             }
7c7f29
             if(remove_hash(cache->c_dntable, (void *)ndn, strlen(ndn)) == 0){
7c7f29
-                LOG("entrycache_add_int: failed to remove %s from dn table\n", 0, 0, 0);
7c7f29
+                LOG("entrycache_add_int: failed to remove %s from dn table\n", ndn, 0, 0);
7c7f29
             }
7c7f29
             e->ep_state |= ENTRY_STATE_NOTINCACHE;
7c7f29
             cache_unlock(cache);
7c7f29
diff --git a/ldap/servers/slapd/detach.c b/ldap/servers/slapd/detach.c
7c7f29
index 54c6028..84a9eef 100644
7c7f29
--- a/ldap/servers/slapd/detach.c
7c7f29
+++ b/ldap/servers/slapd/detach.c
7c7f29
@@ -48,7 +48,8 @@ int
7c7f29
 detach( int slapd_exemode, int importexport_encrypt,
7c7f29
         int s_port, daemon_ports_t *ports_info )
7c7f29
 {
7c7f29
-	int i, sd, rc;
7c7f29
+	int i, sd;
7c7f29
+	int rc = 0;
7c7f29
 	char *workingdir = 0;
7c7f29
 	char *errorlog = 0;
7c7f29
 	char *ptr = 0;
7c7f29
diff --git a/ldap/systools/idsktune.c b/ldap/systools/idsktune.c
7c7f29
index 4c96529..08b7f12 100644
7c7f29
--- a/ldap/systools/idsktune.c
7c7f29
+++ b/ldap/systools/idsktune.c
7c7f29
@@ -875,6 +875,10 @@ linux_check_cpu_features(void)
7c7f29
     char *token = NULL;
7c7f29
     size_t size = 0;
7c7f29
     int found = 0;
7c7f29
+    if (NULL == cpuinfo) {
7c7f29
+        printf("ERROR: Unable to check cpu features since opening \"/proc/cpuinfo\" failed.\n");
7c7f29
+        return;
7c7f29
+    }
7c7f29
     while(getline(&arg, &size, cpuinfo) != -1)
7c7f29
     {
7c7f29
         if (strncmp("flags", arg, 5) == 0) {
7c7f29
-- 
7c7f29
2.4.11
7c7f29