Jelajahi Sumber

Resolves: bug 454030
Bug Description: Need to address 64-bit compiler warnings
Fix Description: As it turns out, there is no portable format specifier
for size_t that works on all of our supported platforms. Afaict, %lu should
work everywhere. C99 uses the "z" specifier, but alas not all of the compilers
we use support C99 and/or "z".
Platforms tested: RHEL5, Solaris
Flag Day: no
Doc impact: no

Rich Megginson 17 tahun lalu
induk
melakukan
40caa26af8

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

@@ -97,13 +97,6 @@
 #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)    \
 {                                                                              \
@@ -929,7 +922,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, "%" PRIuPTR, procpages);
+                    sscanf(s+7, "%lu", procpages);
                     break;
                 }
             }

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

@@ -49,13 +49,6 @@
 #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;
@@ -674,7 +667,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 %" PRIuPTR " files...",
+	import_log_notice(job, "Beginning %d-way merge of up to %lu files...",
 			  passes, job->number_indexers);
     }
 

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

@@ -49,13 +49,6 @@
  * 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"
@@ -579,7 +572,7 @@ void import_producer(void *param)
                     escape_string(slapi_entry_get_dn(e), ebuf),
                     curr_lineno, curr_filename);
             import_log_notice(job, "REASON: entry too large (%ld bytes) for "
-                    "the buffer size (%" PRIuPTR " bytes)", newesize, job->fifo.bsize);
+                    "the buffer size (%lu bytes)", newesize, job->fifo.bsize);
             backentry_free(&ep);
             job->skipped++;
             continue;
@@ -812,8 +805,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 (%" PRIuPTR " bytes) for "
-                    "the buffer size (%" PRIuPTR " bytes)", newesize, job->fifo.bsize);
+            import_log_notice(job, "REASON: entry too large (%lu bytes) for "
+                    "the buffer size (%lu bytes)", newesize, job->fifo.bsize);
             backentry_free(&ep);
             job->skipped++;
             continue;
@@ -1606,8 +1599,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 (%" PRIuPTR " bytes) for "
-                    "the import buffer size (%" PRIuPTR " bytes).   Try increasing nsslapd-cachememsize.", newesize, job->fifo.bsize);
+        import_log_notice(job, "REASON: entry too large (%lu bytes) for "
+                    "the import buffer size (%lu 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);

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

@@ -46,13 +46,6 @@
  * 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"
 #include "import.h"
@@ -1155,7 +1148,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 %" PRIuPTR, 
+                                "Index buffering enabled with bucket size %lu", 
                                 job->job_index_buffer_suggestion);
 
         job->worker_list = producer;
@@ -1318,7 +1311,7 @@ error:
         if (job->not_here_skipped)
         {
                 if (job->skipped)
-                        import_log_notice(job, "Import complete.  Processed %" PRIuPTR " entries "
+                        import_log_notice(job, "Import complete.  Processed %lu entries "
                               "(%d bad entries were skipped, "
                               "%d entries were skipped because they don't "
                                                           "belong to this database) in %d seconds. "
@@ -1326,7 +1319,7 @@ error:
                               job->skipped, job->not_here_skipped,
                                                           seconds_to_import, entries_per_second);
                 else
-                        import_log_notice(job, "Import complete.  Processed %" PRIuPTR " entries "
+                        import_log_notice(job, "Import complete.  Processed %lu entries "
                               "(%d entries were skipped because they don't "
                                                           "belong to this database) "
                               "in %d seconds. (%.2f entries/sec)",
@@ -1336,13 +1329,13 @@ error:
         else
         {
                 if (job->skipped)
-                        import_log_notice(job, "Import complete.  Processed %" PRIuPTR " entries "
+                        import_log_notice(job, "Import complete.  Processed %lu 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 %" PRIuPTR " entries "
+                        import_log_notice(job, "Import complete.  Processed %lu entries "
                               "in %d seconds. (%.2f entries/sec)",
                               entries_processed, seconds_to_import,
                               entries_per_second);

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

@@ -42,13 +42,6 @@
 
 /* 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"
 
@@ -1426,7 +1419,7 @@ void ldbm_config_get(void *arg, config_info *config, char *buf)
         break;
     case CONFIG_TYPE_SIZE_T:
         val = (size_t) config->config_get_fn(arg);
-        sprintf(buf, "%" PRIuPTR, val);
+        sprintf(buf, "%lu", val);
         break;
     case CONFIG_TYPE_STRING:
         /* Remember the get function for strings returns memory

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

@@ -47,13 +47,6 @@
  * 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"
@@ -327,7 +320,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,"%" PRIuPTR,sub_count);
+    sprintf(value_buffer,"%lu",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);

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

@@ -42,13 +42,6 @@
 
 /* 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>
@@ -124,9 +117,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, "%" PRIuPTR, size);
+    sprintf(buf, "%lu", size);
     MSET("currentEntryCacheSize");
-    sprintf(buf, "%" PRIuPTR, maxsize);
+    sprintf(buf, "%lu", maxsize);
     MSET("maxEntryCacheSize");
     sprintf(buf, "%ld", nentries);
     MSET("currentEntryCacheCount");

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

@@ -44,13 +44,6 @@
 
 #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";
 
@@ -137,7 +130,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,"%" PRIuPTR, current_sub_count);
+        	sprintf(value_buffer,"%lu", 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 */

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

@@ -72,13 +72,6 @@
 #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		*/
 
@@ -612,7 +605,7 @@ dse_updateNumSubordinates(Slapi_Entry *entry, int op)
         struct berval val;
         vals[0] = &val;
         vals[1] = NULL;
-        sprintf(value_buffer,"%" PRIuPTR,current_sub_count);
+        sprintf(value_buffer,"%lu",current_sub_count);
         val.bv_val = value_buffer;
         val.bv_len = strlen (val.bv_val);
         switch(mod_op)