[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm back-ldbm.h, 1.15, 1.16 dblayer.c, 1.27, 1.28 dbverify.c, 1.2, 1.3 import-merge.c, 1.8, 1.9 import-threads.c, 1.15, 1.16 import.c, 1.11, 1.12 import.h, 1.8, 1.9 ldbm_attr.c, 1.10, 1.11 ldbm_config.c, 1.14, 1.15 ldbm_instance_config.c, 1.10, 1.11 ldbm_modify.c, 1.6, 1.7 ldif2ldbm.c, 1.16, 1.17 monitor.c, 1.7, 1.8 parents.c, 1.5, 1.6 perfctrs.c, 1.9, 1.10

Richard Allen Megginson rmeggins at fedoraproject.org
Wed Oct 8 17:29:06 UTC 2008


Author: rmeggins

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv26931/ldapserver/ldap/servers/slapd/back-ldbm

Modified Files:
	back-ldbm.h dblayer.c dbverify.c import-merge.c 
	import-threads.c import.c import.h ldbm_attr.c ldbm_config.c 
	ldbm_instance_config.c ldbm_modify.c ldif2ldbm.c monitor.c 
	parents.c perfctrs.c 
Log Message:
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



Index: back-ldbm.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/back-ldbm.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- back-ldbm.h	5 Aug 2008 21:03:42 -0000	1.15
+++ back-ldbm.h	8 Oct 2008 17:29:03 -0000	1.16
@@ -114,6 +114,15 @@
 #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"


Index: dblayer.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/dblayer.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- dblayer.c	3 Apr 2008 16:52:47 -0000	1.27
+++ dblayer.c	8 Oct 2008 17:29:03 -0000	1.28
@@ -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 @@
 
 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 @@
 
 void *
 dblayer_get_batch_transactions(void *arg) {
-  return (void *)trans_batch_limit;
+    return (void *)((uintptr_t)trans_batch_limit);
 }
 
 
@@ -465,25 +472,25 @@
 }
 
 
-/* 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 @@
                 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 @@
     {
         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 @@
                                                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 @@
         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;


Index: dbverify.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/dbverify.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- dbverify.c	18 Oct 2007 00:08:34 -0000	1.2
+++ dbverify.c	8 Oct 2008 17:29:03 -0000	1.3
@@ -50,7 +50,6 @@
     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 @@
           (direntry = PR_ReadDir(dirhandle, PR_SKIP_DOT | PR_SKIP_DOT_DOT)))
     {
         /* struct attrinfo *ai = NULL; */
-        char *p             = NULL;
         dbp = NULL;
 
         if (!direntry->name)


Index: import-merge.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import-merge.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- import-merge.c	2 Oct 2007 18:39:51 -0000	1.8
+++ import-merge.c	8 Oct 2008 17:29:03 -0000	1.9
@@ -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 @@
     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);
     }
 


Index: import-threads.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import-threads.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- import-threads.c	25 Jan 2008 00:59:00 -0000	1.15
+++ import-threads.c	8 Oct 2008 17:29:03 -0000	1.16
@@ -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 @@
                     "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 @@
             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 @@
     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 @@
         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 @@
 {
     struct ldbminfo *li;
     backend *be = NULL;
-    ImportJob *job;
+    ImportJob *job = NULL;
     PRThread *thread;
     int state;
 
@@ -1954,7 +1962,7 @@
 		
 		if (entry_filter != NULL) /* Single instance restoration */
 		{
-			if (!(int)strstr(estr, entry_filter))
+			if (NULL == strstr(estr, entry_filter))
 				continue;
 		}
 


Index: import.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- import.c	3 Apr 2008 16:52:47 -0000	1.11
+++ import.c	8 Oct 2008 17:29:03 -0000	1.12
@@ -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 @@
                 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 @@
         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 @@
                               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 @@
         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);


Index: import.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- import.h	10 Nov 2006 23:45:39 -0000	1.8
+++ import.h	8 Oct 2008 17:29:03 -0000	1.9
@@ -235,4 +235,3 @@
 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);


Index: ldbm_attr.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_attr.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ldbm_attr.c	15 Jul 2008 16:49:43 -0000	1.10
+++ ldbm_attr.c	8 Oct 2008 17:29:03 -0000	1.11
@@ -258,16 +258,16 @@
 							   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)) {


Index: ldbm_config.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_config.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ldbm_config.c	4 Dec 2007 00:50:19 -0000	1.14
+++ ldbm_config.c	8 Oct 2008 17:29:03 -0000	1.15
@@ -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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
     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 @@
 {
     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 @@
     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 @@
 {
     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 @@
     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 @@
 {
     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 @@
     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 @@
 {
     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 @@
     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 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 @@
 {
     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 @@
 {
     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 @@
 {
     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 @@
     
     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 @@
         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 @@
         }
         /* 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 @@
         } 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 @@
         } 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;
     }
     


Index: ldbm_instance_config.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ldbm_instance_config.c	4 Dec 2007 00:50:19 -0000	1.10
+++ ldbm_instance_config.c	8 Oct 2008 17:29:04 -0000	1.11
@@ -136,7 +136,7 @@
 {
     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 *inst = (ldbm_instance *)arg;
     
-    return (void *)inst->require_index;
+    return (void *)((uintptr_t)inst->require_index);
 }
 
 static int
@@ -219,6 +219,7 @@
 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 @@
          * 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 @@
         return LDAP_SUCCESS;
     }
 
-    inst->require_index = (int)value;
+    inst->require_index = (int)((uintptr_t)value);
 
     return LDAP_SUCCESS;
 }


Index: ldbm_modify.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_modify.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ldbm_modify.c	18 Oct 2007 22:40:18 -0000	1.6
+++ ldbm_modify.c	8 Oct 2008 17:29:04 -0000	1.7
@@ -578,10 +578,10 @@
 	 */
 	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 @@
 
 	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


Index: ldif2ldbm.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldif2ldbm.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ldif2ldbm.c	3 Apr 2008 16:52:47 -0000	1.16
+++ ldif2ldbm.c	8 Oct 2008 17:29:04 -0000	1.17
@@ -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 @@
 
 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 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 @@
                                 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 @@
     *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 @@
 
     /* 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 @@
      * 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 @@
     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 @@
         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);


Index: monitor.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/monitor.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- monitor.c	10 Nov 2006 23:45:39 -0000	1.7
+++ monitor.c	8 Oct 2008 17:29:04 -0000	1.8
@@ -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 @@
     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");


Index: parents.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/parents.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- parents.c	10 Nov 2006 23:45:39 -0000	1.5
+++ parents.c	8 Oct 2008 17:29:04 -0000	1.6
@@ -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 @@
 		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 */


Index: perfctrs.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/perfctrs.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- perfctrs.c	26 Sep 2007 17:32:41 -0000	1.9
+++ perfctrs.c	8 Oct 2008 17:29:04 -0000	1.10
@@ -296,7 +296,7 @@
 		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 @@
 		}
 		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 @@
 		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 @@
 		}
 		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);




More information about the Fedora-directory-commits mailing list