andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From 45a86b895601644b624d27484933735d7e665a66 Mon Sep 17 00:00:00 2001
dc8c34
From: Rich Megginson <rmeggins@redhat.com>
dc8c34
Date: Wed, 5 Jun 2013 11:30:13 -0600
dc8c34
Subject: [PATCH 82/99] Ticket #47378 - fix recent compiler warnings
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/47378
dc8c34
Reviewed by: nhosoi (Thanks!)
dc8c34
Branch: master
dc8c34
Fix Description: Fix the various compiler warnings as reported by
dc8c34
http://jenkins.cloud.fedoraproject.org/job/389-ds-base/ws/build-warns.1370449480.txt
dc8c34
In addition, fixed a bug in the slapi_re_subs_ext - if there was an
dc8c34
ampersand that did not need to be replaced, that is, if the ampersand
dc8c34
was part of an LDAP search filter, it was replaced with a '('.  Also, an
dc8c34
ampersand preceeded by an open parenthesis and followed by a non-open
dc8c34
parenthesis is supposed to be replaced in the string, but this was not
dc8c34
working.
dc8c34
Platforms tested: RHEL6 x86_64
dc8c34
Flag Day: no
dc8c34
Doc impact: no
dc8c34
(cherry picked from commit 0dc230b007dc3ad292961f378421b03736b68f9e)
dc8c34
(cherry picked from commit 79739bdfba251ed6445ae4a16e90a471ca3f7b94)
dc8c34
---
dc8c34
 .../plugins/acct_usability/acct_usability.c        |  2 +-
dc8c34
 ldap/servers/plugins/acl/acl_ext.c                 |  2 +-
dc8c34
 ldap/servers/plugins/acl/aclutil.c                 |  3 ++-
dc8c34
 ldap/servers/plugins/automember/automember.c       |  3 ++-
dc8c34
 ldap/servers/plugins/deref/deref.c                 |  2 +-
dc8c34
 ldap/servers/plugins/http/http_impl.c              |  4 ++--
dc8c34
 ldap/servers/plugins/pam_passthru/pam_ptimpl.c     |  2 +-
dc8c34
 ldap/servers/plugins/referint/referint.c           |  2 +-
dc8c34
 ldap/servers/plugins/replication/cl5_api.c         | 20 +++++++++---------
dc8c34
 .../plugins/replication/windows_inc_protocol.c     |  2 +-
dc8c34
 ldap/servers/plugins/replication/windows_private.c |  9 ++++++--
dc8c34
 ldap/servers/plugins/usn/usn.c                     |  4 ++--
dc8c34
 ldap/servers/slapd/back-ldbm/import-threads.c      |  2 +-
dc8c34
 ldap/servers/slapd/back-ldbm/monitor.c             | 18 ++++++++--------
dc8c34
 ldap/servers/slapd/log.c                           | 24 ++++++++++++++--------
dc8c34
 ldap/servers/slapd/mapping_tree.c                  |  6 +++++-
dc8c34
 ldap/servers/slapd/regex.c                         | 10 ++++++---
dc8c34
 ldap/servers/slapd/slapi-plugin.h                  |  9 ++++++++
dc8c34
 ldap/servers/slapd/tools/ldclt/ldapfct.c           |  5 -----
dc8c34
 ldap/servers/slapd/tools/rsearch/infadd.c          |  7 +++----
dc8c34
 ldap/servers/snmp/main.c                           | 13 +++++++++++-
dc8c34
 lib/libaccess/acltools.cpp                         |  2 +-
dc8c34
 lib/libaccess/register.cpp                         | 10 +++++----
dc8c34
 23 files changed, 100 insertions(+), 61 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/plugins/acct_usability/acct_usability.c b/ldap/servers/plugins/acct_usability/acct_usability.c
dc8c34
index 19e55c3..f41f934 100644
dc8c34
--- a/ldap/servers/plugins/acct_usability/acct_usability.c
dc8c34
+++ b/ldap/servers/plugins/acct_usability/acct_usability.c
dc8c34
@@ -312,7 +312,7 @@ auc_pre_search(Slapi_PBlock *pb)
dc8c34
     int ldapcode = LDAP_SUCCESS;
dc8c34
     const LDAPControl **reqctrls = NULL;
dc8c34
     const LDAPControl *aucctrl = NULL;
dc8c34
-    const char *ldaperrtext;
dc8c34
+    const char *ldaperrtext = "Unknown error";
dc8c34
     const char *incompatible = NULL;
dc8c34
     int isroot = 0;
dc8c34
     int ii;
dc8c34
diff --git a/ldap/servers/plugins/acl/acl_ext.c b/ldap/servers/plugins/acl/acl_ext.c
dc8c34
index f8699b4..e42a7e2 100644
dc8c34
--- a/ldap/servers/plugins/acl/acl_ext.c
dc8c34
+++ b/ldap/servers/plugins/acl/acl_ext.c
dc8c34
@@ -128,7 +128,7 @@ acl_get_ext (ext_type type, void *object)
dc8c34
 void
dc8c34
 acl_set_ext (ext_type type, void *object, void *data)
dc8c34
 {
dc8c34
-	if ( type >= 0 && type < ACL_EXT_ALL )
dc8c34
+	if ( type < ACL_EXT_ALL )
dc8c34
 	{
dc8c34
 		struct acl_ext ext = acl_ext_list [type];
dc8c34
 		slapi_set_object_extension ( ext.object_type, object, ext.handle, data );
dc8c34
diff --git a/ldap/servers/plugins/acl/aclutil.c b/ldap/servers/plugins/acl/aclutil.c
dc8c34
index 77ec35f..2002276 100644
dc8c34
--- a/ldap/servers/plugins/acl/aclutil.c
dc8c34
+++ b/ldap/servers/plugins/acl/aclutil.c
dc8c34
@@ -96,6 +96,7 @@ aclutil_str_append_ext(char **dest, size_t *dlen, const char *src, size_t slen)
dc8c34
     char *ptr = NULL;
dc8c34
     int rc = 0;
dc8c34
 
dc8c34
+    PR_ASSERT(NULL != dlen);
dc8c34
     if ( dest == NULL || src == NULL ) {
dc8c34
         return rc;    
dc8c34
     }
dc8c34
@@ -103,7 +104,7 @@ aclutil_str_append_ext(char **dest, size_t *dlen, const char *src, size_t slen)
dc8c34
     if (0 == slen) {
dc8c34
         slen = strlen(src);
dc8c34
     }
dc8c34
-    if (*dest && dlen > 0) {
dc8c34
+    if (*dest && *dlen > 0) {
dc8c34
         size_t dest_strlen = strlen(*dest);
dc8c34
         size_t new_len = dest_strlen + slen + 1;
dc8c34
         if (new_len > *dlen) {
dc8c34
diff --git a/ldap/servers/plugins/automember/automember.c b/ldap/servers/plugins/automember/automember.c
dc8c34
index 424b507..49f47f7 100644
dc8c34
--- a/ldap/servers/plugins/automember/automember.c
dc8c34
+++ b/ldap/servers/plugins/automember/automember.c
dc8c34
@@ -2522,10 +2522,11 @@ void automember_map_task_thread(void *arg){
dc8c34
 #if defined(USE_OPENLDAP)
dc8c34
     int buflen = 0;
dc8c34
     LDIFFP *ldif_fd_in = NULL;
dc8c34
+    ldif_record_lineno_t lineno = 0;
dc8c34
 #else
dc8c34
     PRFileDesc *ldif_fd_in = NULL;
dc8c34
-#endif
dc8c34
     int lineno = 0;
dc8c34
+#endif
dc8c34
     int rc = 0;
dc8c34
 
dc8c34
     td = (task_data *)slapi_task_get_data(task);
dc8c34
diff --git a/ldap/servers/plugins/deref/deref.c b/ldap/servers/plugins/deref/deref.c
dc8c34
index 51394c8..6e4d4ec 100644
dc8c34
--- a/ldap/servers/plugins/deref/deref.c
dc8c34
+++ b/ldap/servers/plugins/deref/deref.c
dc8c34
@@ -440,7 +440,7 @@ deref_pre_search(Slapi_PBlock *pb)
dc8c34
     int ldapcode = LDAP_SUCCESS;
dc8c34
     const LDAPControl **reqctrls = NULL;
dc8c34
     const LDAPControl *derefctrl = NULL;
dc8c34
-    const char *ldaperrtext;
dc8c34
+    const char *ldaperrtext = "Unknown error";
dc8c34
     const char *incompatible = NULL;
dc8c34
     DerefSpecList *speclist = NULL;
dc8c34
     int ii;
dc8c34
diff --git a/ldap/servers/plugins/http/http_impl.c b/ldap/servers/plugins/http/http_impl.c
dc8c34
index f96d75a..db02b67 100644
dc8c34
--- a/ldap/servers/plugins/http/http_impl.c
dc8c34
+++ b/ldap/servers/plugins/http/http_impl.c
dc8c34
@@ -260,7 +260,7 @@ static int doRequest(const char *url, httpheader **httpheaderArray, char *body,
dc8c34
 	PRInt32 port;
dc8c34
 	PRInt32 errcode = 0;
dc8c34
 	PRInt32 http_connection_time_out = 0;
dc8c34
-	PRInt32 sslOn;
dc8c34
+	PRInt32 sslOn = 0;
dc8c34
 	
dc8c34
 	LDAPDebug( LDAP_DEBUG_PLUGIN, "--> doRequest -- BEGIN\n",0,0,0);
dc8c34
 
dc8c34
@@ -1178,7 +1178,7 @@ SECStatus
dc8c34
                     struct SECKEYPrivateKeyStr **pRetKey)
dc8c34
 {
dc8c34
     CERTCertificate *  cert;
dc8c34
-    SECKEYPrivateKey * privKey;
dc8c34
+    SECKEYPrivateKey * privKey = NULL;
dc8c34
     char *             chosenNickName = (char *)arg;
dc8c34
     void *             proto_win      = NULL;
dc8c34
     SECStatus          secStatus      = SECFailure;
dc8c34
diff --git a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
dc8c34
index 69c08e8..2558b9e 100644
dc8c34
--- a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
dc8c34
+++ b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
dc8c34
@@ -263,7 +263,7 @@ do_one_pam_auth(
dc8c34
 	MyStrBuf pam_id;
dc8c34
 	const char *binddn = NULL;
dc8c34
 	Slapi_DN *bindsdn = NULL;
dc8c34
-	int rc;
dc8c34
+	int rc = PAM_SUCCESS;
dc8c34
 	int retcode = LDAP_SUCCESS;
dc8c34
 	pam_handle_t *pam_handle;
dc8c34
 	struct my_pam_conv_str my_data;
dc8c34
diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c
dc8c34
index 8f751da..4a722c1 100644
dc8c34
--- a/ldap/servers/plugins/referint/referint.c
dc8c34
+++ b/ldap/servers/plugins/referint/referint.c
dc8c34
@@ -896,7 +896,7 @@ void
dc8c34
 referint_thread_func(void *arg)
dc8c34
 {
dc8c34
     char **plugin_argv = (char **)arg;
dc8c34
-    PRFileDesc *prfd;
dc8c34
+    PRFileDesc *prfd = NULL;
dc8c34
     char *logfilename;
dc8c34
     char thisline[MAX_LINE];
dc8c34
     int delay;
dc8c34
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
dc8c34
index e24cead..a06c43f 100644
dc8c34
--- a/ldap/servers/plugins/replication/cl5_api.c
dc8c34
+++ b/ldap/servers/plugins/replication/cl5_api.c
dc8c34
@@ -271,8 +271,8 @@ static CL5Desc s_cl5Desc;
dc8c34
 
dc8c34
 /* changelog initialization and cleanup */
dc8c34
 static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode openMode);
dc8c34
-static int _cl5AppInit (PRBool *didRecovery);
dc8c34
-static int _cl5DBOpen ();
dc8c34
+static int _cl5AppInit (void);
dc8c34
+static int _cl5DBOpen (void);
dc8c34
 static void _cl5SetDefaultDBConfig ();
dc8c34
 static void _cl5SetDBConfig (const CL5DBConfig *config);
dc8c34
 static int _cl5CheckDBVersion ();
dc8c34
@@ -876,12 +876,13 @@ cl5ImportLDIF (const char *clDir, const char *ldifFile, Object **replicas)
dc8c34
 #if defined(USE_OPENLDAP)
dc8c34
 	LDIFFP *file = NULL;
dc8c34
 	int buflen;
dc8c34
+	ldif_record_lineno_t lineno = 0;
dc8c34
 #else
dc8c34
 	FILE *file = NULL;
dc8c34
+	int lineno = 0;
dc8c34
 #endif
dc8c34
 	int rc;
dc8c34
 	char *buff = NULL;
dc8c34
-	int lineno = 0;
dc8c34
 	slapi_operation_parameters op;
dc8c34
 	Object *prim_replica_obj = NULL;
dc8c34
 	Object *replica_obj = NULL;
dc8c34
@@ -1850,7 +1851,6 @@ int cl5GetOperationCount (Object *replica)
dc8c34
 static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode openMode)
dc8c34
 {
dc8c34
 	int rc;
dc8c34
-	PRBool didRecovery;
dc8c34
 
dc8c34
 	PR_ASSERT (dir);
dc8c34
 
dc8c34
@@ -1898,7 +1898,7 @@ static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode ope
dc8c34
 	s_cl5Desc.dbOpenMode = openMode;
dc8c34
 
dc8c34
 	/* initialize db environment */
dc8c34
-	rc = _cl5AppInit (&didRecovery);
dc8c34
+	rc = _cl5AppInit ();
dc8c34
 	if (rc != CL5_SUCCESS)
dc8c34
 	{
dc8c34
 		slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, 
dc8c34
@@ -1913,7 +1913,7 @@ static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode ope
dc8c34
 	}
dc8c34
 
dc8c34
 	/* open database files */
dc8c34
-	rc = _cl5DBOpen (!didRecovery);
dc8c34
+	rc = _cl5DBOpen ();
dc8c34
 	if (rc != CL5_SUCCESS)
dc8c34
 	{
dc8c34
 		slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, 
dc8c34
@@ -1989,7 +1989,7 @@ int cl5CreateDirIfNeeded (const char *dirName)
dc8c34
 	return CL5_SUCCESS;
dc8c34
 }
dc8c34
 
dc8c34
-static int _cl5AppInit (PRBool *didRecovery)
dc8c34
+static int _cl5AppInit (void)
dc8c34
 {
dc8c34
 	int rc = -1; /* initialize to failure */
dc8c34
 	DB_ENV *dbEnv = NULL;
dc8c34
@@ -2853,7 +2853,7 @@ static int _cl5Upgrade3_4(char *fromVersion, char *toVersion)
dc8c34
 	backup = s_cl5Desc.dbOpenMode;
dc8c34
 	s_cl5Desc.dbOpenMode = CL5_OPEN_CLEAN_RECOVER;
dc8c34
 	/* CL5_OPEN_CLEAN_RECOVER does 1 and 2 */
dc8c34
-	rc = _cl5AppInit (NULL);
dc8c34
+	rc = _cl5AppInit ();
dc8c34
 	if (rc != CL5_SUCCESS)
dc8c34
 	{
dc8c34
 		slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, 
dc8c34
@@ -2943,7 +2943,7 @@ static int _cl5Upgrade4_4(char *fromVersion, char *toVersion)
dc8c34
 	backup = s_cl5Desc.dbOpenMode;
dc8c34
 	s_cl5Desc.dbOpenMode = CL5_OPEN_CLEAN_RECOVER;
dc8c34
 	/* CL5_OPEN_CLEAN_RECOVER does 1 and 2 */
dc8c34
-	rc = _cl5AppInit (NULL);
dc8c34
+	rc = _cl5AppInit ();
dc8c34
 	if (rc != CL5_SUCCESS)
dc8c34
 	{
dc8c34
 		slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, 
dc8c34
@@ -4208,7 +4208,7 @@ static int _cl5Operation2LDIF (const slapi_operation_parameters *op, const char
dc8c34
 	int len = 2;
dc8c34
 	lenstr *l = NULL;
dc8c34
 	const char *strType;
dc8c34
-	char *strDeleteOldRDN;
dc8c34
+	const char *strDeleteOldRDN = "false";
dc8c34
 	char *buff, *start;
dc8c34
 	LDAPMod **add_mods;
dc8c34
 	char *rawDN = NULL;
dc8c34
diff --git a/ldap/servers/plugins/replication/windows_inc_protocol.c b/ldap/servers/plugins/replication/windows_inc_protocol.c
dc8c34
index b5fcadc..cb3b3d2 100644
dc8c34
--- a/ldap/servers/plugins/replication/windows_inc_protocol.c
dc8c34
+++ b/ldap/servers/plugins/replication/windows_inc_protocol.c
dc8c34
@@ -1175,7 +1175,7 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
dc8c34
 {
dc8c34
 	CL5Entry entry;
dc8c34
 	slapi_operation_parameters op;
dc8c34
-	int return_value;
dc8c34
+	int return_value = UPDATE_NO_MORE_UPDATES;
dc8c34
 	int rc;
dc8c34
 	int set_mincsn = 0;
dc8c34
 	CL5ReplayIterator *changelog_iterator = NULL;
dc8c34
diff --git a/ldap/servers/plugins/replication/windows_private.c b/ldap/servers/plugins/replication/windows_private.c
dc8c34
index 20360a3..a103cad 100644
dc8c34
--- a/ldap/servers/plugins/replication/windows_private.c
dc8c34
+++ b/ldap/servers/plugins/replication/windows_private.c
dc8c34
@@ -1344,11 +1344,16 @@ windows_plugin_init(Repl_Agmt *ra)
dc8c34
 {
dc8c34
     struct winsync_plugin_cookie *list = NULL;
dc8c34
     void *cookie = NULL;
dc8c34
-    PRStatus rv;
dc8c34
 
dc8c34
     LDAPDebug0Args( LDAP_DEBUG_PLUGIN, "--> windows_plugin_init_start -- begin\n");
dc8c34
 
dc8c34
-    rv = PR_CallOnce(&winsync_callOnce, windows_plugin_callonce);
dc8c34
+    if (PR_CallOnce(&winsync_callOnce, windows_plugin_callonce)) {
dc8c34
+	    PRErrorCode prerr = PR_GetError();
dc8c34
+	    slapi_log_error(SLAPI_LOG_FATAL, "windows_plugin_init",
dc8c34
+		    	    "cannot initialize plugin: %d:%s\n", prerr,
dc8c34
+		    	    slapi_pr_strerror(prerr));
dc8c34
+	    return;
dc8c34
+    }
dc8c34
 
dc8c34
     /* call each plugin init function in turn - store the returned cookie
dc8c34
        indexed by the api */
dc8c34
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
dc8c34
index 0273fd1..4473618 100644
dc8c34
--- a/ldap/servers/plugins/usn/usn.c
dc8c34
+++ b/ldap/servers/plugins/usn/usn.c
dc8c34
@@ -673,7 +673,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
dc8c34
         if (be && be->be_usn_counter) {
dc8c34
             /* get a next USN counter from be_usn_counter; 
dc8c34
              * then minus 1 from it */
dc8c34
-            PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRI64 "d",
dc8c34
+            PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
dc8c34
                                 slapi_counter_get_value(be->be_usn_counter)-1);
dc8c34
             usn_berval.bv_len = strlen(usn_berval.bv_val);
dc8c34
             slapi_entry_attr_replace(e, attr, vals);
dc8c34
@@ -692,7 +692,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
dc8c34
             }
dc8c34
             /* get a next USN counter from be_usn_counter; 
dc8c34
              * then minus 1 from it */
dc8c34
-            PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRI64 "d",
dc8c34
+            PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
dc8c34
                                 slapi_counter_get_value(be->be_usn_counter)-1);
dc8c34
             usn_berval.bv_len = strlen(usn_berval.bv_val);
dc8c34
     
dc8c34
diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c
dc8c34
index b85f073..5667acb 100644
dc8c34
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
dc8c34
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
dc8c34
@@ -3622,7 +3622,7 @@ _get_import_entryusn(ImportJob *job, Slapi_Value **usn_value)
dc8c34
              * Use the counter which stores the old DB's
dc8c34
              * next entryusn. */
dc8c34
             PR_snprintf(counter_buf, USN_COUNTER_BUF_LEN,
dc8c34
-                        "%" NSPRI64 "d",
dc8c34
+                        "%" NSPRIu64,
dc8c34
                         slapi_counter_get_value(be->be_usn_counter));
dc8c34
         } else {
dc8c34
             /* import_init value is digit.
dc8c34
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
dc8c34
index 075a48f..e3e1fb5 100644
dc8c34
--- a/ldap/servers/slapd/back-ldbm/monitor.c
dc8c34
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
dc8c34
@@ -214,13 +214,13 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
dc8c34
 #endif
dc8c34
         MSETF("dbFilename-%d", i);
dc8c34
         
dc8c34
-        sprintf(buf, "%u", mpfstat[i]->st_cache_hit);
dc8c34
+        sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_cache_hit);
dc8c34
         MSETF("dbFileCacheHit-%d", i);
dc8c34
-        sprintf(buf, "%u", mpfstat[i]->st_cache_miss);
dc8c34
+        sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_cache_miss);
dc8c34
         MSETF("dbFileCacheMiss-%d", i);
dc8c34
-        sprintf(buf, "%u", mpfstat[i]->st_page_in);
dc8c34
+        sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_page_in);
dc8c34
         MSETF("dbFilePageIn-%d", i);
dc8c34
-        sprintf(buf, "%u", mpfstat[i]->st_page_out);
dc8c34
+        sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_page_out);
dc8c34
         MSETF("dbFilePageOut-%d", i);
dc8c34
 
dc8c34
 	slapi_ch_free_string(&absolute_pathname);
dc8c34
@@ -267,7 +267,7 @@ int ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e,
dc8c34
     }
dc8c34
 
dc8c34
     /* cache hits*/
dc8c34
-    sprintf(buf, "%u", mpstat->st_cache_hit);
dc8c34
+    sprintf(buf, "%lu", (unsigned long)mpstat->st_cache_hit);
dc8c34
     MSET("dbCacheHits");
dc8c34
 
dc8c34
     /* cache tries*/
dc8c34
@@ -279,13 +279,13 @@ int ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e,
dc8c34
     sprintf(buf, "%lu", (unsigned long)(100.0 * (double)mpstat->st_cache_hit / (double)(cache_tries > 0 ? cache_tries : 1) ));
dc8c34
     MSET("dbCacheHitRatio");
dc8c34
 
dc8c34
-    sprintf(buf, "%u", mpstat->st_page_in);
dc8c34
+    sprintf(buf, "%lu", (unsigned long)mpstat->st_page_in);
dc8c34
     MSET("dbCachePageIn");
dc8c34
-    sprintf(buf, "%u", mpstat->st_page_out);
dc8c34
+    sprintf(buf, "%lu", (unsigned long)mpstat->st_page_out);
dc8c34
     MSET("dbCachePageOut");
dc8c34
-    sprintf(buf, "%u", mpstat->st_ro_evict);
dc8c34
+    sprintf(buf, "%lu", (unsigned long)mpstat->st_ro_evict);
dc8c34
     MSET("dbCacheROEvict");
dc8c34
-    sprintf(buf, "%u", mpstat->st_rw_evict);
dc8c34
+    sprintf(buf, "%lu", (unsigned long)mpstat->st_rw_evict);
dc8c34
     MSET("dbCacheRWEvict");
dc8c34
 
dc8c34
     slapi_ch_free((void **)&mpstat);
dc8c34
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
dc8c34
index e65b247..a765001 100644
dc8c34
--- a/ldap/servers/slapd/log.c
dc8c34
+++ b/ldap/servers/slapd/log.c
dc8c34
@@ -207,6 +207,15 @@ slapd_log_error_proc_internal(
dc8c34
 	/* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \
dc8c34
 	PR_Sync(fd); \
dc8c34
 	} while (0)
dc8c34
+#define LOG_WRITE_NOW_NO_ERR(fd, buffer, size, headersize) do {\
dc8c34
+	if ( slapi_write_buffer((fd), (buffer), (size)) != (size) ) \
dc8c34
+	{ \
dc8c34
+		PRErrorCode prerr = PR_GetError(); \
dc8c34
+		syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", prerr, slapd_pr_strerror(prerr), (buffer)+(headersize) ); \
dc8c34
+	} \
dc8c34
+	/* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \
dc8c34
+	PR_Sync(fd); \
dc8c34
+	} while (0)
dc8c34
 #define LOG_CLOSE(fd) \
dc8c34
 	PR_Close((fd))
dc8c34
 #endif
dc8c34
@@ -1279,7 +1288,7 @@ int
dc8c34
 log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype, char *errorbuf, int apply)
dc8c34
 {
dc8c34
 	int	rv = 0;
dc8c34
-  	PRInt64	mlogsize;	  /* in bytes */
dc8c34
+  	PRInt64	mlogsize = 0;	  /* in bytes */
dc8c34
 	PRInt64 maxdiskspace; /* in bytes */
dc8c34
 	int	s_maxdiskspace;   /* in megabytes */
dc8c34
   
dc8c34
@@ -1520,7 +1529,7 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
dc8c34
 {
dc8c34
 	int	value = 0;
dc8c34
 	int	rv = 0;
dc8c34
-	int	exptime, rsecs;
dc8c34
+	int	exptime = 0, rsecs = 0;
dc8c34
 	int	*exptimeunitp = NULL;
dc8c34
 	slapdFrontendConfig_t *fe_cfg = getFrontendConfig();
dc8c34
 
dc8c34
@@ -1642,12 +1651,11 @@ log_write_title (LOGFD fp)
dc8c34
 	char *buildnum = config_get_buildnum();
dc8c34
 	char buff[512];
dc8c34
 	int bufflen = sizeof(buff);
dc8c34
-	int err = 0;
dc8c34
 
dc8c34
 	PR_snprintf(buff, bufflen, "\t%s B%s\n",
dc8c34
 				fe_cfg->versionstring ? fe_cfg->versionstring : CAPBRAND "-Directory/" DS_PACKAGE_VERSION,
dc8c34
 				buildnum ? buildnum : "");
dc8c34
-	LOG_WRITE_NOW(fp, buff, strlen(buff), 0, err);
dc8c34
+	LOG_WRITE_NOW_NO_ERR(fp, buff, strlen(buff), 0);
dc8c34
 
dc8c34
 	if (fe_cfg->localhost) {
dc8c34
 		PR_snprintf(buff, bufflen, "\t%s:%d (%s)\n\n",
dc8c34
@@ -1662,7 +1670,7 @@ log_write_title (LOGFD fp)
dc8c34
 		PR_snprintf(buff, bufflen, "\t<host>:<port> (%s)\n\n",
dc8c34
 				fe_cfg->configdir ? fe_cfg->configdir : "");
dc8c34
 	}
dc8c34
-	LOG_WRITE_NOW(fp, buff, strlen(buff), 0, err);
dc8c34
+	LOG_WRITE_NOW_NO_ERR(fp, buff, strlen(buff), 0);
dc8c34
 	slapi_ch_free((void **)&buildnum);
dc8c34
 }
dc8c34
 
dc8c34
@@ -1768,7 +1776,7 @@ slapd_log_audit_proc (
dc8c34
 			log_write_title( loginfo.log_audit_fdes);
dc8c34
 			loginfo.log_audit_state &= ~LOGGING_NEED_TITLE;
dc8c34
 		}
dc8c34
-	    LOG_WRITE_NOW(loginfo.log_audit_fdes, buffer, buf_len, 0, err);
dc8c34
+	    LOG_WRITE_NOW_NO_ERR(loginfo.log_audit_fdes, buffer, buf_len, 0);
dc8c34
    		LOG_AUDIT_UNLOCK_WRITE();
dc8c34
 	    return 0;
dc8c34
 	}
dc8c34
@@ -4185,8 +4193,8 @@ static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
dc8c34
 		if (!sync_now && slapdFrontendConfig->accesslogbuffering) {
dc8c34
 			LOG_WRITE(loginfo.log_access_fdes, lbi->top, lbi->current - lbi->top, 0);
dc8c34
 		} else {
dc8c34
-			LOG_WRITE_NOW(loginfo.log_access_fdes, lbi->top,
dc8c34
-								lbi->current - lbi->top, 0, err);
dc8c34
+			LOG_WRITE_NOW_NO_ERR(loginfo.log_access_fdes, lbi->top,
dc8c34
+								lbi->current - lbi->top, 0);
dc8c34
 		}
dc8c34
 
dc8c34
         lbi->current = lbi->top;
dc8c34
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
dc8c34
index da8e4f3..19c5708 100644
dc8c34
--- a/ldap/servers/slapd/mapping_tree.c
dc8c34
+++ b/ldap/servers/slapd/mapping_tree.c
dc8c34
@@ -158,8 +158,10 @@ static mapping_tree_node *
dc8c34
 static int _mtn_update_config_param(int op, char *type, char *strvalue);
dc8c34
 
dc8c34
 #ifdef DEBUG
dc8c34
+#ifdef USE_DUMP_MAPPING_TREE
dc8c34
 static void dump_mapping_tree(mapping_tree_node *parent, int depth);
dc8c34
 #endif
dc8c34
+#endif
dc8c34
 
dc8c34
 /* structure and static local variable used to store the
dc8c34
  * list of plugins that have registered to a callback when backend state
dc8c34
@@ -3721,6 +3723,7 @@ void test_register()
dc8c34
 #endif
dc8c34
 
dc8c34
 #ifdef DEBUG
dc8c34
+#ifdef USE_DUMP_MAPPING_TREE
dc8c34
 static void dump_mapping_tree(mapping_tree_node *parent, int depth)
dc8c34
 {
dc8c34
     mapping_tree_node *current = NULL;
dc8c34
@@ -3751,7 +3754,8 @@ static void dump_mapping_tree(mapping_tree_node *parent, int depth)
dc8c34
     }
dc8c34
     return;
dc8c34
 }
dc8c34
-#endif
dc8c34
+#endif /* USE_DUMP_MAPPING_TREE */
dc8c34
+#endif /* DEBUG */
dc8c34
 
dc8c34
 /* helper function to set/remove the config param in cn=config */
dc8c34
 static int
dc8c34
diff --git a/ldap/servers/slapd/regex.c b/ldap/servers/slapd/regex.c
dc8c34
index 3697fde..29edffe 100644
dc8c34
--- a/ldap/servers/slapd/regex.c
dc8c34
+++ b/ldap/servers/slapd/regex.c
dc8c34
@@ -161,7 +161,7 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
dc8c34
     int  pin;
dc8c34
     int  *ovector;
dc8c34
     char *mydst;
dc8c34
-    const char *prev, *next;
dc8c34
+    const char *prev;
dc8c34
     const char *substring_start;
dc8c34
     const char *p;
dc8c34
 
dc8c34
@@ -179,8 +179,7 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
dc8c34
     for (p = src; *p != '\0'; p++) {
dc8c34
         if ('&' == *p) {
dc8c34
             /* Don't replace '&' if it's a filter AND: "(&(cn=a)(sn=b))"  */
dc8c34
-            next = p;
dc8c34
-            if(!filter || (*prev != '(' && *next++ != '(')){
dc8c34
+            if(!filter || !(*prev == '(' && *(p+1) == '(')){
dc8c34
                 if (re_handle->re_oveccount <= 1) {
dc8c34
                     memset(*dst, '\0', dstlen);
dc8c34
                     return -1;
dc8c34
@@ -188,6 +187,11 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
dc8c34
                 substring_start = subject + ovector[0];
dc8c34
                 thislen = ovector[1] - ovector[0];
dc8c34
                 len += thislen;
dc8c34
+            } else { /* is a filter AND clause */
dc8c34
+                /* just copy it into the filter */
dc8c34
+                substring_start = p;
dc8c34
+                thislen = 1;
dc8c34
+                len++;
dc8c34
             }
dc8c34
         } else if (('\\' == *p) && ('0' <= *(p+1) && *(p+1) <= '9')) {
dc8c34
             pin = *(++p) - '0';
dc8c34
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
dc8c34
index 5b3e1ab..0fdb206 100644
dc8c34
--- a/ldap/servers/slapd/slapi-plugin.h
dc8c34
+++ b/ldap/servers/slapd/slapi-plugin.h
dc8c34
@@ -6870,6 +6870,15 @@ int slapi_ldap_get_lderrno(LDAP *ld, char **m, char **s);
dc8c34
 #endif
dc8c34
 void slapi_ldif_put_type_and_value_with_options( char **out, const char *t, const char *val, int vlen, unsigned long options );
dc8c34
 
dc8c34
+/* ldif_read_record lineno argument type depends on openldap version */
dc8c34
+#if defined(USE_OPENLDAP)
dc8c34
+#if LDAP_VENDOR_VERSION >= 20434 /* changed in 2.4.34 */
dc8c34
+typedef unsigned long int ldif_record_lineno_t;
dc8c34
+#else
dc8c34
+typedef int ldif_record_lineno_t;
dc8c34
+#endif
dc8c34
+#endif
dc8c34
+
dc8c34
 #if defined(USE_OPENLDAP)
dc8c34
 /*
dc8c34
  * UTF-8 routines (should these move into libnls?)
dc8c34
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
dc8c34
index 3f74fd0..b177d7c 100644
dc8c34
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
dc8c34
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
dc8c34
@@ -732,10 +732,8 @@ LDAP *
dc8c34
 connectToLDAP(thread_context *tttctx, const char *bufBindDN, const char *bufPasswd, unsigned int mode, unsigned int mod2)
dc8c34
 {
dc8c34
   LDAP *ld = NULL;
dc8c34
-  const char *mech = LDAP_SASL_SIMPLE;
dc8c34
   struct berval cred = {0, NULL};
dc8c34
   int v2v3 = LDAP_VERSION3;
dc8c34
-  const char *binddn = NULL;
dc8c34
   const char *passwd = NULL;
dc8c34
 #if defined(USE_OPENLDAP)
dc8c34
   char *ldapurl = NULL;
dc8c34
@@ -863,11 +861,8 @@ connectToLDAP(thread_context *tttctx, const char *bufBindDN, const char *bufPass
dc8c34
 #endif /* !USE_OPENLDAP */
dc8c34
 
dc8c34
   if (mode & CLTAUTH) {
dc8c34
-    mech = "EXTERNAL";
dc8c34
-    binddn = "";
dc8c34
     passwd = NULL;
dc8c34
   } else {
dc8c34
-    binddn = bufBindDN?bufBindDN:mctx.bindDN;
dc8c34
     passwd = bufPasswd?bufPasswd:mctx.passwd;
dc8c34
     if (passwd) {
dc8c34
       cred.bv_val = (char *)passwd;
dc8c34
diff --git a/ldap/servers/slapd/tools/rsearch/infadd.c b/ldap/servers/slapd/tools/rsearch/infadd.c
dc8c34
index 607381a..4a9f2e9 100644
dc8c34
--- a/ldap/servers/slapd/tools/rsearch/infadd.c
dc8c34
+++ b/ldap/servers/slapd/tools/rsearch/infadd.c
dc8c34
@@ -127,11 +127,10 @@ char *randName(void)
dc8c34
     return x;
dc8c34
 }
dc8c34
 
dc8c34
-int fill_table(NameTable *nt, PRUint32 size)
dc8c34
+void fill_table(NameTable *nt, PRUint32 size)
dc8c34
 {
dc8c34
     PRUint32 i;
dc8c34
     char *x;
dc8c34
-    int ret;
dc8c34
 
dc8c34
     fprintf(stdout, "Generating random names: 0      ");
dc8c34
     for (i = 0; i < size; i++) {
dc8c34
@@ -141,13 +140,13 @@ int fill_table(NameTable *nt, PRUint32 size)
dc8c34
 	    free(x);
dc8c34
 	    x = randName();
dc8c34
 	}
dc8c34
-	ret = nt_push(nt, x);
dc8c34
+	(void)nt_push(nt, x);
dc8c34
 	if ((i % 100) == 0) {
dc8c34
 	    fprintf(stdout, "\b\b\b\b\b\b\b%-7d", i);
dc8c34
 	}
dc8c34
     }
dc8c34
     fprintf(stdout, "\b\b\b\b\b\b\b%d.  Done.\n", size);
dc8c34
-    return ret;
dc8c34
+    return;
dc8c34
 }
dc8c34
 
dc8c34
 int main(int argc, char **argv)
dc8c34
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
dc8c34
index 53af972..0d1fb25 100644
dc8c34
--- a/ldap/servers/snmp/main.c
dc8c34
+++ b/ldap/servers/snmp/main.c
dc8c34
@@ -236,6 +236,15 @@ main (int argc, char *argv[]) {
dc8c34
     return 0;
dc8c34
 }
dc8c34
 
dc8c34
+/* ldif_read_record lineno argument type depends on openldap version */
dc8c34
+#if defined(USE_OPENLDAP)
dc8c34
+#if LDAP_VENDOR_VERSION >= 20434 /* changed in 2.4.34 */
dc8c34
+typedef unsigned long int ldif_record_lineno_t;
dc8c34
+#else
dc8c34
+typedef int ldif_record_lineno_t;
dc8c34
+#endif
dc8c34
+#endif
dc8c34
+
dc8c34
 /************************************************************************
dc8c34
  * load_config
dc8c34
  *
dc8c34
@@ -249,8 +258,10 @@ load_config(char *conf_path)
dc8c34
 #if defined(USE_OPENLDAP)
dc8c34
     LDIFFP *dse_fp = NULL;
dc8c34
     int buflen = 0;
dc8c34
+    ldif_record_lineno_t lineno = 0;
dc8c34
 #else
dc8c34
     FILE *dse_fp = NULL;
dc8c34
+    int lineno = 0;
dc8c34
 #endif
dc8c34
     char line[MAXLINE];
dc8c34
     char *p = NULL;
dc8c34
@@ -329,10 +340,10 @@ load_config(char *conf_path)
dc8c34
         } else if ((p = strstr(line, "server")) != NULL) {
dc8c34
             int got_port = 0;
dc8c34
             int got_rundir = 0;
dc8c34
-            int lineno = 0;
dc8c34
             char *entry = NULL;
dc8c34
             char *instancename = NULL;
dc8c34
 
dc8c34
+            lineno = 0;
dc8c34
             /* Allocate a server_instance */
dc8c34
             if ((serv_p = malloc(sizeof(server_instance))) == NULL) {
dc8c34
                 printf("ldap-agent: malloc error processing config file\n");
dc8c34
diff --git a/lib/libaccess/acltools.cpp b/lib/libaccess/acltools.cpp
dc8c34
index df08658..4c1d28c 100644
dc8c34
--- a/lib/libaccess/acltools.cpp
dc8c34
+++ b/lib/libaccess/acltools.cpp
dc8c34
@@ -1741,7 +1741,7 @@ static PList_t ACLAttr2IndexPList = NULL;
dc8c34
 int
dc8c34
 ACL_InitAttr2Index(void)
dc8c34
 {
dc8c34
-    int i;
dc8c34
+    intptr_t i;
dc8c34
 
dc8c34
     if (ACLAttr2IndexPList) return 0;
dc8c34
 
dc8c34
diff --git a/lib/libaccess/register.cpp b/lib/libaccess/register.cpp
dc8c34
index 3f2acc5..595c1f2 100644
dc8c34
--- a/lib/libaccess/register.cpp
dc8c34
+++ b/lib/libaccess/register.cpp
dc8c34
@@ -77,6 +77,8 @@ ACL_LasHashInit()
dc8c34
 {
dc8c34
     int	i;
dc8c34
 
dc8c34
+    (void)(link_ACLGlobal); /* get rid of defined but not used compiler warning */
dc8c34
+    (void)(link_nsacl_table); /* get rid of defined but not used compiler warning */
dc8c34
     ACLLasEvalHash = PR_NewHashTable(0,
dc8c34
 				     PR_HashString,
dc8c34
 				     PR_CompareStrings,
dc8c34
@@ -268,11 +270,11 @@ ACL_MethodRegister(NSErr_t *errp, const char *name, ACLMethod_t *t)
dc8c34
     }
dc8c34
 	
dc8c34
     /*  Put it in the hash table  */
dc8c34
-    if (NULL == PR_HashTableAdd(ACLMethodHash, name, (void *)++cur_method)) {
dc8c34
+    if (NULL == PR_HashTableAdd(ACLMethodHash, name, (void *)(intptr_t)++cur_method)) {
dc8c34
         ACL_CritExit();
dc8c34
         return -1;
dc8c34
     }
dc8c34
-    *t = (ACLMethod_t) cur_method;
dc8c34
+    *t = (ACLMethod_t) (intptr_t)cur_method;
dc8c34
 
dc8c34
     ACL_CritExit();
dc8c34
     return 0;
dc8c34
@@ -412,11 +414,11 @@ ACL_DbTypeRegister(NSErr_t *errp, const char *name, DbParseFn_t func, ACLDbType_
dc8c34
     }
dc8c34
 	
dc8c34
     /*  Put it in the hash table  */
dc8c34
-    if (NULL == PR_HashTableAdd(ACLDbTypeHash, name, (void *)++cur_dbtype)) {
dc8c34
+    if (NULL == PR_HashTableAdd(ACLDbTypeHash, name, (void *)(intptr_t)++cur_dbtype)) {
dc8c34
         ACL_CritExit();
dc8c34
         return -1;
dc8c34
     }
dc8c34
-    *t = (ACLDbType_t) cur_dbtype;
dc8c34
+    *t = (ACLDbType_t) (intptr_t)cur_dbtype;
dc8c34
     ACLDbParseFnTable[cur_dbtype] = func;
dc8c34
 
dc8c34
     ACL_CritExit();
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34