Răsfoiți Sursa

Bug Description: Need to address 64-bit compiler warnings - part 1
Reviewed by: nhosoi (Thanks!)
Fix Description: The intptr_t and uintptr_t are types which are defined as integer types that are the same size as the pointer (void *) type. On the platforms we currently support, this is the same as long and unsigned long, respectively (ILP32 and LP64). However, intptr_t and uintptr_t are more portable. These can be used to assign a value passed as a void * to get an integer value, then "cast down" to an int or PRBool, and vice versa. This seems to be a common idiom in other applications where values must be passed as void *.
For the printf/scanf formats, there is a standard header called inttypes.h which defines formats to use for various 64 bit quantities, so that you don't need to figure out if you have to use %lld or %ld for a 64-bit value - you just use PRId64 which is set to the correct value. I also assumed that size_t is defined as the same size as a pointer so I used the PRIuPTR format macro for size_t.
I removed many unused variables and some unused functions.
I put parentheses around assignments in conditional expressions to tell the compiler not to complain about them.
I cleaned up some #defines that were defined more than once.
I commented out some unused goto labels.
Some of our header files shared among several source files define static variables. I made it so that those variables are not defined unless a macro is set in the source file. This avoids a lot of unused variable warnings.
I added some return values to functions that were declared as returning a value but did not return a value. In all of these cases no one was checking the return value anyway.
I put explicit parentheses around cases like this: expr || expr && expr - the && has greater precedence than the ||. The compiler complains because it wants you to make sure you mean expr || (expr && expr), not (expr || expr) && expr.
I cleaned up several places where the compiler was complaining about possible use of uninitialized variables. There are still a lot of these cases remaining.
There are a lot of warnings like this:
lib/ldaputil/certmap.c:1279: warning: dereferencing type-punned pointer will break strict-aliasing rules
These are due to our use of void ** to pass in addresses of addresses of structures. Many of these are calls to slapi_ch_free, but many are not - they are cases where we do not know what the type is going to be and may have to cast and modify the structure or pointer. I started replacing the calls to slapi_ch_free with slapi_ch_free_string, but there are many many more that need to be fixed.
The dblayer code also contains a fix for https://bugzilla.redhat.com/show_bug.cgi?id=463991 - instead of checking for dbenv->foo_handle to see if a db "feature" is enabled, instead check the flags passed to open the dbenv. This works for bdb 4.2 through bdb 4.7 and probably other releases as well.
Platforms tested: RHEL5 x86_64, Fedora 8 i386
Flag Day: no
Doc impact: no

Rich Megginson 17 ani în urmă
părinte
comite
b3797a8704
74 a modificat fișierele cu 443 adăugiri și 349 ștergeri
  1. 12 11
      configure
  2. 2 2
      configure.ac
  3. 3 3
      include/i18n.h
  4. 4 1
      include/ldaputil/certmap.h
  5. 4 4
      ldap/servers/plugins/acl/aclparse.c
  6. 5 4
      ldap/servers/plugins/acl/aclutil.c
  7. 45 45
      ldap/servers/plugins/chainingdb/cb_instance.c
  8. 31 26
      ldap/servers/plugins/dna/dna.c
  9. 1 1
      ldap/servers/plugins/pam_passthru/pam_ptimpl.c
  10. 2 2
      ldap/servers/plugins/passthru/ptconfig.c
  11. 1 10
      ldap/servers/plugins/presence/presence.c
  12. 2 0
      ldap/servers/plugins/pwdstorage/crypt_pwd.c
  13. 0 2
      ldap/servers/plugins/replication/cl5_api.c
  14. 1 1
      ldap/servers/plugins/replication/repl5_agmt.c
  15. 1 1
      ldap/servers/plugins/replication/repl5_connection.c
  16. 2 1
      ldap/servers/plugins/replication/repl5_protocol_util.c
  17. 1 1
      ldap/servers/plugins/replication/repl5_replica.c
  18. 1 1
      ldap/servers/plugins/replication/repl5_updatedn_list.c
  19. 1 7
      ldap/servers/plugins/roles/roles_plugin.c
  20. 1 1
      ldap/servers/slapd/agtmmap.c
  21. 4 4
      ldap/servers/slapd/auth.c
  22. 9 0
      ldap/servers/slapd/back-ldbm/back-ldbm.h
  23. 24 17
      ldap/servers/slapd/back-ldbm/dblayer.c
  24. 0 2
      ldap/servers/slapd/back-ldbm/dbverify.c
  25. 8 1
      ldap/servers/slapd/back-ldbm/import-merge.c
  26. 17 9
      ldap/servers/slapd/back-ldbm/import-threads.c
  27. 11 5
      ldap/servers/slapd/back-ldbm/import.c
  28. 0 1
      ldap/servers/slapd/back-ldbm/import.h
  29. 6 6
      ldap/servers/slapd/back-ldbm/ldbm_attr.c
  30. 70 63
      ldap/servers/slapd/back-ldbm/ldbm_config.c
  31. 7 6
      ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
  32. 7 7
      ldap/servers/slapd/back-ldbm/ldbm_modify.c
  33. 16 10
      ldap/servers/slapd/back-ldbm/ldif2ldbm.c
  34. 9 2
      ldap/servers/slapd/back-ldbm/monitor.c
  35. 8 1
      ldap/servers/slapd/back-ldbm/parents.c
  36. 4 4
      ldap/servers/slapd/back-ldbm/perfctrs.c
  37. 2 2
      ldap/servers/slapd/bind.c
  38. 2 2
      ldap/servers/slapd/config.c
  39. 5 5
      ldap/servers/slapd/configdse.c
  40. 1 1
      ldap/servers/slapd/conntable.c
  41. 2 2
      ldap/servers/slapd/detach.c
  42. 10 1
      ldap/servers/slapd/dse.c
  43. 2 2
      ldap/servers/slapd/filter.c
  44. 5 1
      ldap/servers/slapd/libglobs.c
  45. 2 2
      ldap/servers/slapd/log.c
  46. 4 0
      ldap/servers/slapd/log.h
  47. 0 3
      ldap/servers/slapd/main.c
  48. 1 1
      ldap/servers/slapd/mapping_tree.c
  49. 1 1
      ldap/servers/slapd/pblock.c
  50. 0 1
      ldap/servers/slapd/saslbind.c
  51. 0 1
      ldap/servers/slapd/snmp_collator.c
  52. 3 1
      ldap/servers/slapd/statechange.h
  53. 6 0
      ldap/servers/slapd/task.c
  54. 14 15
      ldap/servers/slapd/tools/ldclt/ldapfct.c
  55. 8 8
      ldap/servers/slapd/tools/ldclt/scalab01.c
  56. 1 1
      ldap/servers/slapd/tools/ldif.c
  57. 2 2
      ldap/servers/slapd/tools/mmldif.c
  58. 2 4
      ldap/servers/slapd/tools/pwenc.c
  59. 2 1
      ldap/servers/slapd/tools/rsearch/infadd.c
  60. 2 2
      ldap/servers/slapd/tools/rsearch/rsearch.c
  61. 1 1
      ldap/servers/slapd/tools/rsearch/searchthread.c
  62. 2 2
      ldap/servers/slapd/uuid.c
  63. 20 0
      ldap/servers/snmp/ldap-agent.h
  64. 6 2
      lib/ldaputil/certmap.c
  65. 1 0
      lib/ldaputil/ldapauth.c
  66. 3 0
      lib/ldaputil/ldapdb.c
  67. 1 1
      lib/libaccess/aclerror.cpp
  68. 1 1
      lib/libaccess/acltools.cpp
  69. 2 2
      lib/libaccess/lasdns.cpp
  70. 2 2
      lib/libaccess/lasip.cpp
  71. 1 1
      lib/libaccess/ldapacl.cpp
  72. 2 2
      lib/libaccess/oneeval.cpp
  73. 0 10
      lib/libsi18n/getstrmem.h
  74. 4 4
      lib/libsi18n/gsslapd.h

+ 12 - 11
configure

@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for dirsrv 1.1.3.
+# Generated by GNU Autoconf 2.59 for dirsrv 1.1.4.
 #
 # Report bugs to <http://bugzilla.redhat.com/>.
 #
@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='dirsrv'
 PACKAGE_TARNAME='dirsrv'
-PACKAGE_VERSION='1.1.3'
-PACKAGE_STRING='dirsrv 1.1.3'
+PACKAGE_VERSION='1.1.4'
+PACKAGE_STRING='dirsrv 1.1.4'
 PACKAGE_BUGREPORT='http://bugzilla.redhat.com/'
 
 # Factoring default headers for most tests.
@@ -954,7 +954,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures dirsrv 1.1.3 to adapt to many kinds of systems.
+\`configure' configures dirsrv 1.1.4 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1020,7 +1020,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of dirsrv 1.1.3:";;
+     short | recursive ) echo "Configuration of dirsrv 1.1.4:";;
    esac
   cat <<\_ACEOF
 
@@ -1203,7 +1203,7 @@ fi
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
-dirsrv configure 1.1.3
+dirsrv configure 1.1.4
 generated by GNU Autoconf 2.59
 
 Copyright (C) 2003 Free Software Foundation, Inc.
@@ -1217,7 +1217,7 @@ cat >&5 <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by dirsrv $as_me 1.1.3, which was
+It was created by dirsrv $as_me 1.1.4, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   $ $0 $@
@@ -1863,7 +1863,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='dirsrv'
- VERSION='1.1.3'
+ VERSION='1.1.4'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -19369,7 +19369,8 @@ fi
 
 
 
-for ac_header in arpa/inet.h fcntl.h malloc.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/file.h sys/socket.h sys/time.h unistd.h
+
+for ac_header in arpa/inet.h fcntl.h malloc.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/file.h sys/socket.h sys/time.h unistd.h inttypes.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
@@ -25795,7 +25796,7 @@ _ASBOX
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by dirsrv $as_me 1.1.3, which was
+This file was extended by dirsrv $as_me 1.1.4, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -25858,7 +25859,7 @@ _ACEOF
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-dirsrv config.status 1.1.3
+dirsrv config.status 1.1.4
 configured by $0, generated by GNU Autoconf 2.59,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 

+ 2 - 2
configure.ac

@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.59)
 # This version is the version returned by ns-slapd -v
-AC_INIT([dirsrv], [1.1.3], [http://bugzilla.redhat.com/])
+AC_INIT([dirsrv], [1.1.4], [http://bugzilla.redhat.com/])
 # AC_CONFIG_HEADER must be called right after AC_INIT.
 AC_CONFIG_HEADERS([config.h])
 AM_INIT_AUTOMAKE([1.9 foreign subdir-objects])
@@ -21,7 +21,7 @@ AC_PROG_LIBTOOL
 AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h malloc.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/file.h sys/socket.h sys/time.h unistd.h])
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h malloc.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/file.h sys/socket.h sys/time.h unistd.h inttypes.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_HEADER_STAT

+ 3 - 3
include/i18n.h

@@ -111,11 +111,11 @@ typedef struct res_RESOURCE_GLOBAL
  
 #ifdef  RESOURCE_STR
 #define BEGIN_STR(argLibraryName) \
-                          RESOURCE_TABLE argLibraryName[] = { 0, #argLibraryName,
+                          RESOURCE_TABLE argLibraryName[] = { {0, #argLibraryName},
 #define ResDef(argToken,argID,argString) \
-                          argID, argString,
+                          {argID, argString},
 #define END_STR(argLibraryName) \
-                          0, 0 };
+                          {0, 0} };
 #else
 #define BEGIN_STR(argLibraryName) \
                           enum {

+ 4 - 1
include/ldaputil/certmap.h

@@ -61,6 +61,8 @@ enum {
     LDAPU_STR_MAX_INDEX
 };
 
+#ifdef DEFINE_LDAPU_STRINGS
+/* used only in certmap.c and ldaputil.c */
 static char *ldapu_strings[] = {
     "objectclass=*",		/* LDAPU_STR_DEFAULT */
     "uid=%s",			/* LDAPU_STR_FILTER_USER */
@@ -71,7 +73,8 @@ static char *ldapu_strings[] = {
     "userCertificate;binary",	/* LDAPU_STR_ATTR_CERT */
     "userCertificate"	/* LDAPU_STR_ATTR_CERT_NOSUBTYPE */
 };
-    
+#endif /* DEFINE_LDAPU_STRINGS */
+
 typedef struct {
     char *str;
     int size;

+ 4 - 4
ldap/servers/plugins/acl/aclparse.c

@@ -936,8 +936,8 @@ __aclp__getNextLASRule (aci_t *aci_item, char *original_str , char **endOfCurrRu
 			 * eg. "'ldap:///all"' or 'ldap:///all")' then exit in_dn_expr mode.
 			*/
 			if ( in_dn_expr && (word[len-1] == '"' ||
-								len>1 && word[len-2] == '"' ||
-								len>2 && word[len-3] == '"')) {
+								(len>1 && word[len-2] == '"') ||
+                                (len>2 && word[len-3] == '"')) ) {
 				in_dn_expr = 0;
 			}
 
@@ -1692,7 +1692,7 @@ static int __acl__init_targetattrfilters( aci_t *aci, char *input_str) {
 		if ((str = strstr(s , "del=")) || ((str = strstr(s , "del ="))) ) {
         	str--;
 			*str = '\0';
-        	*str++;
+        	str++;
 		}
 
 
@@ -1704,7 +1704,7 @@ static int __acl__init_targetattrfilters( aci_t *aci, char *input_str) {
 		if ((str = strstr(s , "add=")) || ((str = strstr(s , "add ="))) ) {
         	str--;
 			*str = '\0';
-        	*str++;
+        	str++;
 		}
     } else {
         return(ACL_SYNTAX_ERR);

+ 5 - 4
ldap/servers/plugins/acl/aclutil.c

@@ -1328,13 +1328,14 @@ void acl_ht_add_and_freeOld(acl_ht_t * acl_ht,
 							PLHashNumber key,
 							char *value){
 	char *old_value = NULL;	
+	uintptr_t pkey = (uintptr_t)key;
 
 	if ( (old_value = (char *)acl_ht_lookup( acl_ht, key)) != NULL ) {
 		acl_ht_remove( acl_ht, key);
 		slapi_ch_free((void **)&old_value);
 	}
 
-	PL_HashTableAdd( acl_ht, (const void *)key, value);
+	PL_HashTableAdd( acl_ht, (const void *)pkey, value);
 }
 
 /*
@@ -1349,7 +1350,7 @@ acl_ht_t *acl_ht_new(void) {
 
 static PLHashNumber acl_ht_hash( const void *key) {
 
-	return( (PLHashNumber)key );
+	return( (PLHashNumber)((uintptr_t)key) );
 }
 
 /* Free all the values in the ht */
@@ -1397,14 +1398,14 @@ acl_ht_display_entry(PLHashEntry *he, PRIntn i, void *arg)
 /* remove this entry from the ht--doesn't free the value.*/
 void acl_ht_remove( acl_ht_t *acl_ht, PLHashNumber key) {
 
-	PL_HashTableRemove( acl_ht, (const void *)key);
+	PL_HashTableRemove( acl_ht, (const void *)((uintptr_t)key) );
 }
 
 /* Retrieve a pointer to the value of the entry with key */
 void *acl_ht_lookup( acl_ht_t *acl_ht,
 								PLHashNumber key) {
 
-	return( PL_HashTableLookup( acl_ht, (const void *)key) );	
+	return( PL_HashTableLookup( acl_ht, (const void *)((uintptr_t)key)) );	
 }
 
 

+ 45 - 45
ldap/servers/plugins/chainingdb/cb_instance.c

@@ -903,7 +903,7 @@ static int cb_instance_userpassword_set(void *arg, void *value, char *errorbuf,
 static void *cb_instance_sizelimit_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-	int data;
+	uintptr_t data;
 
         PR_RWLock_Rlock(inst->rwl_config_lock);
 	data = inst->sizelimit;
@@ -916,10 +916,10 @@ static int cb_instance_sizelimit_set(void *arg, void *value, char *errorbuf, int
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
 	if (apply) {
         	PR_RWLock_Wlock(inst->rwl_config_lock);
-		inst->sizelimit=(int) value;
+            inst->sizelimit=(int) ((uintptr_t)value);
         	PR_RWLock_Unlock(inst->rwl_config_lock);
 		if (inst->inst_be) 
-			be_set_sizelimit(inst->inst_be, (int) value);
+			be_set_sizelimit(inst->inst_be, (int) ((uintptr_t)value));
 	}
 	return LDAP_SUCCESS;
 }
@@ -927,7 +927,7 @@ static int cb_instance_sizelimit_set(void *arg, void *value, char *errorbuf, int
 static void *cb_instance_timelimit_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-	int data;
+	uintptr_t data;
 
         PR_RWLock_Rlock(inst->rwl_config_lock);
 	data = inst->timelimit;
@@ -940,10 +940,10 @@ static int cb_instance_timelimit_set(void *arg, void *value, char *errorbuf, int
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
 	if (apply) {
         	PR_RWLock_Wlock(inst->rwl_config_lock);
-		inst->timelimit=(int) value;
+		inst->timelimit=(int) ((uintptr_t)value);
         	PR_RWLock_Unlock(inst->rwl_config_lock);
 		if (inst->inst_be) 
-			be_set_timelimit(inst->inst_be, (int) value);
+			be_set_timelimit(inst->inst_be, (int) ((uintptr_t)value));
 	}
 	return LDAP_SUCCESS;
 }
@@ -951,7 +951,7 @@ static int cb_instance_timelimit_set(void *arg, void *value, char *errorbuf, int
 static void *cb_instance_max_test_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-	int data;
+	uintptr_t data;
 
         PR_RWLock_Rlock(inst->rwl_config_lock);
 	data = inst->max_test_time;
@@ -964,7 +964,7 @@ static int cb_instance_max_test_set(void *arg, void *value, char *errorbuf, int
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
 	if (apply) {
         	PR_RWLock_Wlock(inst->rwl_config_lock);
-		inst->max_test_time=(int) value;
+		inst->max_test_time=(int) ((uintptr_t)value);
         	PR_RWLock_Unlock(inst->rwl_config_lock);
 	}
 	return LDAP_SUCCESS;
@@ -973,7 +973,7 @@ static int cb_instance_max_test_set(void *arg, void *value, char *errorbuf, int
 static void *cb_instance_max_idle_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-	int data;
+	uintptr_t data;
 
         PR_RWLock_Rlock(inst->rwl_config_lock);
 	data = inst->max_idle_time;
@@ -986,7 +986,7 @@ static int cb_instance_max_idle_set(void *arg, void *value, char *errorbuf, int
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
 	if (apply) {
         	PR_RWLock_Wlock(inst->rwl_config_lock);
-		inst->max_idle_time=(int) value;
+		inst->max_idle_time=(int) ((uintptr_t)value);
         	PR_RWLock_Unlock(inst->rwl_config_lock);
 	}
 	return LDAP_SUCCESS;
@@ -996,7 +996,7 @@ static int cb_instance_max_idle_set(void *arg, void *value, char *errorbuf, int
 static void *cb_instance_hoplimit_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-	int data;
+	uintptr_t data;
 
         PR_RWLock_Rlock(inst->rwl_config_lock);
 	data = inst->hoplimit;
@@ -1009,7 +1009,7 @@ static int cb_instance_hoplimit_set(void *arg, void *value, char *errorbuf, int
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
 	if (apply) {
         	PR_RWLock_Wlock(inst->rwl_config_lock);
-		inst->hoplimit=(int) value;
+		inst->hoplimit=(int) ((uintptr_t)value);
         	PR_RWLock_Unlock(inst->rwl_config_lock);
 	}
 	return LDAP_SUCCESS;
@@ -1018,7 +1018,7 @@ static int cb_instance_hoplimit_set(void *arg, void *value, char *errorbuf, int
 static void *cb_instance_maxbconn_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-	int data;
+	uintptr_t data;
 
         PR_RWLock_Rlock(inst->rwl_config_lock);
 	data = inst->bind_pool->conn.maxconnections;
@@ -1031,7 +1031,7 @@ static int cb_instance_maxbconn_set(void *arg, void *value, char *errorbuf, int
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
 	if (apply) {
         	PR_RWLock_Wlock(inst->rwl_config_lock);
-		inst->bind_pool->conn.maxconnections=(int) value;
+		inst->bind_pool->conn.maxconnections=(int) ((uintptr_t)value);
         	PR_RWLock_Unlock(inst->rwl_config_lock);
 	}
 	return LDAP_SUCCESS;
@@ -1040,7 +1040,7 @@ static int cb_instance_maxbconn_set(void *arg, void *value, char *errorbuf, int
 static void *cb_instance_maxconn_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-	int data;
+	uintptr_t data;
 
         PR_RWLock_Rlock(inst->rwl_config_lock);
 	data = inst->pool->conn.maxconnections;
@@ -1053,7 +1053,7 @@ static int cb_instance_maxconn_set(void *arg, void *value, char *errorbuf, int p
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
 	if (apply) {
         	PR_RWLock_Wlock(inst->rwl_config_lock);
-		inst->pool->conn.maxconnections=(int) value;
+		inst->pool->conn.maxconnections=(int) ((uintptr_t)value);
         	PR_RWLock_Unlock(inst->rwl_config_lock);
 	}
 	return LDAP_SUCCESS;
@@ -1062,7 +1062,7 @@ static int cb_instance_maxconn_set(void *arg, void *value, char *errorbuf, int p
 static void *cb_instance_abandonto_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-	int data;
+	uintptr_t data;
 
         PR_RWLock_Rlock(inst->rwl_config_lock);
 	data = inst->abandon_timeout.tv_sec;
@@ -1084,7 +1084,7 @@ static int cb_instance_abandonto_set(void *arg, void *value, char *errorbuf, int
 		}
 
                	PR_RWLock_Wlock(inst->rwl_config_lock);
-		inst->abandon_timeout.tv_sec=(int) value;
+		inst->abandon_timeout.tv_sec=(int) ((uintptr_t)value);
 		inst->abandon_timeout.tv_usec=0;
                	PR_RWLock_Unlock(inst->rwl_config_lock);
 	}
@@ -1094,7 +1094,7 @@ static int cb_instance_abandonto_set(void *arg, void *value, char *errorbuf, int
 static void *cb_instance_maxbconc_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-	int data;
+	uintptr_t data;
 
         PR_RWLock_Rlock(inst->rwl_config_lock);
 	data = inst->bind_pool->conn.maxconcurrency;
@@ -1107,7 +1107,7 @@ static int cb_instance_maxbconc_set(void *arg, void *value, char *errorbuf, int
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
 	if (apply) {
         	PR_RWLock_Wlock(inst->rwl_config_lock);
-		inst->bind_pool->conn.maxconcurrency=(int) value;
+		inst->bind_pool->conn.maxconcurrency=(int) ((uintptr_t)value);
         	PR_RWLock_Unlock(inst->rwl_config_lock);
 	}
 	return LDAP_SUCCESS;
@@ -1116,7 +1116,7 @@ static int cb_instance_maxbconc_set(void *arg, void *value, char *errorbuf, int
 static void *cb_instance_maxconc_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-	int data;
+	uintptr_t data;
 
         PR_RWLock_Rlock(inst->rwl_config_lock);
 	data = inst->pool->conn.maxconcurrency;
@@ -1129,7 +1129,7 @@ static int cb_instance_maxconc_set(void *arg, void *value, char *errorbuf, int p
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
 	if (apply) {
                 PR_RWLock_Wlock(inst->rwl_config_lock);
-		inst->pool->conn.maxconcurrency=(int) value;
+		inst->pool->conn.maxconcurrency=(int) ((uintptr_t)value);
                 PR_RWLock_Unlock(inst->rwl_config_lock);
 	}
         return LDAP_SUCCESS;   
@@ -1138,7 +1138,7 @@ static int cb_instance_maxconc_set(void *arg, void *value, char *errorbuf, int p
 static void *cb_instance_imperson_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-        int data;
+        uintptr_t data;
 
         PR_RWLock_Rlock(inst->rwl_config_lock);
         data = inst->impersonate;
@@ -1153,7 +1153,7 @@ static int cb_instance_imperson_set(void *arg, void *value, char *errorbuf, int
 
 	if (apply) {
                 PR_RWLock_Wlock(inst->rwl_config_lock); 
-		inst->impersonate=(int) value;
+		inst->impersonate=(int) ((uintptr_t)value);
                 PR_RWLock_Unlock(inst->rwl_config_lock); 
 	} else {
 		/* Security check: Make sure the proxing user is */
@@ -1162,7 +1162,7 @@ static int cb_instance_imperson_set(void *arg, void *value, char *errorbuf, int
 		char * rootdn=cb_get_rootdn();
 
                 PR_RWLock_Rlock(inst->rwl_config_lock); 
-		if (((int) value) && inst->pool && inst->pool->binddn &&
+		if (((int) ((uintptr_t)value)) && inst->pool && inst->pool->binddn &&
 	                !strcmp(inst->pool->binddn,rootdn)) {	/* UTF-8 aware */
 		  	rc=LDAP_UNWILLING_TO_PERFORM;
 			if (errorbuf)
@@ -1179,7 +1179,7 @@ static int cb_instance_imperson_set(void *arg, void *value, char *errorbuf, int
 static void *cb_instance_connlife_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-        int data; 
+        uintptr_t data; 
  
         PR_RWLock_Rlock(inst->rwl_config_lock); 
         data=inst->pool->conn.connlifetime;
@@ -1192,7 +1192,7 @@ static int cb_instance_connlife_set(void *arg, void *value, char *errorbuf, int
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
 	if (apply) {
                 PR_RWLock_Wlock(inst->rwl_config_lock);  
-		inst->pool->conn.connlifetime=(int) value;
+		inst->pool->conn.connlifetime=(int) ((uintptr_t)value);
                 PR_RWLock_Unlock(inst->rwl_config_lock);  
 	}
         return LDAP_SUCCESS;     
@@ -1201,7 +1201,7 @@ static int cb_instance_connlife_set(void *arg, void *value, char *errorbuf, int
 static void *cb_instance_bindto_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-        int data;  
+        uintptr_t data;  
  
         PR_RWLock_Rlock(inst->rwl_config_lock);  
         data=inst->bind_pool->conn.op_timeout.tv_sec;
@@ -1214,12 +1214,12 @@ static int cb_instance_bindto_set(void *arg, void *value, char *errorbuf, int ph
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
 	if (apply) {
                 PR_RWLock_Wlock(inst->rwl_config_lock);   
-		inst->bind_pool->conn.op_timeout.tv_sec=(int) value;
+		inst->bind_pool->conn.op_timeout.tv_sec=(int) ((uintptr_t)value);
 		inst->bind_pool->conn.op_timeout.tv_usec=0;
-		inst->bind_pool->conn.bind_timeout.tv_sec=(int) value;
+		inst->bind_pool->conn.bind_timeout.tv_sec=(int) ((uintptr_t)value);
 		inst->bind_pool->conn.bind_timeout.tv_usec=0;
 		/* Used to bind to the farm server */
-		inst->pool->conn.bind_timeout.tv_sec=(int) value;
+		inst->pool->conn.bind_timeout.tv_sec=(int) ((uintptr_t)value);
 		inst->pool->conn.bind_timeout.tv_usec=0;
                 PR_RWLock_Unlock(inst->rwl_config_lock);   
 	}
@@ -1229,7 +1229,7 @@ static int cb_instance_bindto_set(void *arg, void *value, char *errorbuf, int ph
 static void *cb_instance_opto_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-        int data;  
+        uintptr_t data;  
  
         PR_RWLock_Rlock(inst->rwl_config_lock);  
         data=inst->pool->conn.op_timeout.tv_sec;
@@ -1242,7 +1242,7 @@ static int cb_instance_opto_set(void *arg, void *value, char *errorbuf, int phas
         cb_backend_instance * inst=(cb_backend_instance *) arg;
         if (apply) {
                 PR_RWLock_Wlock(inst->rwl_config_lock);
-                inst->pool->conn.op_timeout.tv_sec=(int) value;
+                inst->pool->conn.op_timeout.tv_sec=(int) ((uintptr_t)value);
                 inst->pool->conn.op_timeout.tv_usec=0;
                 PR_RWLock_Unlock(inst->rwl_config_lock);
         }
@@ -1252,7 +1252,7 @@ static int cb_instance_opto_set(void *arg, void *value, char *errorbuf, int phas
 static void *cb_instance_ref_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-        int data;   
+        uintptr_t data;   
   
         PR_RWLock_Rlock(inst->rwl_config_lock);   
         data=inst->searchreferral;
@@ -1265,7 +1265,7 @@ static int cb_instance_ref_set(void *arg, void *value, char *errorbuf, int phase
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
 	if (apply) {
                 PR_RWLock_Wlock(inst->rwl_config_lock);    
-		inst->searchreferral=(int) value;
+		inst->searchreferral=(int) ((uintptr_t)value);
                 PR_RWLock_Unlock(inst->rwl_config_lock);    
 	}
 	return LDAP_SUCCESS;
@@ -1274,7 +1274,7 @@ static int cb_instance_ref_set(void *arg, void *value, char *errorbuf, int phase
 static void *cb_instance_acl_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-        int data;
+        uintptr_t data;
 
         PR_RWLock_Rlock(inst->rwl_config_lock);
         data=inst->local_acl;
@@ -1295,7 +1295,7 @@ static int cb_instance_acl_set(void *arg, void *value, char *errorbuf, int phase
                         return LDAP_SUCCESS;
                 }
 	        PR_RWLock_Wlock(inst->rwl_config_lock);
-		inst->local_acl=(int) value;
+		inst->local_acl=(int) ((uintptr_t)value);
 	        PR_RWLock_Unlock(inst->rwl_config_lock);
 	}
 	return LDAP_SUCCESS;
@@ -1304,7 +1304,7 @@ static int cb_instance_acl_set(void *arg, void *value, char *errorbuf, int phase
 static void *cb_instance_bindretry_get(void *arg)
 {
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
-	int data;
+	uintptr_t data;
 
         PR_RWLock_Rlock(inst->rwl_config_lock); 
         data=inst->bind_retry;
@@ -1317,7 +1317,7 @@ static int cb_instance_bindretry_set(void *arg, void *value, char *errorbuf, int
 	cb_backend_instance * inst=(cb_backend_instance *) arg;
 	if (apply) {
                 PR_RWLock_Wlock(inst->rwl_config_lock);
-		inst->bind_retry=(int) value;
+		inst->bind_retry=(int) ((uintptr_t)value);
                 PR_RWLock_Unlock(inst->rwl_config_lock);
 	}
 	return LDAP_SUCCESS;
@@ -1383,7 +1383,7 @@ struct berval *bval, char *err_buf, int phase, int apply_mod)
                 } else {
                         int_val = cb_atoi((char *)bval->bv_val);
                 }
-                retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod);
+                retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod);
                 break;
         case CB_CONFIG_TYPE_INT_OCTAL:
                 if (use_default) {
@@ -1391,7 +1391,7 @@ struct berval *bval, char *err_buf, int phase, int apply_mod)
                 } else {
                         int_val = (int) strtol((char *)bval->bv_val, NULL, 8);
                 }
-                retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod);
+                retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod);
                 break;
         case CB_CONFIG_TYPE_LONG:
                 if (use_default) {
@@ -1414,7 +1414,7 @@ struct berval *bval, char *err_buf, int phase, int apply_mod)
                 } else {
                         int_val = !strcasecmp((char *) bval->bv_val, "on");
                 }
-                retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod);
+                retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod);
                 break;
         }        
         return retval;
@@ -1435,10 +1435,10 @@ void cb_instance_config_get(void *arg, cb_instance_config_info *config, char *bu
  
         switch(config->config_type) {
         case CB_CONFIG_TYPE_INT:
-                sprintf(buf, "%d", (int) config->config_get_fn(arg));
+                sprintf(buf, "%d", (int) ((uintptr_t)config->config_get_fn(arg)));
                 break;
         case CB_CONFIG_TYPE_INT_OCTAL:
-                sprintf(buf, "%o", (int) config->config_get_fn(arg));
+                sprintf(buf, "%o", (int) ((uintptr_t)config->config_get_fn(arg)));
                 break;
         case CB_CONFIG_TYPE_LONG:
                 sprintf(buf, "%ld", (long) config->config_get_fn(arg));
@@ -1451,7 +1451,7 @@ void cb_instance_config_get(void *arg, cb_instance_config_info *config, char *bu
                 slapi_ch_free((void **)&tmp_string);
                 break;
         case CB_CONFIG_TYPE_ONOFF:
-                if ((int) config->config_get_fn(arg)) {
+                if ((int) ((uintptr_t)config->config_get_fn(arg))) {
                         sprintf(buf,"%s","on");
                 } else {
                         sprintf(buf,"%s","off");

+ 31 - 26
ldap/servers/plugins/dna/dna.c

@@ -55,6 +55,13 @@
 #include "prclist.h"
 #include "ldif.h"
 
+/* Required to get portable printf/scanf format macros */
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#error Need to define portable format macros such as PRIu64
+#endif /* HAVE_INTTYPES_H */
+
 /* get file mode flags for unix */
 #ifndef _WIN32
 #include <sys/stat.h>
@@ -708,7 +715,7 @@ dna_parse_config_entry(Slapi_Entry * e, int apply)
     }
 
     slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
-                    "----------> %s [%llu]\n", DNA_NEXTVAL, entry->nextval, 0,
+                    "----------> %s [%" PRIu64 "]\n", DNA_NEXTVAL, entry->nextval, 0,
                     0);
 
     value = slapi_entry_attr_get_charptr(e, DNA_PREFIX);
@@ -736,7 +743,7 @@ dna_parse_config_entry(Slapi_Entry * e, int apply)
     }
 
     slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
-                    "----------> %s [%llu]\n", DNA_INTERVAL, entry->interval, 0, 0);
+                    "----------> %s [%" PRIu64 "]\n", DNA_INTERVAL, entry->interval, 0, 0);
 #endif
 
     value = slapi_entry_attr_get_charptr(e, DNA_GENERATE);
@@ -844,7 +851,7 @@ dna_parse_config_entry(Slapi_Entry * e, int apply)
         entry->threshold = strtoull(value, 0, 0);
 
         slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM,
-                        "----------> %s [%llu]\n", DNA_THRESHOLD, value, 0, 0);
+                        "----------> %s [%" PRIu64 "]\n", DNA_THRESHOLD, value, 0, 0);
 
         slapi_ch_free_string(&value);
     } else {
@@ -1319,8 +1326,8 @@ dna_notice_allocation(struct configEntry *config_entry, PRUint64 new,
      * don't need to do this if we already have a next range on deck. */
     if ((config_entry->next_range_lower == 0) && (config_entry->remaining <= config_entry->threshold)) {
         slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
-                        "dna_notice_allocation: Passed threshold of %llu remaining values "
-                        "for range %s. (%llu values remain)\n",
+                        "dna_notice_allocation: Passed threshold of %" PRIu64 " remaining values "
+                        "for range %s. (%" PRIu64 " values remain)\n",
                         config_entry->threshold, config_entry->dn, config_entry->remaining);
         /* Only attempt to fix maxval if the fix flag is set. */
         if (fix != 0) {
@@ -1461,13 +1468,11 @@ static int dna_request_range(struct configEntry *config_entry,
                              struct dnaServer *server,
                              PRUint64 *lower, PRUint64 *upper)
 {
-    Slapi_DN *agmt_sdn = NULL;
     char *bind_dn = NULL;
     char *bind_passwd = NULL;
     char *bind_method = NULL;
     int is_ssl = 0;
     int is_client_auth = 0;
-    int replport = 0;
     struct berval *request = NULL;
     char *retoid = NULL;
     struct berval *responsedata = NULL;
@@ -1767,12 +1772,12 @@ dna_first_free_value(struct configEntry *config_entry,
     if (prefix) {
         /* The 7 below is for all of the filter characters "(&(=))"
          * plus the trailing \0.  The 20 is for the maximum string
-         * representation of a %llu. */
+         * representation of a " PRIu64 ". */
         filterlen = strlen(config_entry->filter) +
                                  strlen(prefix) + strlen(type)
                                  + 7 + 20;
         filter = slapi_ch_malloc(filterlen);
-        snprintf(filter, filterlen, "(&%s(%s=%s%llu))",
+        snprintf(filter, filterlen, "(&%s(%s=%s%" PRIu64 "))",
                           config_entry->filter, type, prefix, tmpval);
     } else {
         ctrls = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl));
@@ -1785,7 +1790,7 @@ dna_first_free_value(struct configEntry *config_entry,
             return LDAP_OPERATIONS_ERROR;
         }
 
-        filter = slapi_ch_smprintf("(&%s(&(%s>=%llu)(%s<=%llu)))",
+        filter = slapi_ch_smprintf("(&%s(&(%s>=%" PRIu64 ")(%s<=%" PRIu64 ")))",
                                    config_entry->filter,
                                    type, tmpval,
                                    type, config_entry->maxval);
@@ -1836,7 +1841,7 @@ dna_first_free_value(struct configEntry *config_entry,
             /* filter is guaranteed to be big enough since we allocated
              * enough space to fit a string representation of any unsigned
              * 64-bit integer */
-            snprintf(filter, filterlen, "(&%s(%s=%s%llu))",
+            snprintf(filter, filterlen, "(&%s(%s=%s%" PRIu64 "))",
                               config_entry->filter, type, prefix, tmpval);
 
             /* clear out the pblock so we can re-use it */
@@ -1968,7 +1973,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
      * of our current range */
     if (nextval <= (config_entry->maxval + config_entry->interval)) {
         /* try to set the new next value in the config entry */
-        snprintf(next_value, sizeof(next_value),"%llu", nextval);
+        snprintf(next_value, sizeof(next_value),"%" PRIu64, nextval);
 
         /* set up our replace modify operation */
         replace_val[0] = next_value;
@@ -1998,7 +2003,7 @@ static int dna_get_next_value(struct configEntry *config_entry,
 
     if (LDAP_SUCCESS == ret) {
         slapi_ch_free_string(next_value_ret);
-        *next_value_ret = slapi_ch_smprintf("%llu", setval);
+        *next_value_ret = slapi_ch_smprintf("%" PRIu64, setval);
         if (NULL == *next_value_ret) {
             ret = LDAP_OPERATIONS_ERROR;
             goto done;
@@ -2045,7 +2050,7 @@ dna_update_shared_config(struct configEntry * config_entry)
 
         /* We store the number of remaining assigned values
          * in the shared config entry. */
-        snprintf(remaining_vals, sizeof(remaining_vals),"%llu", config_entry->remaining);
+        snprintf(remaining_vals, sizeof(remaining_vals),"%" PRIu64, config_entry->remaining);
 
         /* set up our replace modify operation */
         replace_val[0] = remaining_vals;
@@ -2130,7 +2135,7 @@ dna_update_next_range(struct configEntry *config_entry,
     int ret = 0;
 
     /* Try to set the new next range in the config entry. */
-    snprintf(nextrange_value, sizeof(nextrange_value), "%llu-%llu",
+    snprintf(nextrange_value, sizeof(nextrange_value), "%" PRIu64 "-%" PRIu64,
              lower, upper);
 
     /* set up our replace modify operation */
@@ -2199,8 +2204,8 @@ dna_activate_next_range(struct configEntry *config_entry)
     int ret = 0;
 
     /* Setup the modify operation for the config entry */
-    snprintf(maxval_val, sizeof(maxval_val),"%llu", config_entry->next_range_upper);
-    snprintf(nextval_val, sizeof(nextval_val),"%llu", config_entry->next_range_lower);
+    snprintf(maxval_val, sizeof(maxval_val),"%" PRIu64, config_entry->next_range_upper);
+    snprintf(nextval_val, sizeof(nextval_val),"%" PRIu64, config_entry->next_range_lower);
 
     maxval_vals[0] = maxval_val;
     maxval_vals[1] = 0;
@@ -2817,8 +2822,8 @@ static int dna_extend_exop(Slapi_PBlock *pb)
         char highstr[16];
 
         /* Create the exop response */
-        snprintf(lowstr, sizeof(lowstr), "%llu", lower);
-        snprintf(highstr, sizeof(highstr), "%llu", upper);
+        snprintf(lowstr, sizeof(lowstr), "%" PRIu64, lower);
+        snprintf(highstr, sizeof(highstr), "%" PRIu64, upper);
         range_low.bv_val = lowstr;
         range_low.bv_len = strlen(range_low.bv_val);
         range_high.bv_val = highstr;
@@ -2846,12 +2851,12 @@ static int dna_extend_exop(Slapi_PBlock *pb)
         slapi_pblock_set(pb, SLAPI_EXT_OP_RET_VALUE, respdata);
 
         /* send the response ourselves */
-        send_ldap_result( pb, ret, NULL, NULL, 0, NULL );
+        slapi_send_ldap_result( pb, ret, NULL, NULL, 0, NULL );
         ret = SLAPI_PLUGIN_EXTENDED_SENT_RESULT;
         ber_bvfree(respdata);
 
         slapi_log_error(SLAPI_LOG_PLUGIN, DNA_PLUGIN_SUBSYSTEM,
-                        "dna_extend_exop: Released range %llu-%llu.\n",
+                        "dna_extend_exop: Released range %" PRIu64 "-%" PRIu64 ".\n",
                         lower, upper);
     }
 
@@ -2993,7 +2998,7 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper)
                 *lower = *upper - release + 1;
 
                 /* try to set the new maxval in the config entry */
-                snprintf(max_value, sizeof(max_value),"%llu", (*lower - 1));
+                snprintf(max_value, sizeof(max_value),"%" PRIu64, (*lower - 1));
 
                 /* set up our replace modify operation */
                 replace_val[0] = max_value;
@@ -3092,11 +3097,11 @@ void dna_dump_config_entry(struct configEntry * entry)
     printf("<---- filter ---------> %s\n", entry->filter);
     printf("<---- prefix ---------> %s\n", entry->prefix);
     printf("<---- scope ----------> %s\n", entry->scope);
-    printf("<---- next value -----> %llu\n", entry->nextval);
-    printf("<---- max value ------> %llu\n", entry->maxval);
-    printf("<---- interval -------> %llu\n", entry->interval);
+    printf("<---- next value -----> %" PRIu64 "\n", entry->nextval);
+    printf("<---- max value ------> %" PRIu64 "\n", entry->maxval);
+    printf("<---- interval -------> %" PRIu64 "\n", entry->interval);
     printf("<---- generate flag --> %s\n", entry->generate);
     printf("<---- shared cfg base > %s\n", entry->shared_cfg_base);
     printf("<---- shared cfg DN --> %s\n", entry->shared_cfg_dn);
-    printf("<---- threshold -----> %llu", entry->threshold);
+    printf("<---- threshold ------> %" PRIu64 "", entry->threshold);
 }

+ 1 - 1
ldap/servers/plugins/pam_passthru/pam_ptimpl.c

@@ -177,7 +177,7 @@ free_pam_response(int nresp, struct pam_response *resp)
  * tell if this is actually the case.
  */
 static int
-pam_conv_func(int num_msg, struct pam_message **msg, struct pam_response **resp, void *mydata)
+pam_conv_func(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *mydata)
 {
 	int ii;
 	struct berval *creds;

+ 2 - 2
ldap/servers/plugins/passthru/ptconfig.c

@@ -102,7 +102,7 @@ int
 passthru_config( int argc, char **argv )
 {
     int			i, j, rc, tosecs, using_def_connlifetime;
-    char		*p, **suffixarray;
+    char		**suffixarray;
     PassThruServer	*prevsrvr, *srvr;
     PassThruSuffix	*suffix, *prevsuffix;
     LDAPURLDesc		*ludp;
@@ -144,7 +144,7 @@ passthru_config( int argc, char **argv )
 	   and that the url does not look like this: ldap://host
 	   also assumes suffixes do not have any / in them
 	*/
-	if (p = strrchr(srvr->ptsrvr_url, '/')) { /* look for last / */
+	if ((p = strrchr(srvr->ptsrvr_url, '/'))) { /* look for last / */
 	    p = strchr(p, ' '); /* look for first space after last / */
 	    if (p) {
 		if (!strchr(p, ',')) { /* no comma */

+ 1 - 10
ldap/servers/plugins/presence/presence.c

@@ -66,13 +66,7 @@
 
 /*** from proto-slap.h ***/
 
-int slapd_log_error_proc( char *subsystem, char *fmt, ... )
-#ifdef __GNUC__ 
-        __attribute__ ((format (printf, 2, 3)));
-#else
-        ;
-#endif
-
+int slapd_log_error_proc( char *subsystem, char *fmt, ... );
 
 /*** from ldaplog.h ***/
 
@@ -346,7 +340,6 @@ int presence_init( Slapi_PBlock *pb )
 int presence_start( Slapi_PBlock *pb )
 {
 	char * plugindn = NULL;
-	char * httpRootDir = NULL;
 
 	LDAPDebug( LDAP_DEBUG_PLUGIN, "--> presence_start -- begin\n",0,0,0);
 
@@ -1105,7 +1098,6 @@ static int setTypes(PLHashEntry *he, PRIntn i, void *arg)
 {
 	int status;
 	int props = SLAPI_ATTR_FLAG_OPATTR;
-	Slapi_Attr *attr = NULL;
 	Slapi_ValueSet *results = NULL;
 	int type_name_disposition = 0;
 	char *actual_type_name = 0;
@@ -1150,7 +1142,6 @@ logGraphicAttributeValue( Slapi_Attr *attr, const char *attrname )
 		v = slapi_value_get_berval(val);
 		if (v) {
 			char	*ldifvalue;
-			size_t	attrnamelen = strlen( attrname );
 
 			LDAPDebug( LDAP_DEBUG_PLUGIN, "----------> %s size [%d] \n",
 					attrname,v->bv_len,0);

+ 2 - 0
ldap/servers/plugins/pwdstorage/crypt_pwd.c

@@ -53,7 +53,9 @@ char *crypt(char *key, char *salt);
 #else
 #include <sys/socket.h>
 #if defined( hpux ) || defined ( AIX ) || defined (LINUX) || defined (OSF1)
+#ifndef __USE_XOPEN
 #define __USE_XOPEN     /* linux */
+#endif /* __USE_XOPEN */
 #include <unistd.h>
 #else /* hpux */
 #include <crypt.h>

+ 0 - 2
ldap/servers/plugins/replication/cl5_api.c

@@ -3376,8 +3376,6 @@ out:
  */
 static int _cl5Upgrade4_4(char *fromVersion, char *toVersion)
 {
-	PRDirEntry *entry = NULL;
-	DB *thisdb = NULL;
 	CL5OpenMode	backup;
 	int rc = 0;
 

+ 1 - 1
ldap/servers/plugins/replication/repl5_agmt.c

@@ -1183,7 +1183,7 @@ agmt_validate_replicated_attributes(Repl_Agmt *ra)
 	{
 		char *this_attr = NULL;
 		int i = 0;
-		for (i = 0; this_attr = frac_attrs[i]; i++)
+		for (i = 0; (this_attr = frac_attrs[i]); i++)
 		{
 			if (charray_inlist(verbotten_attrs,this_attr)) {
 				int k = 0;

+ 1 - 1
ldap/servers/plugins/replication/repl5_connection.c

@@ -1728,7 +1728,7 @@ repl5_stop_debug_timeout(Slapi_Eq_Context eqctx, int *setlevel)
 	char msg[SLAPI_DSE_RETURNTEXT_SIZE];
 
 	if (eqctx && !*setlevel) {
-		int found = slapi_eq_cancel(eqctx);
+		(void)slapi_eq_cancel(eqctx);
 	}
 
 	if (s_debug_timeout && s_debug_level && *setlevel) {

+ 2 - 1
ldap/servers/plugins/replication/repl5_protocol_util.c

@@ -417,7 +417,8 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv)
 			}
 		}
 	}
-error:
+
+/* error: */
 	if (NULL != ruv_bervals)
 		ber_bvecfree(ruv_bervals);
 	if (NULL != replarea_sdn)

+ 1 - 1
ldap/servers/plugins/replication/repl5_replica.c

@@ -1076,7 +1076,7 @@ replica_update_csngen_state_ext (Replica *r, const RUV *ruv, const CSN *extracsn
     rc = csngen_adjust_time (gen, csn);
     /* rc will be either CSN_SUCCESS (0) or clock skew */
 
-done:
+/* done: */
 
     PR_Unlock(r->repl_lock);
     if (csn != extracsn) /* do not free the given csn */

+ 1 - 1
ldap/servers/plugins/replication/repl5_updatedn_list.c

@@ -193,7 +193,7 @@ replica_updatedn_list_ismember(ReplicaUpdateDNList list, const Slapi_DN *dn)
 
 	/* Bug 605169 - null ndn would cause core dump */
 	if ( ndn ) {
-		ret = (PRBool)PL_HashTableLookupConst(hash, ndn);
+		ret = (PRBool)((uintptr_t)PL_HashTableLookupConst(hash, ndn));
 	}
 
 	return ret;

+ 1 - 7
ldap/servers/plugins/roles/roles_plugin.c

@@ -50,15 +50,9 @@
 #include "vattr_spi.h"
 
 #include "roles_cache.h"
+#define DEFINE_STATECHANGE_STATICS 1
 #include "statechange.h"
 
-
-#ifdef SOURCEFILE 
-#undef SOURCEFILE
-#endif
-#define SOURCEFILE "roles_plugin.c"
-static char *sourcefile = SOURCEFILE;
-
 #define STATECHANGE_ROLES_ID "Roles"
 #define STATECHANGE_ROLES_CONFG_FILTER "objectclass=nsRoleDefinition"
 #define STATECHANGE_ROLES_ENTRY_FILTER "objectclass=*"

+ 1 - 1
ldap/servers/slapd/agtmmap.c

@@ -195,7 +195,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
 		   {
 			   /* Without this we will get segv when we try to read/write later */
 			   buf = calloc (1, sz);
-			   write (fd, buf, sz);
+			   (void)write (fd, buf, sz);
 			   free (buf);
 		   }
 

+ 4 - 4
ldap/servers/slapd/auth.c

@@ -449,7 +449,7 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData)
     if ( conn->c_flags & CONN_FLAG_START_TLS ) {
         if ( cipherInfo.symKeyBits == 0 ) {
 	        start_tls_graceful_closure( conn, NULL, 1 );
-			slapi_ch_free((void **)&cipher);
+			slapi_ch_free_string(&cipher);
 	        return ;
 	}
     }
@@ -457,7 +457,7 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData)
     if (config_get_SSLclientAuth() == SLAPD_SSLCLIENTAUTH_OFF ) {
 		slapi_log_access (LDAP_DEBUG_STATS, "conn=%d SSL %i-bit %s\n",
 		   		conn->c_connid, keySize, cipher ? cipher : "NULL" );
-		slapi_ch_free((void **)&cipher);
+		slapi_ch_free_string(&cipher);
 		return;
     } 
     if (clientCert == NULL) {
@@ -499,7 +499,7 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData)
 	        LDAPDebug (LDAP_DEBUG_TRACE, "<= ldapu_cert_to_ldap_entry() %i (%s)%s\n",
 			   err, extraErrorMsg, chain ? "" : " NULL");
 	    }
-		slapi_ch_free((void**)&basedn);
+		slapi_ch_free_string(&basedn);
 	    slapu_msgfree (internal_ld, chain);
 	}
 	if (subject) free (subject);
@@ -522,6 +522,6 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData)
 	bind_credentials_set( conn, SLAPD_AUTH_SSL, clientDN,
 			SLAPD_AUTH_SSL, clientDN, clientCert , NULL);
 
-    slapi_ch_free((void **)&cipher);
+    slapi_ch_free_string(&cipher);
     /* clientDN and clientCert will be freed later */
 }

+ 9 - 0
ldap/servers/slapd/back-ldbm/back-ldbm.h

@@ -114,6 +114,15 @@ typedef unsigned short u_int16_t;
 #define MEGABYTE (1024 * 1024)
 #define GIGABYTE (1024 * MEGABYTE)
 
+#define DB_USES_LOCKING(env) \
+    (DB_INIT_LOCK & ((env)->get_open_flags((env), NULL)))
+#define DB_USES_TRANSACTIONS(env) \
+    (DB_INIT_TXN & ((env)->get_open_flags((env), NULL)))
+#define DB_USES_MPOOL(env) \
+    (DB_INIT_MPOOL & ((env)->get_open_flags((env), NULL)))
+#define DB_USES_LOGGING(env) \
+    (DB_INIT_LOG & ((env)->get_open_flags((env), NULL)))
+
 
 /* include NSPR header files */
 #include "nspr.h"

+ 24 - 17
ldap/servers/slapd/back-ldbm/dblayer.c

@@ -97,6 +97,13 @@
 #include "dblayer.h"
 #include <prrwlock.h>
 
+/* Required to get portable printf/scanf format macros */
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#error Need to define portable format macros such as PRIu64
+#endif /* HAVE_INTTYPES_H */
+
 #if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4100
 #define DB_OPEN(oflags, db, txnid, file, database, type, flags, mode, rval)    \
 {                                                                              \
@@ -284,7 +291,7 @@ dblayer_bt_compare(DB *db, const DBT *dbt1, const DBT *dbt2)
 
 int
 dblayer_set_batch_transactions(void *arg, void *value, char *errorbuf, int phase, int apply) {
-    int val = (int) value;
+    int val = (int)((uintptr_t)value);
     int retval = LDAP_SUCCESS;
 
     if (apply) {
@@ -304,7 +311,7 @@ dblayer_set_batch_transactions(void *arg, void *value, char *errorbuf, int phase
 
 void *
 dblayer_get_batch_transactions(void *arg) {
-  return (void *)trans_batch_limit;
+    return (void *)((uintptr_t)trans_batch_limit);
 }
 
 
@@ -465,25 +472,25 @@ int dblayer_open_huge_file(const char *path, int oflag, int mode)
 }
 
 
-/* Helper function for large seeks, db2.4 */
-static int dblayer_seek24_large(int fd, size_t pgsize, db_pgno_t pageno,
-                u_long relative, int isrewind, int whence)
+#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
+/* Helper function for large seeks, db4.3 */
+static int dblayer_seek43_large(int fd, off64_t offset, int whence)
 {
-    off64_t offset = 0, ret;
+    int ret = 0;
 
-    offset = (off64_t)pgsize * pageno + relative;
-    if (isrewind) offset = -offset;
     ret = lseek64(fd, offset, whence);
 
     return (ret < 0) ? errno : 0;
 }
-
-#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
-/* Helper function for large seeks, db4.3 */
-static int dblayer_seek43_large(int fd, off64_t offset, int whence)
+#else
+/* Helper function for large seeks, db2.4 */
+static int dblayer_seek24_large(int fd, size_t pgsize, db_pgno_t pageno,
+                u_long relative, int isrewind, int whence)
 {
-    int ret = 0;
+    off64_t offset = 0, ret;
 
+    offset = (off64_t)pgsize * pageno + relative;
+    if (isrewind) offset = -offset;
     ret = lseek64(fd, offset, whence);
 
     return (ret < 0) ? errno : 0;
@@ -892,7 +899,7 @@ void dblayer_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size_
                 if (feof(f))
                     break;
                 if (strncmp(s, "VmSize:", 7) == 0) {
-                    sscanf(s+7, "%d", procpages);
+                    sscanf(s+7, "%" PRIuPTR, procpages);
                     break;
                 }
             }
@@ -3449,7 +3456,7 @@ static int deadlock_threadmain(void *param)
     {
         if (priv->dblayer_enable_transactions) 
         {
-            if (NULL != priv->dblayer_env->dblayer_DB_ENV->lk_handle) {
+            if (DB_USES_LOCKING(priv->dblayer_env->dblayer_DB_ENV)) {
                 int aborted;
                 if ((rval = LOCK_DETECT(priv->dblayer_env->dblayer_DB_ENV,
                             0,
@@ -3619,7 +3626,7 @@ static int checkpoint_threadmain(void *param)
                                                checkpoint_interval) 
             continue;
 
-        if (NULL == priv->dblayer_env->dblayer_DB_ENV->tx_handle)
+        if (!DB_USES_TRANSACTIONS(priv->dblayer_env->dblayer_DB_ENV))
             continue;
 
         /* now checkpoint */
@@ -3777,7 +3784,7 @@ static int trickle_threadmain(void *param)
         DS_Sleep(interval);   /* 622855: wait for other threads fully started */
         if (priv->dblayer_enable_transactions) 
         {
-            if ( (NULL != priv->dblayer_env->dblayer_DB_ENV->mp_handle) &&
+            if ( DB_USES_MPOOL(priv->dblayer_env->dblayer_DB_ENV) &&
                  (0 != priv->dblayer_trickle_percentage) )
             {
                 int pages_written = 0;

+ 0 - 2
ldap/servers/slapd/back-ldbm/dbverify.c

@@ -50,7 +50,6 @@ dbverify_ext( ldbm_instance *inst, int verbose )
     char *filep           = NULL;
     PRDir *dirhandle      = NULL;
     PRDirEntry *direntry  = NULL;
-    backend *be           = inst->inst_be;
     DB *dbp               = NULL;
     int tmplen            = 0;
     int filelen           = 0;
@@ -87,7 +86,6 @@ dbverify_ext( ldbm_instance *inst, int verbose )
           (direntry = PR_ReadDir(dirhandle, PR_SKIP_DOT | PR_SKIP_DOT_DOT)))
     {
         /* struct attrinfo *ai = NULL; */
-        char *p             = NULL;
         dbp = NULL;
 
         if (!direntry->name)

+ 8 - 1
ldap/servers/slapd/back-ldbm/import-merge.c

@@ -49,6 +49,13 @@
 #include "back-ldbm.h"
 #include "import.h"
 
+/* Required to get portable printf/scanf format macros */
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#error Need to define portable format macros such as PRIu64
+#endif /* HAVE_INTTYPES_H */
+
 struct _import_merge_thang
 {
 	int type;
@@ -667,7 +674,7 @@ int import_mega_merge(ImportJob *job)
     if (1 == job->number_indexers) {
 	import_log_notice(job, "Beginning %d-way merge of one file...", passes);
     } else {
-	import_log_notice(job, "Beginning %d-way merge of up to %lu files...",
+	import_log_notice(job, "Beginning %d-way merge of up to %" PRIuPTR " files...",
 			  passes, job->number_indexers);
     }
 

+ 17 - 9
ldap/servers/slapd/back-ldbm/import-threads.c

@@ -49,6 +49,13 @@
  * a wire import (aka "fast replica" import) won't have a producer thread.
  */
 
+/* Required to get portable printf/scanf format macros */
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#error Need to define portable format macros such as PRIu64
+#endif /* HAVE_INTTYPES_H */
+
 #include "back-ldbm.h"
 #include "vlv_srch.h"
 #include "import.h"
@@ -56,6 +63,7 @@
 #define STDIN_FILENO 0
 #endif
 
+static void import_wait_for_space_in_fifo(ImportJob *job, size_t new_esize);
 
 static struct backentry *import_make_backentry(Slapi_Entry *e, ID id)
 {
@@ -570,8 +578,8 @@ void import_producer(void *param)
                     "ending line %d of file \"%s\"",
                     escape_string(slapi_entry_get_dn(e), ebuf),
                     curr_lineno, curr_filename);
-            import_log_notice(job, "REASON: entry too large (%d bytes) for "
-                    "the buffer size (%d bytes)", newesize, job->fifo.bsize);
+            import_log_notice(job, "REASON: entry too large (%ld bytes) for "
+                    "the buffer size (%" PRIuPTR " bytes)", newesize, job->fifo.bsize);
             backentry_free(&ep);
             job->skipped++;
             continue;
@@ -804,8 +812,8 @@ void index_producer(void *param)
             char ebuf[BUFSIZ];
             import_log_notice(job, "WARNING: skipping entry \"%s\"",
                     escape_string(slapi_entry_get_dn(e), ebuf));
-            import_log_notice(job, "REASON: entry too large (%d bytes) for "
-                    "the buffer size (%d bytes)", newesize, job->fifo.bsize);
+            import_log_notice(job, "REASON: entry too large (%" PRIuPTR " bytes) for "
+                    "the buffer size (%" PRIuPTR " bytes)", newesize, job->fifo.bsize);
             backentry_free(&ep);
             job->skipped++;
             continue;
@@ -1185,7 +1193,7 @@ void import_worker(void *param)
     int idl_disposition = 0;
     struct vlvIndex* vlv_index = NULL;
     void *substring_key_buffer = NULL;
-    FifoItem *fi;
+    FifoItem *fi = NULL;
     int is_objectclass_attribute;
     int is_nsuniqueid_attribute;
     void *attrlist_cursor;
@@ -1598,8 +1606,8 @@ static int bulk_import_queue(ImportJob *job, Slapi_Entry *entry)
         char ebuf[BUFSIZ];
         import_log_notice(job, "WARNING: skipping entry \"%s\"",
                     escape_string(slapi_entry_get_dn(ep->ep_entry), ebuf));
-        import_log_notice(job, "REASON: entry too large (%d bytes) for "
-                    "the import buffer size (%d bytes).   Try increasing nsslapd-cachememsize.", newesize, job->fifo.bsize);
+        import_log_notice(job, "REASON: entry too large (%" PRIuPTR " bytes) for "
+                    "the import buffer size (%" PRIuPTR " bytes).   Try increasing nsslapd-cachememsize.", newesize, job->fifo.bsize);
         backentry_clear_entry(ep);      /* entry is released in the frontend on failure*/
         backentry_free( &ep );          /* release the backend wrapper, here */
         PR_Unlock(job->wire_lock);
@@ -1670,7 +1678,7 @@ int ldbm_back_wire_import(Slapi_PBlock *pb)
 {
     struct ldbminfo *li;
     backend *be = NULL;
-    ImportJob *job;
+    ImportJob *job = NULL;
     PRThread *thread;
     int state;
 
@@ -1954,7 +1962,7 @@ dse_conf_verify_core(struct ldbminfo *li, char *src_dir, char *file_name, char *
 		
 		if (entry_filter != NULL) /* Single instance restoration */
 		{
-			if (!(int)strstr(estr, entry_filter))
+			if (NULL == strstr(estr, entry_filter))
 				continue;
 		}
 

+ 11 - 5
ldap/servers/slapd/back-ldbm/import.c

@@ -46,6 +46,12 @@
  * please make sure you use 4-space indentation on this file.
  */
 
+/* Required to get portable printf/scanf format macros */
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#error Need to define portable format macros such as PRIu64
+#endif /* HAVE_INTTYPES_H */
 
 #include "back-ldbm.h"
 #include "vlv_srch.h"
@@ -1149,7 +1155,7 @@ int import_main_offline(void *arg)
                 import_log_notice(job, "Index buffering is disabled.");
         else
                 import_log_notice(job,
-                                "Index buffering enabled with bucket size %lu", 
+                                "Index buffering enabled with bucket size %" PRIuPTR, 
                                 job->job_index_buffer_suggestion);
 
         job->worker_list = producer;
@@ -1312,7 +1318,7 @@ error:
         if (job->not_here_skipped)
         {
                 if (job->skipped)
-                        import_log_notice(job, "Import complete.  Processed %lu entries "
+                        import_log_notice(job, "Import complete.  Processed %" PRIuPTR " entries "
                               "(%d bad entries were skipped, "
                               "%d entries were skipped because they don't "
                                                           "belong to this database) in %d seconds. "
@@ -1320,7 +1326,7 @@ error:
                               job->skipped, job->not_here_skipped,
                                                           seconds_to_import, entries_per_second);
                 else
-                        import_log_notice(job, "Import complete.  Processed %lu entries "
+                        import_log_notice(job, "Import complete.  Processed %" PRIuPTR " entries "
                               "(%d entries were skipped because they don't "
                                                           "belong to this database) "
                               "in %d seconds. (%.2f entries/sec)",
@@ -1330,13 +1336,13 @@ error:
         else
         {
                 if (job->skipped)
-                        import_log_notice(job, "Import complete.  Processed %lu entries "
+                        import_log_notice(job, "Import complete.  Processed %" PRIuPTR " entries "
                               "(%d were skipped) in %d seconds. "
                               "(%.2f entries/sec)", entries_processed,
                               job->skipped, seconds_to_import,
                               entries_per_second);
                 else
-                        import_log_notice(job, "Import complete.  Processed %lu entries "
+                        import_log_notice(job, "Import complete.  Processed %" PRIuPTR " entries "
                               "in %d seconds. (%.2f entries/sec)",
                               entries_processed, seconds_to_import,
                               entries_per_second);

+ 0 - 1
ldap/servers/slapd/back-ldbm/import.h

@@ -235,4 +235,3 @@ void import_producer(void *param);
 void index_producer(void *param);
 void import_foreman(void *param);
 void import_worker(void *param);
-static void import_wait_for_space_in_fifo(ImportJob *job, size_t new_esize);

+ 6 - 6
ldap/servers/slapd/back-ldbm/ldbm_attr.c

@@ -258,16 +258,16 @@ attr_index_config(
 							   preamble, officialOID, index_rules[j] );
 						slapi_ch_free((void**)&preamble);
 						}
-					} else if (p =
-							   strstr(index_rules[j], INDEX_ATTR_SUBSTRBEGIN)) {
+					} else if ((p =
+                                strstr(index_rules[j], INDEX_ATTR_SUBSTRBEGIN))) {
 						_set_attr_substrlen(INDEX_SUBSTRBEGIN, index_rules[j],
 											&substrlens);
-					} else if (p =
-							   strstr(index_rules[j], INDEX_ATTR_SUBSTRMIDDLE)) {
+					} else if ((p =
+                                strstr(index_rules[j], INDEX_ATTR_SUBSTRMIDDLE))) {
 						_set_attr_substrlen(INDEX_SUBSTRMIDDLE, index_rules[j],
 											&substrlens);
-					} else if (p =
-							   strstr(index_rules[j], INDEX_ATTR_SUBSTREND)) {
+					} else if ((p =
+                                strstr(index_rules[j], INDEX_ATTR_SUBSTREND))) {
 						_set_attr_substrlen(INDEX_SUBSTREND, index_rules[j],
 											&substrlens);
 					} else if (!slapi_matchingrule_is_ordering(index_rules[j], attrsyntax_oid)) {

+ 70 - 63
ldap/servers/slapd/back-ldbm/ldbm_config.c

@@ -42,6 +42,13 @@
 
 /* ldbm_config.c - Handles configuration information that is global to all ldbm instances. */
 
+/* Required to get portable printf/scanf format macros */
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#error Need to define portable format macros such as PRIu64
+#endif /* HAVE_INTTYPES_H */
+
 #include "back-ldbm.h"
 #include "dblayer.h"
 
@@ -147,14 +154,14 @@ static void *ldbm_config_lookthroughlimit_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
 
-    return (void *) (li->li_lookthroughlimit);
+    return (void *) ((uintptr_t)(li->li_lookthroughlimit));
 }
 
 static int ldbm_config_lookthroughlimit_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
 
     /* Do whatever we can to make sure the data is ok. */
 
@@ -169,14 +176,14 @@ static void *ldbm_config_mode_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
 
-    return (void *) (li->li_mode);
+    return (void *) ((uintptr_t)(li->li_mode));
 }
 
 static int ldbm_config_mode_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
 
     /* Do whatever we can to make sure the data is ok. */
 
@@ -191,14 +198,14 @@ static void *ldbm_config_allidsthreshold_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
 
-    return (void *) (li->li_allidsthreshold);
+    return (void *) ((uintptr_t)(li->li_allidsthreshold));
 }
 
 static int ldbm_config_allidsthreshold_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
 
     /* Do whatever we can to make sure the data is ok. */
 
@@ -365,14 +372,14 @@ static void *ldbm_config_maxpassbeforemerge_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
 
-    return (void *) (li->li_maxpassbeforemerge);
+    return (void *) ((uintptr_t)(li->li_maxpassbeforemerge));
 }
 
 static int ldbm_config_maxpassbeforemerge_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         if (val < 0) {
@@ -391,14 +398,14 @@ static void *ldbm_config_dbncache_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
 
-    return (void *) (li->li_new_dbncache);
+    return (void *) ((uintptr_t)(li->li_new_dbncache));
 }
 
 static int ldbm_config_dbncache_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         if (val < 0) {
@@ -454,14 +461,14 @@ static void *ldbm_config_db_durable_transactions_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_durable_transactions;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_durable_transactions);
 }
 
 static int ldbm_config_db_durable_transactions_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
         
     if (apply) {
         li->li_dblayer_private->dblayer_durable_transactions = val;
@@ -474,7 +481,7 @@ static void *ldbm_config_db_lockdown_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_lockdown;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_lockdown);
 }
 
 static int ldbm_config_db_lockdown_set(
@@ -487,7 +494,7 @@ static int ldbm_config_db_lockdown_set(
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
 
     if (apply) {
         li->li_dblayer_private->dblayer_lockdown = val;
@@ -500,14 +507,14 @@ static void *ldbm_config_db_circular_logging_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_circular_logging;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_circular_logging);
 }
 
 static int ldbm_config_db_circular_logging_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         li->li_dblayer_private->dblayer_circular_logging = val;
@@ -520,14 +527,14 @@ static void *ldbm_config_db_transaction_logging_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_enable_transactions;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_enable_transactions);
 }
 
 static int ldbm_config_db_transaction_logging_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         li->li_dblayer_private->dblayer_enable_transactions = val;
@@ -560,14 +567,14 @@ static void *ldbm_config_db_checkpoint_interval_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_checkpoint_interval;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_checkpoint_interval);
 }
 
 static int ldbm_config_db_checkpoint_interval_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         li->li_dblayer_private->dblayer_checkpoint_interval = val;
@@ -620,14 +627,14 @@ static void *ldbm_config_db_idl_divisor_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_idl_divisor;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_idl_divisor);
 }
 
 static int ldbm_config_db_idl_divisor_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         li->li_dblayer_private->dblayer_idl_divisor = val;
@@ -660,14 +667,14 @@ static void *ldbm_config_db_spin_count_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_spin_count;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_spin_count);
 }
 
 static int ldbm_config_db_spin_count_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         li->li_dblayer_private->dblayer_spin_count = val;
@@ -680,14 +687,14 @@ static void *ldbm_config_db_trickle_percentage_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_trickle_percentage;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_trickle_percentage);
 }
 
 static int ldbm_config_db_trickle_percentage_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (val < 0 || val > 100) {
         PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
@@ -707,14 +714,14 @@ static void *ldbm_config_db_verbose_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_verbose;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_verbose);
 }
 
 static int ldbm_config_db_verbose_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         li->li_dblayer_private->dblayer_verbose = val;
@@ -727,14 +734,14 @@ static void *ldbm_config_db_debug_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_debug;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_debug);
 }
 
 static int ldbm_config_db_debug_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         li->li_dblayer_private->dblayer_debug = val;
@@ -747,14 +754,14 @@ static void *ldbm_config_db_named_regions_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_named_regions;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_named_regions);
 }
 
 static int ldbm_config_db_named_regions_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         li->li_dblayer_private->dblayer_named_regions = val;
@@ -767,14 +774,14 @@ static void *ldbm_config_db_private_mem_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_private_mem;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_private_mem);
 }
 
 static int ldbm_config_db_private_mem_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         li->li_dblayer_private->dblayer_private_mem = val;
@@ -787,14 +794,14 @@ static void *ldbm_config_db_private_import_mem_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_private_import_mem;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_private_import_mem);
 }
 
 static int ldbm_config_db_private_import_mem_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         li->li_dblayer_private->dblayer_private_import_mem = val;
@@ -820,7 +827,7 @@ static int ldbm_config_db_shm_key_set(
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
 
     if (apply) {
         li->li_dblayer_private->dblayer_shm_key = val;
@@ -833,7 +840,7 @@ static void *ldbm_config_db_lock_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_lock_config;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_lock_config);
 }
 
 
@@ -859,14 +866,14 @@ static void *ldbm_config_db_cache_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->dblayer_cache_config;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_cache_config);
 }
 
 static int ldbm_config_db_cache_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         li->li_dblayer_private->dblayer_cache_config = val;
@@ -879,14 +886,14 @@ static void *ldbm_config_db_debug_checkpointing_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
-    return (void *) li->li_dblayer_private->db_debug_checkpointing;
+    return (void *) ((uintptr_t)li->li_dblayer_private->db_debug_checkpointing);
 }
 
 static int ldbm_config_db_debug_checkpointing_set(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
     
     if (apply) {
         li->li_dblayer_private->db_debug_checkpointing = val;
@@ -922,7 +929,7 @@ static void *ldbm_config_import_cache_autosize_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *)arg;
 
-    return (void *)(li->li_import_cache_autosize);
+    return (void *)((uintptr_t)(li->li_import_cache_autosize));
 }
 
 static int ldbm_config_import_cache_autosize_set(void *arg, void *value, char *errorbuf,
@@ -931,7 +938,7 @@ static int ldbm_config_import_cache_autosize_set(void *arg, void *value, char *e
     struct ldbminfo *li = (struct ldbminfo *)arg;
 
     if (apply)
-    li->li_import_cache_autosize = (int)value;
+    li->li_import_cache_autosize = (int)((uintptr_t)value);
     return LDAP_SUCCESS;
 }
 
@@ -939,7 +946,7 @@ static void *ldbm_config_cache_autosize_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *)arg;
 
-    return (void *)(li->li_cache_autosize);
+    return (void *)((uintptr_t)(li->li_cache_autosize));
 }
 
 static int ldbm_config_cache_autosize_set(void *arg, void *value, char *errorbuf,
@@ -948,7 +955,7 @@ static int ldbm_config_cache_autosize_set(void *arg, void *value, char *errorbuf
     struct ldbminfo *li = (struct ldbminfo *)arg;
 
     if (apply)
-    li->li_cache_autosize = (int)value;
+    li->li_cache_autosize = (int)((uintptr_t)value);
     return LDAP_SUCCESS;
 }
 
@@ -956,7 +963,7 @@ static void *ldbm_config_cache_autosize_split_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *)arg;
 
-    return (void *)(li->li_cache_autosize_split);
+    return (void *)((uintptr_t)(li->li_cache_autosize_split));
 }
 
 static int ldbm_config_cache_autosize_split_set(void *arg, void *value, char *errorbuf,
@@ -965,7 +972,7 @@ static int ldbm_config_cache_autosize_split_set(void *arg, void *value, char *er
     struct ldbminfo *li = (struct ldbminfo *)arg;
 
     if (apply)
-    li->li_cache_autosize_split = (int)value;
+    li->li_cache_autosize_split = (int)((uintptr_t)value);
     return LDAP_SUCCESS;
 }
 
@@ -1021,7 +1028,7 @@ static void *ldbm_config_serial_lock_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
 
-    return (void *) li->li_fat_lock;
+    return (void *) ((uintptr_t)li->li_fat_lock);
 }
 
 static int ldbm_config_serial_lock_set(void *arg, void *value, char *errorbuf,
@@ -1030,7 +1037,7 @@ static int ldbm_config_serial_lock_set(void *arg, void *value, char *errorbuf,
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
     if (apply) {
-        li->li_fat_lock = (int) value;
+        li->li_fat_lock = (int) ((uintptr_t)value);
     }
     
     return LDAP_SUCCESS;
@@ -1040,7 +1047,7 @@ static void *ldbm_config_legacy_errcode_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
 
-    return (void *) li->li_legacy_errcode;
+    return (void *) ((uintptr_t)li->li_legacy_errcode);
 }
 
 static int ldbm_config_legacy_errcode_set(void *arg, void *value, char *errorbuf,
@@ -1049,7 +1056,7 @@ static int ldbm_config_legacy_errcode_set(void *arg, void *value, char *errorbuf
     struct ldbminfo *li = (struct ldbminfo *) arg;
     
     if (apply) {
-        li->li_legacy_errcode = (int) value;
+        li->li_legacy_errcode = (int) ((uintptr_t)value);
     }
     
     return LDAP_SUCCESS;
@@ -1099,7 +1106,7 @@ static void *ldbm_config_get_bypass_filter_test(void *arg)
 static int ldbm_config_set_use_vlv_index(void *arg, void *value, char *errorbuf, int phase, int apply) 
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
         
     if (apply) {
         if (val) {
@@ -1115,7 +1122,7 @@ static void *ldbm_config_get_use_vlv_index(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
 
-    return (void *) li->li_use_vlv;
+    return (void *) ((uintptr_t)li->li_use_vlv);
 }
 
 static int
@@ -1174,7 +1181,7 @@ static void *ldbm_config_db_tx_max_get(void *arg)
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
 
-    return (void *) li->li_dblayer_private->dblayer_tx_max;
+    return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_tx_max);
 }
 
 static int ldbm_config_db_tx_max_set(
@@ -1187,7 +1194,7 @@ static int ldbm_config_db_tx_max_set(
 {
     struct ldbminfo *li = (struct ldbminfo *) arg;
     int retval = LDAP_SUCCESS;
-    int val = (int) value;
+    int val = (int) ((uintptr_t)value);
 
     if (apply) {
         li->li_dblayer_private->dblayer_tx_max = val;
@@ -1409,17 +1416,17 @@ void ldbm_config_get(void *arg, config_info *config, char *buf)
     
     switch(config->config_type) {
     case CONFIG_TYPE_INT:
-            sprintf(buf, "%d", (int) config->config_get_fn(arg));
+            sprintf(buf, "%d", (int) ((uintptr_t)config->config_get_fn(arg)));
             break;
     case CONFIG_TYPE_INT_OCTAL:
-        sprintf(buf, "%o", (int) config->config_get_fn(arg));
+        sprintf(buf, "%o", (int) ((uintptr_t)config->config_get_fn(arg)));
         break;
     case CONFIG_TYPE_LONG:
         sprintf(buf, "%ld", (long) config->config_get_fn(arg));
         break;
     case CONFIG_TYPE_SIZE_T:
         val = (size_t) config->config_get_fn(arg);
-        sprintf(buf, "%lu", val);
+        sprintf(buf, "%" PRIuPTR, val);
         break;
     case CONFIG_TYPE_STRING:
         /* Remember the get function for strings returns memory
@@ -1429,7 +1436,7 @@ void ldbm_config_get(void *arg, config_info *config, char *buf)
         slapi_ch_free((void **)&tmp_string);
         break;
     case CONFIG_TYPE_ONOFF:
-        if ((int) config->config_get_fn(arg)) {
+        if ((int) ((uintptr_t)config->config_get_fn(arg))) {
             sprintf(buf, "on");
         } else {
             sprintf(buf, "off");
@@ -1578,7 +1585,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
         }
         /* convert 64 bit value to 32 bit value */
         LL_L2I(int_val, llval);
-        retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod);
+        retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod);
         break;
     case CONFIG_TYPE_INT_OCTAL:
         if (use_default) {
@@ -1586,7 +1593,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
         } else {
             int_val = (int) strtol((char *)bval->bv_val, NULL, 8);
         }
-        retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod);
+        retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod);
         break;
     case CONFIG_TYPE_LONG:
         if (use_default) {
@@ -1657,7 +1664,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc
         } else {
             int_val = !strcasecmp((char *) bval->bv_val, "on");
         }
-        retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod);
+        retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod);
         break;
     }
     

+ 7 - 6
ldap/servers/slapd/back-ldbm/ldbm_instance_config.c

@@ -136,7 +136,7 @@ ldbm_instance_config_readonly_get(void *arg)
 {
     ldbm_instance *inst = (ldbm_instance *)arg;
 
-    return (void *)inst->inst_be->be_readonly;
+    return (void *)((uintptr_t)inst->inst_be->be_readonly);
 }
 
 static void *
@@ -165,7 +165,7 @@ ldbm_instance_config_require_index_get(void *arg)
 {
     ldbm_instance *inst = (ldbm_instance *)arg;
     
-    return (void *)inst->require_index;
+    return (void *)((uintptr_t)inst->require_index);
 }
 
 static int
@@ -219,6 +219,7 @@ static int
 ldbm_instance_config_readonly_set(void *arg, void *value, char *errorbuf, int phase, int apply)
 {
     ldbm_instance *inst = (ldbm_instance *)arg;
+    uintptr_t pval = (uintptr_t)value;
 
     if (!apply) {
         return LDAP_SUCCESS;
@@ -229,15 +230,15 @@ ldbm_instance_config_readonly_set(void *arg, void *value, char *errorbuf, int ph
          * but won't change them until the instance is un-busy again.
          */
         if (! (inst->inst_flags & INST_FLAG_BUSY)) {
-            slapi_mtn_be_set_readonly(inst->inst_be, (int)value);
+            slapi_mtn_be_set_readonly(inst->inst_be, (int)pval);
         }
-        if ((int)value) {
+        if ((int)pval) {
             inst->inst_flags |= INST_FLAG_READONLY;
         } else {
             inst->inst_flags &= ~INST_FLAG_READONLY;
         }
     } else {
-        slapi_be_set_readonly(inst->inst_be, (int)value);
+        slapi_be_set_readonly(inst->inst_be, (int)pval);
     }
 
     return LDAP_SUCCESS;
@@ -252,7 +253,7 @@ ldbm_instance_config_require_index_set(void *arg, void *value, char *errorbuf, i
         return LDAP_SUCCESS;
     }
 
-    inst->require_index = (int)value;
+    inst->require_index = (int)((uintptr_t)value);
 
     return LDAP_SUCCESS;
 }

+ 7 - 7
ldap/servers/slapd/back-ldbm/ldbm_modify.c

@@ -578,10 +578,10 @@ mods_have_effect (Slapi_Entry *entry, Slapi_Mods *smods)
 	 */
 	for ( j = 0; j < smods->num_mods - 1; j++ ) {
 		if ( (mod = smods->mods[j]) != NULL ) {
-			if ( (mod->mod_op & LDAP_MOD_REPLACE) == 0 ||
-				mod->mod_vals.modv_bvals &&
-				strcasecmp (mod->mod_type, "modifiersname") &&
-				strcasecmp (mod->mod_type, "modifytime") ) {
+			if ( ((mod->mod_op & LDAP_MOD_REPLACE) == 0) ||
+				 (mod->mod_vals.modv_bvals &&
+				  strcasecmp (mod->mod_type, "modifiersname") &&
+				  strcasecmp (mod->mod_type, "modifytime") ) ) {
 				goto done;
 			}
 		}
@@ -589,9 +589,9 @@ mods_have_effect (Slapi_Entry *entry, Slapi_Mods *smods)
 
 	if ( entry && entry->e_sdn.dn ) {
 		for ( j = 0; j < smods->num_mods - 1; j++ ) {
-			if ( (mod = smods->mods[j]) != NULL &&
-				strcasecmp (mod->mod_type, "modifiersname") &&
-				strcasecmp (mod->mod_type, "modifytime") ) {
+			if ( ((mod = smods->mods[j]) != NULL) &&
+				 strcasecmp (mod->mod_type, "modifiersname") &&
+				 strcasecmp (mod->mod_type, "modifytime") ) {
 				for ( attr = entry->e_attrs; attr; attr = attr->a_next ) {
 					/* Mods have effect if at least a null-value-mod is
 					 * to actually remove an existing attribute

+ 16 - 10
ldap/servers/slapd/back-ldbm/ldif2ldbm.c

@@ -47,6 +47,13 @@
  * code for db2index (is this still in use?)
  */
 
+/* Required to get portable printf/scanf format macros */
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#error Need to define portable format macros such as PRIu64
+#endif /* HAVE_INTTYPES_H */
+
 #include "back-ldbm.h"
 #include "vlv_srch.h"
 #include "dblayer.h"
@@ -76,7 +83,7 @@ size_t import_get_index_buffer_size() {
 
 static PRIntn import_subcount_hash_compare_keys(const void *v1, const void *v2)
 {
-    return( ((ID)v1 == (ID)v2 ) ? 1 : 0);
+    return( ((ID)((uintptr_t)v1) == (ID)((uintptr_t)v2) ) ? 1 : 0);
 }
 
 static PRIntn import_subcount_hash_compare_values(const void *v1, const void *v2)
@@ -86,7 +93,7 @@ static PRIntn import_subcount_hash_compare_values(const void *v1, const void *v2
 
 static PLHashNumber import_subcount_hash_fn(const void *id)
 {
-    return (PLHashNumber) id;
+    return (PLHashNumber) ((uintptr_t)id);
 }
 
 void import_subcount_stuff_init(import_subcount_stuff *stuff)
@@ -263,7 +270,7 @@ int import_subcount_mother_init(import_subcount_stuff *mothers, ID parent_id,
                                 size_t count)
 {
     PR_ASSERT(NULL == PL_HashTableLookup(mothers->hashtable,(void*)parent_id));
-    PL_HashTableAdd(mothers->hashtable,(void*)parent_id,(void*)count);
+    PL_HashTableAdd(mothers->hashtable,(void*)((uintptr_t)parent_id),(void*)count);
     return 0;
 }
 
@@ -276,7 +283,7 @@ static int import_subcount_mothers_lookup(import_subcount_stuff *mothers,
     *count = 0;
     /* Lookup hash table for ID */
     stored_count = (size_t)PL_HashTableLookup(mothers->hashtable,
-                                              (void*)parent_id);
+                                              (void*)((uintptr_t)parent_id));
     /* If present, return the count found */
     if (0 != stored_count) {
         *count = stored_count;
@@ -292,11 +299,11 @@ int import_subcount_mother_count(import_subcount_stuff *mothers, ID parent_id)
 
     /* Lookup the hash table for the target ID */
     stored_count = (size_t)PL_HashTableLookup(mothers->hashtable,
-                                              (void*)parent_id);
+                                              (void*)((uintptr_t)parent_id));
     PR_ASSERT(0 != stored_count);
     /* Increment the count */
     stored_count++;
-    PL_HashTableAdd(mothers->hashtable, (void*)parent_id, (void*)stored_count);
+    PL_HashTableAdd(mothers->hashtable, (void*)((uintptr_t)parent_id), (void*)stored_count);
     return 0;
 }
 
@@ -320,7 +327,7 @@ static int import_update_entry_subcount(backend *be, ID parentid,
      * let's do it so we can reuse the modify routines) */
     cache_lock_entry( &inst->inst_cache, e );
     modify_init(&mc,e);
-    sprintf(value_buffer,"%lu",sub_count);
+    sprintf(value_buffer,"%" PRIuPTR,sub_count);
     /* attr numsubordinates could already exist in the entry,
        let's check whether it's already there or not */
     isreplace = (attrlist_find(e->ep_entry->e_attrs, numsubordinates) != NULL);
@@ -761,12 +768,12 @@ ldbm_back_ldbm2ldif( Slapi_PBlock *pb )
     int              appendmode = 0;
     int              appendmode_1 = 0;
     int              noversion = 0;
-    ID               lastid;
+    ID               lastid = 0;
     int              task_flags;
     Slapi_Task       *task;
     int              run_from_cmdline = 0;
     char             *instance_name;
-    ldbm_instance    *inst;
+    ldbm_instance    *inst = NULL;
     int              str2entry_options= 0;
     int              retry;
     int              we_start_the_backends = 0;
@@ -1812,7 +1819,6 @@ err_out:
         dbc->c_close(dbc);
     }
     if (return_value < 0) {/* error case: undo vlv indexing */
-        struct vlvIndex *vlvip = NULL;
         /* if jumped to out due to an error, vlv lock has not been released */
         for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) {
             vlvIndex_go_offline(pvlv[vlvidx], be);

+ 9 - 2
ldap/servers/slapd/back-ldbm/monitor.c

@@ -42,6 +42,13 @@
 
 /* monitor.c - ldbm backend monitor function */
 
+/* Required to get portable printf/scanf format macros */
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#error Need to define portable format macros such as PRIu64
+#endif /* HAVE_INTTYPES_H */
+
 #include "back-ldbm.h"
 #include "dblayer.h"	/* XXXmcs: not sure this is good to do... */
 #include <sys/stat.h>
@@ -117,9 +124,9 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
     MSET("entryCacheTries");
     sprintf(buf, "%lu", (unsigned long)(100.0*(double)hits / (double)(tries > 0 ? tries : 1)));
     MSET("entryCacheHitRatio");
-    sprintf(buf, "%lu", size);
+    sprintf(buf, "%" PRIuPTR, size);
     MSET("currentEntryCacheSize");
-    sprintf(buf, "%lu", maxsize);
+    sprintf(buf, "%" PRIuPTR, maxsize);
     MSET("maxEntryCacheSize");
     sprintf(buf, "%ld", nentries);
     MSET("currentEntryCacheCount");

+ 8 - 1
ldap/servers/slapd/back-ldbm/parents.c

@@ -44,6 +44,13 @@
 
 #include "back-ldbm.h"
 
+/* Required to get portable printf/scanf format macros */
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#error Need to define portable format macros such as PRIu64
+#endif /* HAVE_INTTYPES_H */
+
 char *numsubordinates = "numsubordinates";
 char *hassubordinates = "hassubordinates";
 
@@ -130,7 +137,7 @@ int parent_update_on_childchange(modify_context *mc,int op, size_t *new_sub_coun
 		else
 		{
         	char value_buffer[20]; /* enough digits for 2^64 children */
-        	sprintf(value_buffer,"%lu", current_sub_count);
+        	sprintf(value_buffer,"%" PRIuPTR, current_sub_count);
             slapi_mods_add(smods, mod_op | LDAP_MOD_BVALUES, numsubordinates, strlen(value_buffer), value_buffer);
 		}
     	ret = modify_apply_mods(mc,smods); /* smods passed in */

+ 4 - 4
ldap/servers/slapd/back-ldbm/perfctrs.c

@@ -296,7 +296,7 @@ void perfctrs_update(perfctrs_private *priv, DB_ENV *db_env)
 		return;
 	}
 	/* Call libdb to get the various stats */
-	if (NULL != db_env->lg_handle)
+	if (DB_USES_LOGGING(db_env))
 	{
 		DB_LOG_STAT *logstat = NULL;
 		ret = LOG_STAT(db_env,&logstat,0,malloc);
@@ -307,7 +307,7 @@ void perfctrs_update(perfctrs_private *priv, DB_ENV *db_env)
 		}
 		free(logstat);
 	}
-	if (NULL != db_env->tx_handle)
+	if (DB_USES_TRANSACTIONS(db_env))
 	{
 		DB_TXN_STAT *txnstat = NULL;
 		ret = TXN_STAT(db_env, &txnstat, 0, malloc);
@@ -320,7 +320,7 @@ void perfctrs_update(perfctrs_private *priv, DB_ENV *db_env)
 		if (txnstat)
 			free(txnstat);
 	}
-	if (NULL != db_env->lk_handle)
+	if (DB_USES_LOCKING(db_env))
 	{
 		DB_LOCK_STAT *lockstat = NULL;
 		ret = LOCK_STAT(db_env,&lockstat,0,malloc);
@@ -338,7 +338,7 @@ void perfctrs_update(perfctrs_private *priv, DB_ENV *db_env)
 		}
 		free(lockstat);
 	}
-	if (NULL != db_env->mp_handle)
+	if (DB_USES_MPOOL(db_env))
 	{
 		DB_MPOOL_STAT	*mpstat = NULL;
 		ret = MEMP_STAT(db_env,&mpstat,NULL,0,malloc);

+ 2 - 2
ldap/servers/slapd/bind.c

@@ -103,7 +103,7 @@ is_root_dn_pw( const char *dn, const Slapi_Value *cred )
 		rv = slapi_pw_find_sv( rdnpwvals, cred ) == 0;
 		value_done(&rdnpwbv);
 	}
-	slapi_ch_free( (void **) &rootpw );
+	slapi_ch_free_string( &rootpw );
 	return rv;
 }
 
@@ -787,6 +787,6 @@ slapi_add_auth_response_control( Slapi_PBlock *pb, const char *binddn )
 	}
 
 	if ( NULL != dnbuf_dynamic ) {
-		slapi_ch_free( (void **)&dnbuf_dynamic );
+		slapi_ch_free_string( &dnbuf_dynamic );
 	}
 }

+ 2 - 2
ldap/servers/slapd/config.c

@@ -566,11 +566,11 @@ slapd_bootstrap_config(const char *configdir)
 			}
 		}
 
-		slapi_ch_free((void **)&buf);
+		slapi_ch_free_string(&buf);
 	}
 
 bail:
-	slapi_ch_free((void **)&buf);
+	slapi_ch_free_string(&buf);
 	return rc;
 }
 

+ 5 - 5
ldap/servers/slapd/configdse.c

@@ -102,7 +102,7 @@ isASyntaxOrMrPluginOrPss(Slapi_Entry *e)
 		retval = (ptype && !strcasecmp(ptype, "pwdstoragescheme"));
 	if (!retval)
 		retval = (ptype && !strcasecmp(ptype, "reverpwdstoragescheme"));
-	slapi_ch_free((void**)&ptype);
+	slapi_ch_free_string(&ptype);
 	return retval;
 }
 
@@ -178,7 +178,7 @@ read_config_dse (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int
 		be = slapi_get_next_backend (cookie);
     }
 
-	slapi_ch_free ((void **)&cookie);
+	slapi_ch_free_string (&cookie);
 
 	/* show be_type */
 	attrlist_delete( &e->e_attrs, "nsslapd-betype");
@@ -195,7 +195,7 @@ read_config_dse (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int
 		be = slapi_get_next_backend(cookie);
 	}
 
-	slapi_ch_free ( (void **) &cookie);
+	slapi_ch_free_string (&cookie);
 
     /* show private suffixes */
     attrlist_delete ( &e->e_attrs, "nsslapd-privatenamespaces");
@@ -222,7 +222,7 @@ read_config_dse (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int
 		be = slapi_get_next_backend(cookie);    	
     }
 
-	slapi_ch_free ((void **) &cookie);
+	slapi_ch_free_string (&cookie);
 
 	/* show syntax plugins */
 	attrlist_delete ( &e->e_attrs, CONFIG_PLUGIN_ATTRIBUTE );
@@ -432,7 +432,7 @@ finish_and_return:
 	/* if the password has been set, it will be hashed */
 	if ((pwd = config_get_rootpw()) != NULL) {
 		slapi_entry_attr_set_charptr(e, CONFIG_ROOTPW_ATTRIBUTE, pwd);
-		slapi_ch_free((void**)&pwd);
+		slapi_ch_free_string(&pwd);
 	}
 
 	*returncode= rc;

+ 1 - 1
ldap/servers/slapd/conntable.c

@@ -438,7 +438,7 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
 			val.bv_len = strlen( bufptr );
 			attrlist_merge( &e->e_attrs, "connection", vals );
 			if (newbuf) {
-				slapi_ch_free((void **) &newbuf);
+				slapi_ch_free_string(&newbuf);
 			}
 		}
 		PR_Unlock( ct->c[i].c_mutex );

+ 2 - 2
ldap/servers/slapd/detach.c

@@ -127,7 +127,7 @@ detach( int slapd_exemode, int importexport_encrypt,
 				}
 				(void) chdir( errorlog );
 				config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, errorlog, errorbuf, 1);
-				slapi_ch_free((void**)&errorlog);
+				slapi_ch_free_string(&errorlog);
 			}
 		} else {
 			/* calling config_set_workingdir to check for validity of directory, don't apply */
@@ -135,7 +135,7 @@ detach( int slapd_exemode, int importexport_encrypt,
 				exit(1);
 			}
 			(void) chdir( workingdir );
-			slapi_ch_free((void**)&workingdir);
+			slapi_ch_free_string(&workingdir);
 		}
 
 		if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {

+ 10 - 1
ldap/servers/slapd/dse.c

@@ -72,6 +72,13 @@
 #include <pwd.h>
 #endif  /* _WIN32 */
 
+/* Required to get portable printf/scanf format macros */
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#error Need to define portable format macros such as PRIu64
+#endif /* HAVE_INTTYPES_H */
+
 /* #define SLAPI_DSE_DEBUG */ 	/* define this to force trace log	*/
 								/* messages to always be logged		*/
 
@@ -463,6 +470,8 @@ dse_destroy(struct dse *pdse)
     slapi_ch_free((void **)&pdse);
     LDAPDebug( SLAPI_DSE_TRACELEVEL, "Removed [%d] entries from the dse tree.\n",
                  nentries,0,0 );
+
+    return 0; /* no one checks this return value */
 }
 
 /*
@@ -603,7 +612,7 @@ dse_updateNumSubordinates(Slapi_Entry *entry, int op)
         struct berval val;
         vals[0] = &val;
         vals[1] = NULL;
-        sprintf(value_buffer,"%lu",current_sub_count);
+        sprintf(value_buffer,"%" PRIuPTR,current_sub_count);
         val.bv_val = value_buffer;
         val.bv_len = strlen (val.bv_val);
         switch(mod_op)

+ 2 - 2
ldap/servers/slapd/filter.c

@@ -1280,7 +1280,7 @@ slapi_filter_to_string_internal( const struct slapi_filter *f, char *buf, size_t
 			if(1 < *bufsize)
 			{
 				sprintf( buf, ")" );
-				*bufsize--;
+				(*bufsize)--;
 			}
 		}
 		break;
@@ -1313,7 +1313,7 @@ slapi_filter_to_string_internal( const struct slapi_filter *f, char *buf, size_t
 			if(1 < *bufsize)
 			{
 				sprintf( buf, ")" );
-				*bufsize--;
+				(*bufsize)--;
 			}
 		}
 		break;

+ 5 - 1
ldap/servers/slapd/libglobs.c

@@ -5066,6 +5066,8 @@ config_set_value(
 {
     struct berval **values = 0;
     char *sval = 0;
+    int ival = 0;
+    uintptr_t pval;
 
     /* for null values, just set the attr value to the empty
        string */
@@ -5125,7 +5127,9 @@ config_set_value(
 
     case CONFIG_CONSTANT_INT:
         PR_ASSERT(value); /* should be a constant value */
-        slapi_entry_attr_set_int(e, cgas->attr_name, (int)value);
+        pval = (uintptr_t)value;
+        ival = (int)pval;
+        slapi_entry_attr_set_int(e, cgas->attr_name, ival);
         break;
 
     case CONFIG_SPECIAL_SSLCLIENTAUTH:

+ 2 - 2
ldap/servers/slapd/log.c

@@ -2216,12 +2216,12 @@ log__needrotation(LOGFD fp, int logtype)
 {
 	time_t	curr_time;
 	time_t	log_createtime= 0;
-	time_t	syncclock;
+	time_t	syncclock = 0;
 	int	type = LOG_CONTINUE;
 	int	f_size = 0;
 	int	maxlogsize, nlogs;
 	int	rotationtime_secs = -1;
-	int	sync_enabled, timeunit;
+	int	sync_enabled = 0, timeunit = 0;
 
 	if (fp == NULL) {
 		return LOG_ROTATE;

+ 4 - 0
ldap/servers/slapd/log.h

@@ -49,9 +49,13 @@
  *************************************************************************/
 #include <stdio.h>
 #ifdef LINUX
+#ifndef _XOPEN_SOURCE
 #define _XOPEN_SOURCE /* glibc2 needs this */
+#endif
+#ifndef __USE_XOPEN
 #define __USE_XOPEN
 #endif
+#endif
 #include <time.h>
 #include <stdarg.h>
 #include <sys/types.h>

+ 0 - 3
ldap/servers/slapd/main.c

@@ -261,7 +261,6 @@ static void
 fix_ownership() 
 {
 	struct passwd* pw=NULL;
-	char dirname[MAXPATHLEN + 1];
 
 	slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
 
@@ -630,7 +629,6 @@ main( int argc, char **argv)
 	slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
 	daemon_ports_t ports_info = {0};
    	Slapi_Backend *be = NULL;
-	int init_ssl;
 #ifndef __LP64__ 
 #if defined(__hpux) && !defined(__ia64)
 	/* for static constructors */
@@ -2598,7 +2596,6 @@ slapd_exemode_dbverify()
     int return_value = 0;
     Slapi_PBlock pb;
     struct slapdplugin *backend_plugin;
-    slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
 
     /* this should be the first time to be called!  if the init order
      * is ever changed, these lines should be changed (or erased)!

+ 1 - 1
ldap/servers/slapd/mapping_tree.c

@@ -1998,7 +1998,7 @@ int slapi_mapping_tree_select(Slapi_PBlock *pb, Slapi_Backend **be, Slapi_Entry
      *  will be transferred to the internal DSE backend 
      */
     if( sdn_is_nulldn(target_sdn) &&
-        ((op_type == SLAPI_OPERATION_SEARCH) && (scope == LDAP_SCOPE_BASE)  ||
+        (((op_type == SLAPI_OPERATION_SEARCH) && (scope == LDAP_SCOPE_BASE)) ||
          (op_type != SLAPI_OPERATION_SEARCH)) ) {
 
         mtn_unlock();

+ 1 - 1
ldap/servers/slapd/pblock.c

@@ -2873,7 +2873,7 @@ slapi_pblock_set( Slapi_PBlock *pblock, int arg, void *value )
 		
 	case SLAPI_LDIF2DB_ENCRYPT:
 	case SLAPI_DB2LDIF_DECRYPT:
-		pblock->pb_ldif_encrypt = (int)value;
+		pblock->pb_ldif_encrypt = *((int *)value);
 		break;
 
 	default:

+ 0 - 1
ldap/servers/slapd/saslbind.c

@@ -297,7 +297,6 @@ static Slapi_Entry *ids_sasl_user_to_entry(
     int attrsonly = 0, scope = LDAP_SCOPE_SUBTREE;
     LDAPControl **ctrls = NULL;
     Slapi_Entry *entry = NULL;
-    Slapi_DN *sdn;
     char **attrs = NULL;
     int regexmatch = 0;
     char *base = NULL;

+ 0 - 1
ldap/servers/slapd/snmp_collator.c

@@ -399,7 +399,6 @@ int snmp_collator_start()
 
   int err;
   char *statspath = config_get_rundir();
-  char *lp = NULL;
   char *instdir = config_get_configdir();
   char *instname = NULL;
 

+ 3 - 1
ldap/servers/slapd/statechange.h

@@ -78,7 +78,9 @@ typedef void (*api_statechange_unregister_all)(char *caller_id, caller_data_free
 #define STATECHANGE_VATTR_ENTRY_INVALIDATE 2
 
 /* Vattr api caller data to be passed to statechange_register() */
+#ifdef DEFINE_STATECHANGE_STATICS
 static int vattr_global_invalidate = STATECHANGE_VATTR_GLOBAL_INVALIDATE;
-static int vattr_entry_invalidate = STATECHANGE_VATTR_ENTRY_INVALIDATE;
+/* static int vattr_entry_invalidate = STATECHANGE_VATTR_ENTRY_INVALIDATE; */
+#endif /* DEFINE_STATECHANGE_STATICS */
 
 #endif /*_STATE_NOTIFY_H_*/

+ 6 - 0
ldap/servers/slapd/task.c

@@ -193,6 +193,8 @@ int slapi_task_get_state(Slapi_Task *task)
     if (task) {
         return task->task_state;
     }
+
+    return 0; /* return value not currently used */
 }
 
 /* this changes the 'nsTaskStatus' value, which is transient (anything logged
@@ -341,6 +343,8 @@ void * slapi_task_get_data(Slapi_Task *task)
     if (task) {
         return task->task_private;
     }
+
+    return NULL; /* return value not currently used */
 }
 
 /*
@@ -371,6 +375,8 @@ int slapi_task_get_refcount(Slapi_Task *task)
     if (task) {
         return task->task_refcount;
     }
+
+    return 0; /* return value not currently used */
 }
 
 /* name is, for example, "import" */

+ 14 - 15
ldap/servers/slapd/tools/ldclt/ldapfct.c

@@ -671,9 +671,9 @@ connectToServer (
        */
       tttctx->ldapCtx = ldapssl_init(mctx.hostname, mctx.port, 1);
       if (mctx.mode & VERY_VERBOSE)
-	printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%08x\n",
+	printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%p\n",
 		mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port,
-		(unsigned int)tttctx->ldapCtx);
+		tttctx->ldapCtx);
       if (tttctx->ldapCtx == NULL)
       {
 	printf ("ldclt[%d]: T%03d: Cannot ldapssl_init (%s, %d), errno=%d\n",
@@ -689,14 +689,14 @@ connectToServer (
 	 ret = ldapssl_enable_clientauth(tttctx->ldapCtx, "", mctx.keydbpin, mctx.cltcertname);
 	 if (mctx.mode & VERY_VERBOSE)
 	   printf 
-	    ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)",
-	     mctx.pid, tttctx->thrdNum, (unsigned int)tttctx->ldapCtx, mctx.keydbpin,
+	    ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+	     mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin,
 	     mctx.cltcertname);
 	 if (ret < 0)
 	 {
 	   printf
-	    ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)",
-	     mctx.pid, tttctx->thrdNum, (unsigned int)tttctx->ldapCtx, mctx.keydbpin,
+	    ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+	     mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin,
 	     mctx.cltcertname);
 	   ldap_perror(tttctx->ldapCtx, "ldapssl_enable_clientauth");
 	   fflush (stdout);
@@ -709,9 +709,9 @@ connectToServer (
        */
       tttctx->ldapCtx = ldap_init (mctx.hostname, mctx.port);
       if (mctx.mode & VERY_VERBOSE)
-	printf ("ldclt[%d]: T%03d: After ldap_init (%s, %d), ldapCtx=0x%08x\n",
+	printf ("ldclt[%d]: T%03d: After ldap_init (%s, %d), ldapCtx=0x%p\n",
 		mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port,
-		(unsigned int)tttctx->ldapCtx);
+		tttctx->ldapCtx);
       if (tttctx->ldapCtx == NULL)
       {
 	printf ("ldclt[%d]: T%03d: Cannot ldap_init (%s, %d), errno=%d\n",
@@ -805,7 +805,6 @@ connectToServer (
   } else if ((mctx.mod2 & M2_SASLAUTH) && ((!(tttctx->binded)) ||
                                           (mctx.mode & BIND_EACH_OPER))) {
     void *defaults;
-    LDAPControl **rctrls = NULL;
     char *my_saslauthid = NULL;
 
     if ( mctx.sasl_mech == NULL) {
@@ -1836,9 +1835,9 @@ createMissingNodes (
        */
       tttctx->ldapCtx = ldapssl_init(mctx.hostname, mctx.port, 1);
       if (mctx.mode & VERY_VERBOSE)
-	printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%08x\n",
+	printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%p\n",
 		mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port,
-		(unsigned int)tttctx->ldapCtx);
+		tttctx->ldapCtx);
       if (tttctx->ldapCtx == NULL)
       {
 	printf ("ldclt[%d]: T%03d: Cannot ldapssl_init (%s, %d), errno=%d\n",
@@ -1854,14 +1853,14 @@ createMissingNodes (
 	 ret = ldapssl_enable_clientauth(tttctx->ldapCtx, "", mctx.keydbpin, mctx.cltcertname);
 	 if (mctx.mode & VERY_VERBOSE)
 	   printf 
-	     ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)",
-	      mctx.pid, tttctx->thrdNum, (unsigned int)tttctx->ldapCtx, mctx.keydbpin,
+	     ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+	      mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin,
 	      mctx.cltcertname);
 	 if (ret < 0)
 	 {
 	   printf 
-	    ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)",
-	     mctx.pid, tttctx->thrdNum, (unsigned int)tttctx->ldapCtx, mctx.keydbpin,
+	    ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+	     mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin,
 	     mctx.cltcertname);
 	   fflush (stdout);
 	   return (-1);

+ 8 - 8
ldap/servers/slapd/tools/ldclt/scalab01.c

@@ -524,8 +524,8 @@ scalab01_connectSuperuser (void)
      */
     s1ctx.ldapCtx = ldapssl_init(mctx.hostname, mctx.port, 1);
     if (mctx.mode & VERY_VERBOSE)
-      printf ("ldclt[%d]: ctrl: ldapssl_init (%s, %d), ldapCtx=0x%08x\n",
-			mctx.pid, mctx.hostname, mctx.port, (unsigned int)s1ctx.ldapCtx);
+      printf ("ldclt[%d]: ctrl: ldapssl_init (%s, %d), ldapCtx=0x%p\n",
+			mctx.pid, mctx.hostname, mctx.port, s1ctx.ldapCtx);
     if (s1ctx.ldapCtx == NULL)
     {
       printf ("ldclt[%d]: ctrl: Cannot ldapssl_init (%s, %d), errno=%d\n",
@@ -541,13 +541,13 @@ scalab01_connectSuperuser (void)
       ret = ldapssl_enable_clientauth(s1ctx.ldapCtx, "", mctx.keydbpin, mctx.cltcertname);
       if (mctx.mode & VERY_VERBOSE)
 	printf
-	    ("ldclt[%d]: ctrl: After ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)",
-	     mctx.pid, (unsigned int)s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname);
+	    ("ldclt[%d]: ctrl: After ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+	     mctx.pid, s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname);
       if (ret < 0)
       {
 	printf
-	    ("ldclt[%d]: ctrl: Cannot ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)",
-	     mctx.pid, (unsigned int)s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname);
+	    ("ldclt[%d]: ctrl: Cannot ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)",
+	     mctx.pid, s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname);
 	ldap_perror(s1ctx.ldapCtx, "ldapssl_enable_clientauth");
 	fflush (stdout);
 	return (-1);
@@ -561,8 +561,8 @@ scalab01_connectSuperuser (void)
      */
     s1ctx.ldapCtx = ldap_init (mctx.hostname, mctx.port);
     if (mctx.mode & VERY_VERBOSE)
-      printf ("ldclt[%d]: ctrl: After ldap_init (%s, %d), ldapCtx=0x%08x\n",
-		mctx.pid, mctx.hostname, mctx.port, (unsigned int)s1ctx.ldapCtx);
+      printf ("ldclt[%d]: ctrl: After ldap_init (%s, %d), ldapCtx=0x%p\n",
+		mctx.pid, mctx.hostname, mctx.port, s1ctx.ldapCtx);
     if (s1ctx.ldapCtx == NULL)
     {
       printf ("ldclt[%d]: ctrl: Cannot ldap_init (%s, %d), errno=%d\n",

+ 1 - 1
ldap/servers/slapd/tools/ldif.c

@@ -145,7 +145,7 @@ int main( int argc, char **argv )
 					perror( "realloc" );
 					return( 1 );
 				}
-				fgets(buf+curlen, maxlen/2 + 1, stdin);
+				(void)fgets(buf+curlen, maxlen/2 + 1, stdin);
 			}
 			/* we have a full line, chop potential newline and turn into ldif */
 			if( buf[curlen-1] == '\n' )

+ 2 - 2
ldap/servers/slapd/tools/mmldif.c

@@ -816,7 +816,7 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
                 lookahead = fgetc(edf1->fp);
                 if (lookahead != ' ')
                     break;
-                fgets(line, sizeof(line), edf1->fp);
+                (void)fgets(line, sizeof(line), edf1->fp);
                 len = strlen(line);
                 for (lptr = line+len-1; len; len--, lptr--) {
                     if ((*lptr != '\n') && (*lptr != '\r'))
@@ -854,7 +854,7 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
                 lookahead = fgetc(edf1->fp);
                 if (lookahead != ' ')
                     break;
-                fgets(line, sizeof(line), edf1->fp);
+                (void)fgets(line, sizeof(line), edf1->fp);
                 len = strlen(line);
                 for (lptr = line+len-1; len; len--, lptr--) {
                     if ((*lptr != '\n') && (*lptr != '\r'))

+ 2 - 4
ldap/servers/slapd/tools/pwenc.c

@@ -145,7 +145,7 @@ init_config(char *configdir)
         fprintf( stderr, "%s\n", errorbuf );
         return( NULL );
     }
-    slapi_ch_free((void **)&abs_configdir);
+    slapi_ch_free_string(&abs_configdir);
 
     slapdFrontendConfig = getFrontendConfig();
     if (0 == slapd_config(slapdFrontendConfig->configdir, configfile)) {
@@ -169,11 +169,9 @@ main( argc, argv )
     struct pw_scheme	*pwsp, *cmppwsp;
     extern int		optind;
     char 		*cpwd = NULL;	/* candidate password for comparison */
-	char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE];
 	slapdFrontendConfig_t *slapdFrontendConfig =  NULL;
 
 	char *opts = "Hs:c:D:";
-	char *configdir = NULL;
     name = argv[ 0 ];
     pwsp = cmppwsp = NULL;
 
@@ -409,7 +407,7 @@ slapd_config(const char *configdir, const char *givenconfigfile)
 			rc= 1; /* OK */
 		}
 
-		slapi_ch_free((void **)&buf);
+		slapi_ch_free_string(&buf);
 	}
 
 	return rc;

+ 2 - 1
ldap/servers/slapd/tools/rsearch/infadd.c

@@ -344,11 +344,12 @@ int main(int argc, char **argv)
         }
         if (lmtCount && ntotal >= lmtCount) {
             if (!quiet) {
+                tmpv = (double)ntotal*1000.0/(counter*sampleInterval);
                 fprintf(stdout,
                   "Total added records: %d, Average rate: %7.2f/thrd, "
                   "%6.2f/sec = %6.4fmsec/op\n",
                   ntotal, (double)ntotal/(double)numThreads,
-                  (tmpv = (double)ntotal*1000.0/(counter*sampleInterval)),
+                  tmpv,
                   (double)1000.0/tmpv);
             }
             exit(1);

+ 2 - 2
ldap/servers/slapd/tools/rsearch/rsearch.c

@@ -501,12 +501,12 @@ int main(int argc, char** argv)
 	    exit(0);
 	}
 	if (timeLimit && (lifeTime >= timeLimit)) {
-	    double tmpv;
+	    double tmpv = (val + sumVal)/counter;
 	    if (verbose)
 		printf("%d sec >= %d\n", lifeTime, timeLimit);
 	    printf("Final Average rate: "
 		            "%6.2f/sec = %6.4fmsec/op, total:%6u\n",
-			    (tmpv = (val + sumVal)/counter),
+			    tmpv,
 			    (double)1000.0/tmpv,
 			    total);
 	    exit(0);

+ 1 - 1
ldap/servers/slapd/tools/rsearch/searchthread.c

@@ -501,7 +501,7 @@ void search_start(void *v)
 {
     SearchThread *st = (SearchThread *)v;
     PRIntervalTime timer;
-    int notBound = 1, res, searches = 0;
+    int notBound = 1, res = LDAP_SUCCESS, searches = 0;
     PRUint32 span;
 
     st->alive = 1;

+ 2 - 2
ldap/servers/slapd/uuid.c

@@ -361,8 +361,8 @@ static int uuid_create_st(guid_t *uuid)
 /* uuid_create -- multithreaded generation */
 static int uuid_create_mt(guid_t *uuid) 
 {
-    uuid_time_t timestamp;
-	unsigned16 clock_seq;
+    uuid_time_t timestamp = 0;
+	unsigned16 clock_seq = 0;
 
 	/* just bumps time sequence number. the actual
        time calls are made by a uuid_update_state */

+ 20 - 0
ldap/servers/snmp/ldap-agent.h

@@ -47,7 +47,27 @@
 extern          "C" {
 #endif
 
+/* net-snmp-config.h defines
+   all of these unconditionally - so we undefine
+   them here to make the compiler warnings shut up
+   hopefully we don't need the real versions
+   of these, but then with no warnings the compiler
+   will just silently redefine them to the wrong
+   ones anyway
+   Then undefine them after the include so that
+   our own local defines will take effect
+*/
+#undef PACKAGE_BUGREPORT
+#undef PACKAGE_NAME
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+#undef PACKAGE_VERSION
 #include <net-snmp/net-snmp-config.h>
+#undef PACKAGE_BUGREPORT
+#undef PACKAGE_NAME
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+#undef PACKAGE_VERSION
 #include <net-snmp/net-snmp-includes.h>
 #include <net-snmp/agent/net-snmp-agent-includes.h>
 #include <net-snmp/library/snmp_assert.h>

+ 6 - 2
lib/ldaputil/certmap.c

@@ -55,6 +55,7 @@
 
 #include <key.h>
 #include <cert.h>
+#define DEFINE_LDAPU_STRINGS 1
 #include <ldaputil/certmap.h>
 #include <ldaputil/ldapauth.h>
 #include <ldaputil/errors.h>
@@ -300,7 +301,8 @@ static int ldapu_list_print (LDAPUList_t *list, LDAPUListNodeFn_t print_fn,
     int rv;
 
     while(node) {
-	rv = (int)(*print_fn)(node->info, pinfo);
+	uintptr_t retval = (uintptr_t)(*print_fn)(node->info, pinfo);
+	rv = (int)retval;
 	if (rv != LDAPU_SUCCESS) return rv;
 	node = node->next;
     }
@@ -1691,6 +1693,7 @@ NSAPI_PUBLIC int ldapu_certinfo_save (const char *fname,
     char *ptr;
     int eof;
     int rv;
+    uintptr_t retval;
     LDAPUPrintInfo_t pinfo;
     
 #ifdef XP_WIN32
@@ -1730,7 +1733,8 @@ NSAPI_PUBLIC int ldapu_certinfo_save (const char *fname,
     pinfo.fp = tfp;
     pinfo.arg = default_certmap_info->issuerName;
 
-    rv = (int)ldapu_certinfo_print (default_certmap_info, &pinfo);
+    retval = (uintptr_t)ldapu_certinfo_print (default_certmap_info, &pinfo);
+    rv = (int)retval;
 
     if (rv != LDAPU_SUCCESS) {
 	fclose(tfp);

+ 1 - 0
lib/ldaputil/ldapauth.c

@@ -53,6 +53,7 @@
 #include <ldap.h>
 #include <prprf.h>
 
+#define DEFINE_LDAPU_STRINGS 1
 #include <ldaputil/certmap.h>
 #include <ldaputil/errors.h>
 #include <ldaputil/ldapauth.h>

+ 3 - 0
lib/ldaputil/ldapdb.c

@@ -171,7 +171,10 @@ ldapu_gethostbyaddr( const char *addr, int length, int type,
 	LDAPHostEnt *result, char *buffer, int buflen, int *statusp,
 	void *extradata )
 {
+    /* old code did this which was clearly wrong:
     return( (LDAPHostEnt *)PR_GetError() );
+    which leads me to believe this is not used */
+    return( NULL );
 }
 #endif /* LDAP_OPT_DNS_FN_PTRS */
 

+ 1 - 1
lib/libaccess/aclerror.cpp

@@ -100,7 +100,7 @@ char * ACL_Program = "NSACL";               /* ACL facility name */
 void aclErrorFmt(NSErr_t * errp, char * msgbuf, int maxlen, int maxdepth)
 {
     NSEFrame_t * efp;		/* error frame pointer */
-    int len;			/* length of error message text */
+    int len = 0;			/* length of error message text */
     int depth = 0;		/* current depth */
 
     msgbuf[0] = 0;

+ 1 - 1
lib/libaccess/acltools.cpp

@@ -3060,7 +3060,7 @@ ACL_FileGetNameList(NSErr_t *errp, char * filename, char ***name_list)
 
 	const int block_size = 50;
 	int  rv, list_size, list_index;
-	char ** local_list;
+	char ** local_list = NULL;
 	char * block ;
 	char * name;
 	char * next;

+ 2 - 2
lib/libaccess/lasdns.cpp

@@ -140,7 +140,7 @@ LASDnsBuild(NSErr_t *errp, char *attr_pattern, LASDnsContext_t *context, int ali
     size_t	delimiter;    	/* length of valid token	*/
     char	token[256];    	/* max length dns name		*/
     int		i;
-    int		ipcnt;
+    int		ipcnt = 0;
     char	**p;
     unsigned long	*ipaddrs=0;
     pool_handle_t *pool;
@@ -347,7 +347,7 @@ int LASDnsEval(NSErr_t *errp, char *attr_name, CmpOp_t comparator,
     int			result;
     int			aliasflg;
     char		*my_dns;
-    LASDnsContext_t 	*context;
+    LASDnsContext_t 	*context = NULL;
     int			rv;
 
     *cachable = ACL_INDEF_CACHABLE;

+ 2 - 2
lib/libaccess/lasip.cpp

@@ -340,7 +340,7 @@ LASIpAddPattern(NSErr_t *errp, int netmask, int pattern, LASIpTree_t **treetop)
     int        stopbit;    /* Don't care after this point    */
     int        curbit;        /* current bit we're working on    */
     int        curval;        /* value of pattern[curbit]    */
-    LASIpTree_t    *curptr;    /* pointer to the current node    */
+    LASIpTree_t    *curptr = NULL;    /* pointer to the current node    */
     LASIpTree_t    *newptr;
 
     /* stop at the first 1 in the netmask from low to high         */
@@ -448,7 +448,7 @@ int LASIpEval(NSErr_t *errp, char *attr_name, CmpOp_t comparator,
     IPAddr_t           ip;
     int                retcode;
     LASIpTree_t        *node;
-    LASIpContext_t     *context;
+    LASIpContext_t     *context = NULL;
     int		       rv;
     char	       ip_str[124];
 

+ 1 - 1
lib/libaccess/ldapacl.cpp

@@ -762,7 +762,7 @@ NSAPI_PUBLIC int acl_user_exists (const char *user, const char *userdn,
     PList_t resource = 0;
     PList_t auth_info = 0;
     PList_t global_auth = NULL;
-    int rv;
+    int rv = 0;
 
     /* Check if the userdn is available in the usr_cache */
     if (acl_usr_cache_enabled() && userdn) {

+ 2 - 2
lib/libaccess/oneeval.cpp

@@ -344,7 +344,7 @@ ACLEvalBuildContext(
     ACLHandle_t        *acl;
     ACLExprHandle_t    *ace;
     int                ace_cnt = -1;
-    ACLAceEntry_t      *acelast, *new_ace;
+    ACLAceEntry_t      *acelast = NULL, *new_ace;
     ACLAceNumEntry_t   *entry, *temp_entry;
     char               **argp;
     ACLListCache_t     *cache;
@@ -635,7 +635,7 @@ ACL_INTEvalTestRights(
     int i, j, right_num, delta;
     ACLCachable_t ace_cachable;
     int result;
-    int absolute;
+    int absolute = 0;
     int skipflag;
     int g_num;    /* index into the generic rights array.  */
     char **g_rights;

+ 0 - 10
lib/libsi18n/getstrmem.h

@@ -53,7 +53,6 @@ static char emptyString[] = "";
 #define NUM_BUCKETS 32 /* must be a power of 2 */
 
 /* strings in library libadmin */
-static char* libadminid[] = {"$DBT: libadmin in memory  v1 $"};
 static char* libadmin[] = {
   "",
   "  Help  ",
@@ -89,7 +88,6 @@ static struct DATABIN bucket5[] = {
   {emptyString,NULL,0} };
 
 /* strings in library userforms */
-static char* userformsid[] = {"$DBT: userforms in memory  v1 $"};
 static char* userforms[] = {
   "",
   "Error: could not open servers list file.<p>\n",
@@ -113,7 +111,6 @@ static struct DATABIN bucket8[] = {
   {emptyString,NULL,0} };
 
 /* strings in library libaccess */
-static char* libaccessid[] = {"$DBT: libaccess in memory  v1 $"};
 static char* libaccess[] = {
   "",
   "basic-ncsa",
@@ -274,7 +271,6 @@ static struct DATABIN bucket10[] = {
   {emptyString,NULL,0} };
 
 /* strings in library frame */
-static char* frameid[] = {"$DBT: frame in memory  v1 $"};
 static char* frame[] = {
   "",
   "<TITLE>Not Found</TITLE><H1>Not Found</H1> The requested object does not exist on this server. The link you followed is either outdated, inaccurate, or the server has been instructed not to let you have it. ",
@@ -465,7 +461,6 @@ static struct DATABIN bucket17[] = {
   {emptyString,NULL,0} };
 
 /* strings in library admserv */
-static char* admservid[] = {"$DBT: admserv in memory  v1 $"};
 static char* admserv[] = {
   "",
   "Unauthorized host",
@@ -477,7 +472,6 @@ static char* admserv[] = {
   emptyString };
 
 /* strings in library libir */
-static char* libirid[] = {"$DBT: libadmin in memory  v1 $"};
 static char* libir[] = {
   "",
   "An I/O error occurred before all form data could be read.",
@@ -494,7 +488,6 @@ static struct DATABIN bucket19[] = {
   {emptyString,NULL,0} };
 
 /* strings in library httpdaemon */
-static char* httpdaemonid[] = {"$DBT: httpdaemon in memory  v1 $"};
 static char* httpdaemon[] = {
   "",
   "Error in ConvertThreadToFiber",
@@ -540,7 +533,6 @@ static struct DATABIN bucket20[] = {
   {emptyString,NULL,0} };
 
 /* strings in library dsgw */
-static char* dsgwid[] = {"$DBT: dsgw in memory  v1 $"};
 static char* dsgw[] = {
   "",
   "Unknown HTTP request method",
@@ -856,7 +848,6 @@ static struct DATABIN bucket26[] = {
   {emptyString,NULL,0} };
 
 /* strings in library base */
-static char* baseid[] = {"$DBT: base in memory  v1 $"};
 static char* base[] = {
   "",
   "insufficient memory to create hash table",
@@ -1072,7 +1063,6 @@ static struct DATABIN bucket27[] = {
   {emptyString,NULL,0} };
 
 /* strings in library cgiadmin */
-static char* cgiadminid[] = {"$DBT: cgiadmin in memory  v1 $"};
 static char* cgiadmin[] = {
   "",
   "Missing REQUEST_METHOD",

+ 4 - 4
lib/libsi18n/gsslapd.h

@@ -54,10 +54,10 @@
 #undef LIBRARY_NAME
 
 static RESOURCE_GLOBAL allxpstr[] = {
-  base,
-  libaccess,
-  libadmin,
-  0
+  {base},
+  {libaccess},
+  {libadmin},
+  {0}
 };
 
 #endif /* ifdef RESOURCE_STR */