>From 8d447ca0c352fd529e7d436c7380b0ea2280e25c Mon Sep 17 00:00:00 2001
From: Rich Megginson <rmeggins@redhat.com>
Date: Tue, 7 Jul 2009 13:22:45 -0600
Subject: [PATCH] Clean up compiler warnings
 This cleans up all of the compiler warnings produced with -Wall on RHEL/Fedora platforms.
 The warnings about the %lld and %llu formats are still produced and cannot be helped.

---
 ldap/servers/plugins/acl/acl.c                   |    6 +++---
 ldap/servers/plugins/acl/acllas.c                |   11 +++++++++--
 ldap/servers/plugins/replication/repl5_replica.c |    3 ++-
 ldap/servers/plugins/replication/replutil.c      |    2 +-
 ldap/servers/plugins/syntaxes/string.c           |    5 +++--
 ldap/servers/slapd/backend.c                     |    2 +-
 ldap/servers/slapd/getfilelist.c                 |    2 +-
 ldap/servers/slapd/pblock.c                      |    4 ++--
 ldap/servers/slapd/sasl_map.c                    |    2 +-
 ldap/servers/slapd/slap.h                        |    5 +++--
 10 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/ldap/servers/plugins/acl/acl.c b/ldap/servers/plugins/acl/acl.c
index b708cad..d62796f 100644
--- a/ldap/servers/plugins/acl/acl.c
+++ b/ldap/servers/plugins/acl/acl.c
@@ -3148,6 +3148,7 @@ acl_match_substring ( Slapi_Filter *f, char *str, int exact_match)
 	char		*type, *initial, *final;
 	char		**any;
 	Slapi_Regex	*re = NULL;
+	const char  *re_result = NULL;
 
 	if ( 0 != slapi_filter_get_subfilt ( f, &type, &initial, &any, &final ) ) {
 		return (ACL_FALSE);
@@ -3235,11 +3236,10 @@ acl_match_substring ( Slapi_Filter *f, char *str, int exact_match)
 	** Now we will compile the pattern and compare wth the string to
 	** see if the input string matches with the patteren or not.
 	*/
-	p = NULL;
-	re = slapi_re_comp( pat, &p );
+	re = slapi_re_comp( pat, &re_result );
 	if (NULL == re) {
 		slapi_log_error (SLAPI_LOG_ACL, plugin_name, 
-			"acl_match_substring:re_comp failed (%s)\n", p?p:"unknown");
+			"acl_match_substring:re_comp failed (%s)\n", re_result?re_result:"unknown");
 		return (ACL_ERR);
 	}
 
diff --git a/ldap/servers/plugins/acl/acllas.c b/ldap/servers/plugins/acl/acllas.c
index abde4fd..e16fbd2 100644
--- a/ldap/servers/plugins/acl/acllas.c
+++ b/ldap/servers/plugins/acl/acllas.c
@@ -2218,7 +2218,7 @@ acllas__handle_group_entry (Slapi_Entry* e, void *callback_data)
  	Slapi_Attr		*currAttr, *nextAttr;
 	char			*n_dn, *attrType;
 	int				n;
-	int				i, j;
+	int				i;
 
 	info = (struct eval_info *) callback_data;
 	info->result = ACL_FALSE;
@@ -2252,11 +2252,18 @@ acllas__handle_group_entry (Slapi_Entry* e, void *callback_data)
 					return 0;
 				}
 				if (!(n % ACLLAS_MAX_GRP_MEMBER)) {
-					struct member_info *orig_memberInfo = info->memberInfo[0];
+					struct member_info **orig_memberInfo = info->memberInfo;
 					info->memberInfo = (struct member_info **)slapi_ch_realloc(
 							(char *)info->memberInfo,
 							(n + ACLLAS_MAX_GRP_MEMBER) *
 							sizeof(struct member_info *));
+					if (!info->memberInfo) {
+						slapi_log_error( SLAPI_LOG_FATAL, plugin_name,
+										 "acllas__handle_group_entry: out of memory - could not allocate space for %d group members\n",
+										 n + ACLLAS_MAX_GRP_MEMBER );
+						info->memberInfo = orig_memberInfo;
+						return 0;
+					}
 				}
 
 				/* allocate the space for the member and attch it to the list */
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 5f280b1..a563835 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -1012,7 +1012,8 @@ replica_set_referrals(Replica *r,const Slapi_ValueSet *vs)
 		{
 			const char *ref = slapi_value_get_string(vv);
 			LDAPURLDesc *lud = NULL;
-			int myrc = slapi_ldap_url_parse(ref, &lud, 0, NULL);
+
+			(void)slapi_ldap_url_parse(ref, &lud, 0, NULL);
 			/* see if the dn is already in the referral URL */
 			if (!lud || !lud->lud_dn) {
 				/* add the dn */
diff --git a/ldap/servers/plugins/replication/replutil.c b/ldap/servers/plugins/replication/replutil.c
index 8703c7c..aaa427b 100644
--- a/ldap/servers/plugins/replication/replutil.c
+++ b/ldap/servers/plugins/replication/replutil.c
@@ -740,7 +740,7 @@ repl_set_mtn_state_and_referrals(
 	/* next, add the repl root dn to each referral if not present */
 	for (ii = 0; referrals_to_set && referrals_to_set[ii]; ++ii) {
 		LDAPURLDesc *lud = NULL;
-		int myrc = slapi_ldap_url_parse(referrals_to_set[ii], &lud, 0, NULL);
+		(void)slapi_ldap_url_parse(referrals_to_set[ii], &lud, 0, NULL);
 		/* see if the dn is already in the referral URL */
 		if (!lud || !lud->lud_dn) {
 			/* add the dn */
diff --git a/ldap/servers/plugins/syntaxes/string.c b/ldap/servers/plugins/syntaxes/string.c
index 218cc76..c2f0fa6 100644
--- a/ldap/servers/plugins/syntaxes/string.c
+++ b/ldap/servers/plugins/syntaxes/string.c
@@ -210,6 +210,7 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char *final,
 	int		timelimit = 0; /* search timelimit */
 	Operation	*op = NULL;
 	Slapi_Regex	*re = NULL;
+	const char  *re_result = NULL;
 
 	LDAPDebug( LDAP_DEBUG_FILTER, "=> string_filter_sub\n",
 	    0, 0, 0 );
@@ -286,10 +287,10 @@ string_filter_sub( Slapi_PBlock *pb, char *initial, char **any, char *final,
 	/* compile the regex */
 	p = (bigpat) ? bigpat : pat;
 	tmpbuf = NULL;
-	re = slapi_re_comp( p, &tmpbuf );
+	re = slapi_re_comp( p, &re_result );
 	if (NULL == re) {
 		LDAPDebug( LDAP_DEBUG_ANY, "re_comp (%s) failed (%s): %s\n",
-		    pat, p, tmpbuf?tmpbuf:"unknown" );
+		    pat, p, re_result?re_result:"unknown" );
 		rc = LDAP_OPERATIONS_ERROR;
 		goto bailout;
 	} else {
diff --git a/ldap/servers/slapd/backend.c b/ldap/servers/slapd/backend.c
index 1bded05..c4c399f 100644
--- a/ldap/servers/slapd/backend.c
+++ b/ldap/servers/slapd/backend.c
@@ -502,7 +502,7 @@ slapi_be_setentrypoint(Slapi_Backend *be, int entrypoint, void *ret_fnptr, Slapi
         be->be_entry_release=(IFP) ret_fnptr;
         break;
 	case SLAPI_PLUGIN_DB_SEARCH_RESULTS_RELEASE_FN:
-        be->be_search_results_release=(IFP) ret_fnptr;
+        be->be_search_results_release=(VFPP) ret_fnptr;
         break;
 	case SLAPI_PLUGIN_DB_SIZE_FN:
         be->be_dbsize=(IFP) ret_fnptr;
diff --git a/ldap/servers/slapd/getfilelist.c b/ldap/servers/slapd/getfilelist.c
index ac79430..c8dd8f9 100644
--- a/ldap/servers/slapd/getfilelist.c
+++ b/ldap/servers/slapd/getfilelist.c
@@ -124,7 +124,7 @@ matches(const char *filename, const char *pattern)
 {
 	Slapi_Regex *re = NULL;
 	int match = 0;
-	char *error = NULL;
+	const char *error = NULL;
 
 	if (!pattern)
 		return 1; /* null pattern matches everything */
diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c
index c89a648..98984ad 100644
--- a/ldap/servers/slapd/pblock.c
+++ b/ldap/servers/slapd/pblock.c
@@ -516,7 +516,7 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
 		if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
 			return( -1 );
 		}
-		(*(IFP *)value) = pblock->pb_plugin->plg_search_results_release;
+		(*(VFPP *)value) = pblock->pb_plugin->plg_search_results_release;
 		break;
 	case SLAPI_PLUGIN_DB_COMPARE_FN:
 		if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
@@ -1814,7 +1814,7 @@ slapi_pblock_set( Slapi_PBlock *pblock, int arg, void *value )
 		if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
 			return( -1 );
 		}
-		pblock->pb_plugin->plg_search_results_release = (IFP) value;
+		pblock->pb_plugin->plg_search_results_release = (VFPP) value;
 		break;
 	case SLAPI_PLUGIN_DB_COMPARE_FN:
 		if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
diff --git a/ldap/servers/slapd/sasl_map.c b/ldap/servers/slapd/sasl_map.c
index 637ea5d..383f045 100644
--- a/ldap/servers/slapd/sasl_map.c
+++ b/ldap/servers/slapd/sasl_map.c
@@ -469,7 +469,7 @@ sasl_map_check(sasl_map_data *dp, char *sasl_user_and_realm, char **ldap_search_
 	Slapi_Regex *re = NULL;
 	int ret = 0;
 	int matched = 0;
-	char *recomp_result = NULL;
+	const char *recomp_result = NULL;
 
 	LDAPDebug( LDAP_DEBUG_TRACE, "-> sasl_map_check\n", 0, 0, 0 );
 	/* Compiles the regex */
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 7fd6761..696d810 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -211,7 +211,8 @@ typedef struct symbol_t {
 #define SLAPD_SHORT_VERSION_STR	PRODUCTTEXT
 
 typedef void	(*VFP)(void *);
-typedef void	(*VFP0)();
+typedef void	(*VFPP)(void **);
+typedef void	(*VFP0)(void);
 #define LDAPI_INTERNAL	1
 #include "slapi-private.h"
 #include "pw.h"
@@ -765,7 +766,7 @@ struct slapdplugin {
 			IFP	plg_un_db_search;	  /* search */
 			IFP	plg_un_db_next_search_entry;	/* iterate */
 	        IFP plg_un_db_next_search_entry_ext;
-			IFP plg_un_db_search_results_release; /* PAGED RESULTS */
+			VFPP plg_un_db_search_results_release; /* PAGED RESULTS */
 	        IFP plg_un_db_entry_release;
 			IFP	plg_un_db_compare;	  /* compare */
 			IFP	plg_un_db_modify;	  /* modify */
-- 
1.5.5.6

