From 63336d20388efac24b5a051aa3134963ed310b29 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Jun 08 2018 19:08:58 +0000 Subject: Ticket 49746 - Segfault during replication startup on Arm device Bug Description: There was an inproper use of format strings and int types in agmt_update_maxcsn(). This was addressed in ticket 49618 in 1.4.0, along with other fixes for compiler warnings. Fix Description: Backport ticket 49618 to 1.3.8. https://pagure.io/389-ds-base/issue/49746 --- diff --git a/Makefile.am b/Makefile.am index 9a72aaf..5d570aa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1854,7 +1854,7 @@ ldap_agent_SOURCES = ldap/servers/snmp/main.c \ ldap/servers/snmp/ldap-agent.c \ ldap/servers/slapd/agtmmap.c -ldap_agent_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) @netsnmp_inc@ +ldap_agent_CPPFLAGS = $(AM_CPPFLAGS) $(DSPLUGIN_CPPFLAGS) @netsnmp_inc@ -fPIC ldap_agent_LDADD = $(LDAPSDK_LINK_NOTHR) $(SASL_LINK) $(NSS_LINK) $(NSPR_LINK) $(NETSNMP_LINK) $(THREADLIB) @@ -2273,7 +2273,7 @@ if HAVE_DOXYGEN doxyfile.stamp: cd $(srcdir); $(DOXYGEN) $(abs_top_builddir)/docs/slapi.doxy - rm $(abs_top_builddir)/man/man3/_* + rm -f $(abs_top_builddir)/man/man3/_* touch doxyfile.stamp # Add the docs to make all. diff --git a/ldap/servers/slapd/abandon.c b/ldap/servers/slapd/abandon.c index e2237e5..3f7bef0 100644 --- a/ldap/servers/slapd/abandon.c +++ b/ldap/servers/slapd/abandon.c @@ -148,7 +148,7 @@ do_abandon(Slapi_PBlock *pb) slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d ABANDON" " targetop=%d msgid=%d nentries=%d etime=%" PRId64 ".%010" PRId64 "\n", pb_conn->c_connid, pb_op->o_opid, o->o_opid, id, - o->o_results.r.r_search.nentries, o_hr_time_end.tv_sec, o_hr_time_end.tv_nsec); + o->o_results.r.r_search.nentries, (int64_t)o_hr_time_end.tv_sec, (int64_t)o_hr_time_end.tv_nsec); } PR_ExitMonitor(pb_conn->c_mutex); diff --git a/ldap/servers/slapd/back-ldbm/back-ldbm.h b/ldap/servers/slapd/back-ldbm/back-ldbm.h index d2b25a7..f13a42f 100644 --- a/ldap/servers/slapd/back-ldbm/back-ldbm.h +++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h @@ -359,10 +359,10 @@ struct backdn /* for the in-core cache of entries */ struct cache { - size_t c_maxsize; /* max size in bytes */ + uint64_t c_maxsize; /* max size in bytes */ Slapi_Counter *c_cursize; /* size in bytes */ - long c_maxentries; /* max entries allowed (-1: no limit) */ - long c_curentries; /* current # entries in cache */ + int64_t c_maxentries; /* max entries allowed (-1: no limit) */ + uint64_t c_curentries; /* current # entries in cache */ Hashtable *c_dntable; Hashtable *c_idtable; #ifdef UUIDCACHE_ON @@ -552,7 +552,7 @@ struct ldbminfo char *li_directory; int li_reslimit_lookthrough_handle; size_t li_dbcachesize; - int li_dblock; + uint64_t li_dblock; int li_dbncache; int li_import_cache_autosize; /* % of free memory to use * for the import caches @@ -588,7 +588,7 @@ struct ldbminfo */ char *li_new_directory; size_t li_new_dbcachesize; - int li_new_dblock; + uint64_t li_new_dblock; int li_new_dbncache; diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c index ee20dc3..d84c630 100644 --- a/ldap/servers/slapd/back-ldbm/cache.c +++ b/ldap/servers/slapd/back-ldbm/cache.c @@ -183,7 +183,7 @@ new_hash(u_long size, u_long offset, HashFn hfn, HashTestFn tfn) * already there (filled into 'alt' if 'alt' is not NULL) */ int -add_hash(Hashtable *ht, void *key, size_t keylen, void *entry, void **alt) +add_hash(Hashtable *ht, void *key, uint32_t keylen, void *entry, void **alt) { u_long val, slot; void *e; @@ -209,7 +209,7 @@ add_hash(Hashtable *ht, void *key, size_t keylen, void *entry, void **alt) /* returns 1 if the item was found, and puts a ptr to it in 'entry' */ int -find_hash(Hashtable *ht, const void *key, size_t keylen, void **entry) +find_hash(Hashtable *ht, const void *key, uint32_t keylen, void **entry) { u_long val, slot; void *e; @@ -231,7 +231,7 @@ find_hash(Hashtable *ht, const void *key, size_t keylen, void **entry) /* returns 1 if the item was found and removed */ int -remove_hash(Hashtable *ht, const void *key, size_t keylen) +remove_hash(Hashtable *ht, const void *key, uint32_t keylen) { u_long val, slot; void *e, *laste = NULL; @@ -494,7 +494,7 @@ cache_make_hashes(struct cache *cache, int type) /* initialize the cache */ int -cache_init(struct cache *cache, size_t maxsize, long maxentries, int type) +cache_init(struct cache *cache, uint64_t maxsize, long maxentries, int type) { slapi_log_err(SLAPI_LOG_TRACE, "cache_init", "-->\n"); cache->c_maxsize = maxsize; @@ -598,7 +598,7 @@ entrycache_clear_int(struct cache *cache) cache->c_maxsize = size; if (cache->c_curentries > 0) { slapi_log_err(SLAPI_LOG_WARNING, - "entrycache_clear_int", "There are still %ld entries " + "entrycache_clear_int", "There are still %" PRIu64 " entries " "in the entry cache.\n", cache->c_curentries); #ifdef LDAP_CACHE_DEBUG @@ -648,7 +648,7 @@ cache_destroy_please(struct cache *cache, int type) } void -cache_set_max_size(struct cache *cache, size_t bytes, int type) +cache_set_max_size(struct cache *cache, uint64_t bytes, int type) { if (CACHE_TYPE_ENTRY == type) { entrycache_set_max_size(cache, bytes); @@ -773,7 +773,7 @@ cache_entry_size(struct backentry *e) * these u_long *'s to a struct */ void -cache_get_stats(struct cache *cache, PRUint64 *hits, PRUint64 *tries, long *nentries, long *maxentries, size_t *size, size_t *maxsize) +cache_get_stats(struct cache *cache, uint64_t *hits, uint64_t *tries, uint64_t *nentries, int64_t *maxentries, uint64_t *size, uint64_t *maxsize) { cache_lock(cache); if (hits) @@ -1580,7 +1580,7 @@ dncache_clear_int(struct cache *cache) cache->c_maxsize = size; if (cache->c_curentries > 0) { slapi_log_err(SLAPI_LOG_WARNING, - "dncache_clear_int", "There are still %ld dn's " + "dncache_clear_int", "There are still %" PRIu64 " dn's " "in the dn cache. :/\n", cache->c_curentries); } diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c index 5d870e3..0956998 100644 --- a/ldap/servers/slapd/back-ldbm/dblayer.c +++ b/ldap/servers/slapd/back-ldbm/dblayer.c @@ -822,10 +822,10 @@ dblayer_dump_config_tracing(dblayer_private *priv) slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "dbhome_directory=%s\n", priv->dblayer_dbhome_directory); } slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "trickle_percentage=%d\n", priv->dblayer_trickle_percentage); - slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "page_size=%lu\n", priv->dblayer_page_size); - slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "index_page_size=%lu\n", priv->dblayer_index_page_size); - slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "cachesize=%lu\n", priv->dblayer_cachesize); - slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "previous_cachesize=%lu\n", priv->dblayer_previous_cachesize); + slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "page_size=%" PRIu32 "\n", priv->dblayer_page_size); + slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "index_page_size=%" PRIu32 "\n", priv->dblayer_index_page_size); + slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "cachesize=%" PRIu64 "\n", priv->dblayer_cachesize); + slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "previous_cachesize=%" PRIu64 "\n", priv->dblayer_previous_cachesize); slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "ncache=%d\n", priv->dblayer_ncache); slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "previous_ncache=%d\n", priv->dblayer_previous_ncache); slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "recovery_required=%d\n", priv->dblayer_recovery_required); @@ -834,8 +834,8 @@ dblayer_dump_config_tracing(dblayer_private *priv) slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "transaction_batch_val=%d\n", trans_batch_limit); slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "circular_logging=%d\n", priv->dblayer_circular_logging); slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "idl_divisor=%d\n", priv->dblayer_idl_divisor); - slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "logfile_size=%lu\n", priv->dblayer_logfile_size); - slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "logbuf_size=%lu\n", priv->dblayer_logbuf_size); + slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "logfile_size=%" PRIu64 "\n", priv->dblayer_logfile_size); + slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "logbuf_size=%" PRIu64 "\n", priv->dblayer_logbuf_size); slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "file_mode=%d\n", priv->dblayer_file_mode); slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "cache_config=%d\n", priv->dblayer_cache_config); slapi_log_err(SLAPI_LOG_TRACE, "dblayer_dump_config_tracing", "lib_version=%d\n", priv->dblayer_lib_version); @@ -1203,8 +1203,8 @@ no_diskspace(struct ldbminfo *li, int dbenv_flags) /* Check if we have enough space */ if (fsiz < expected_siz) { slapi_log_err(SLAPI_LOG_ERR, - "no_diskspace", "No enough space left on device (%s) (%lu bytes); " - "at least %lu bytes space is needed for db region files\n", + "no_diskspace", "No enough space left on device (%s) (%" PRIu64 " bytes); " + "at least %" PRIu64 " bytes space is needed for db region files\n", region_dir, fsiz, expected_siz); return 1; } @@ -1406,7 +1406,7 @@ dblayer_start(struct ldbminfo *li, int dbmode) (priv->dblayer_lock_config != priv->dblayer_previous_lock_config)) && !(dbmode & (DBLAYER_ARCHIVE_MODE | DBLAYER_EXPORT_MODE))) { if (priv->dblayer_cachesize != priv->dblayer_previous_cachesize) { - slapi_log_err(SLAPI_LOG_INFO, "dblayer_start", "Resizing db cache size: %lu -> %lu\n", + slapi_log_err(SLAPI_LOG_INFO, "dblayer_start", "Resizing db cache size: %" PRIu64 " -> %" PRIu64 "\n", priv->dblayer_previous_cachesize, priv->dblayer_cachesize); } if (priv->dblayer_ncache != priv->dblayer_previous_ncache) { @@ -1448,7 +1448,8 @@ dblayer_start(struct ldbminfo *li, int dbmode) if (priv->dblayer_logbuf_size >= 32768) { pEnv->dblayer_DB_ENV->set_lg_bsize(pEnv->dblayer_DB_ENV, priv->dblayer_logbuf_size); } else { - slapi_log_err(SLAPI_LOG_NOTICE, "dblayer_start", "Using default value for log bufsize because configured value (%lu) is too small.\n", + slapi_log_err(SLAPI_LOG_NOTICE, "dblayer_start", + "Using default value for log bufsize because configured value (%" PRIu64 ") is too small.\n", priv->dblayer_logbuf_size); } } @@ -1499,7 +1500,7 @@ dblayer_start(struct ldbminfo *li, int dbmode) */ slapi_log_err(SLAPI_LOG_CRIT, "dblayer_start", "mmap in opening database environment (recovery mode) " - "failed trying to allocate %lu bytes. (OS err %d - %s)\n", + "failed trying to allocate %" PRIu64 " bytes. (OS err %d - %s)\n", li->li_dbcachesize, return_value, dblayer_strerror(return_value)); dblayer_free_env(&priv->dblayer_env); priv->dblayer_env = CATASTROPHIC; @@ -1509,7 +1510,7 @@ dblayer_start(struct ldbminfo *li, int dbmode) return_value, dblayer_strerror(return_value)); slapi_log_err(SLAPI_LOG_CRIT, "dblayer_start", "Please make sure there is enough disk space for " - "dbcache (%lu bytes) and db region files\n", + "dbcache (%" PRIu64 " bytes) and db region files\n", li->li_dbcachesize); } return return_value; @@ -1588,7 +1589,7 @@ dblayer_start(struct ldbminfo *li, int dbmode) */ slapi_log_err(SLAPI_LOG_CRIT, "dblayer_start", "mmap in opening database environment " - "failed trying to allocate %lu bytes. (OS err %d - %s)\n", + "failed trying to allocate %" PRIu64 " bytes. (OS err %d - %s)\n", li->li_dbcachesize, return_value, dblayer_strerror(return_value)); dblayer_free_env(&priv->dblayer_env); priv->dblayer_env = CATASTROPHIC; @@ -1949,7 +1950,7 @@ dblayer_instance_start(backend *be, int mode) (priv->dblayer_page_size == 0) ? DBLAYER_PAGESIZE : priv->dblayer_page_size); if (0 != return_value) { slapi_log_err(SLAPI_LOG_ERR, - "dblayer_instance_start", "dbp->set_pagesize(%lu or %lu) failed %d\n", + "dblayer_instance_start", "dbp->set_pagesize(%" PRIu32 " or %" PRIu32 ") failed %d\n", priv->dblayer_page_size, DBLAYER_PAGESIZE, return_value); goto out; @@ -1976,7 +1977,7 @@ dblayer_instance_start(backend *be, int mode) (priv->dblayer_page_size == 0) ? DBLAYER_PAGESIZE : priv->dblayer_page_size); if (0 != return_value) { slapi_log_err(SLAPI_LOG_ERR, - "dblayer_instance_start", "dbp->set_pagesize(%lu or %lu) failed %d\n", + "dblayer_instance_start", "dbp->set_pagesize(%" PRIu32 " or %" PRIu32 ") failed %d\n", priv->dblayer_page_size, DBLAYER_PAGESIZE, return_value); goto out; @@ -2223,7 +2224,7 @@ dblayer_get_aux_id2entry_ext(backend *be, DB **ppDB, DB_ENV **ppEnv, char **path rval = dbp->set_pagesize(dbp, (priv->dblayer_page_size == 0) ? DBLAYER_PAGESIZE : priv->dblayer_page_size); if (rval) { slapi_log_err(SLAPI_LOG_ERR, - "dblayer_get_aux_id2entry_ext", "dbp->set_pagesize(%lu or %lu) failed %d\n", + "dblayer_get_aux_id2entry_ext", "dbp->set_pagesize(%" PRIu32 " or %" PRIu32 ") failed %d\n", priv->dblayer_page_size, DBLAYER_PAGESIZE, rval); goto err; } @@ -3495,11 +3496,11 @@ dblayer_txn_abort_all(struct ldbminfo *li, back_txn *txn) return (dblayer_txn_abort_ext(li, txn, PR_TRUE)); } -size_t +uint32_t dblayer_get_optimal_block_size(struct ldbminfo *li) { dblayer_private *priv = NULL; - size_t page_size = 0; + uint32_t page_size = 0; PR_ASSERT(NULL != li); @@ -3650,7 +3651,7 @@ typedef struct txn_test_iter DBC *cur; uint64_t cnt; const char *attr; - u_int32_t flags; + uint32_t flags; backend *be; } txn_test_iter; @@ -3658,14 +3659,14 @@ typedef struct txn_test_cfg { PRUint32 hold_msec; PRUint32 loop_msec; - u_int32_t flags; + uint32_t flags; int use_txn; char **indexes; int verbose; } txn_test_cfg; static txn_test_iter * -new_txn_test_iter(DB *db, const char *attr, backend *be, u_int32_t flags) +new_txn_test_iter(DB *db, const char *attr, backend *be, uint32_t flags) { txn_test_iter *tti = (txn_test_iter *)slapi_ch_malloc(sizeof(txn_test_iter)); tti->db = db; @@ -3702,7 +3703,7 @@ free_txn_test_iter(txn_test_iter *tti) } static void -free_ttilist(txn_test_iter ***ttilist, size_t *tticnt) +free_ttilist(txn_test_iter ***ttilist, uint32_t *tticnt) { if (!ttilist || !*ttilist || !**ttilist) { return; @@ -3715,7 +3716,7 @@ free_ttilist(txn_test_iter ***ttilist, size_t *tticnt) } static void -init_ttilist(txn_test_iter **ttilist, size_t tticnt) +init_ttilist(txn_test_iter **ttilist, uint32_t tticnt) { if (!ttilist || !*ttilist) { return; @@ -3727,7 +3728,7 @@ init_ttilist(txn_test_iter **ttilist, size_t tticnt) } static void -print_ttilist(txn_test_iter **ttilist, size_t tticnt) +print_ttilist(txn_test_iter **ttilist, uint32_t tticnt) { while (tticnt > 0) { tticnt--; @@ -3772,7 +3773,7 @@ txn_test_threadmain(void *param) Object *inst_obj; int rc = 0; txn_test_iter **ttilist = NULL; - uint64_t tticnt = 0; + uint32_t tticnt = 0; DB_TXN *txn = NULL; txn_test_cfg cfg = {0}; uint64_t counter = 0; @@ -3903,7 +3904,7 @@ wait_for_init: /* phase 1 - open a cursor to each db */ if (cfg.verbose) { slapi_log_err(SLAPI_LOG_ERR, - "txn_test_threadmain", "Starting [%lu] indexes\n", tticnt); + "txn_test_threadmain", "Starting [%" PRIu32 "] indexes\n", tticnt); } for (ii = 0; ii < tticnt; ++ii) { txn_test_iter *tti = ttilist[ii]; @@ -4015,7 +4016,7 @@ wait_for_init: init_ttilist(ttilist, tticnt); if (cfg.verbose) { slapi_log_err(SLAPI_LOG_ERR, - "txn_test_threadmain", "Finished [%lu] indexes [%lu] records\n", tticnt, cnt); + "txn_test_threadmain", "Finished [%" PRIu32 "] indexes [%" PRIu64 "] records\n", tticnt, cnt); } TXN_TEST_LOOP_WAIT(cfg.loop_msec); } else { @@ -4612,10 +4613,10 @@ db_atoi(char *str, int *err) return db_atol(str, err); } -unsigned long +uint32_t db_strtoul(const char *str, int *err) { - unsigned long val = 0, result, multiplier = 1; + uint32_t val = 0, result, multiplier = 1; char *p; errno = 0; @@ -4678,6 +4679,72 @@ db_strtoul(const char *str, int *err) return result; } +uint64_t +db_strtoull(const char *str, int *err) +{ + uint64_t val = 0, result, multiplier = 1; + char *p; + errno = 0; + + /* + * manpage of strtoull: Negative values are considered valid input and + * are silently converted to the equivalent unsigned long int value. + */ + /* We don't want to make it happen. */ + for (p = (char *)str; p && *p && (*p == ' ' || *p == '\t'); p++) + ; + if ('-' == *p) { + if (err) { + *err = ERANGE; + } + return val; + } + val = strtoull(str, &p, 10); + if (errno != 0) { + if (err) { + *err = errno; + } + return val; + } + + switch (*p) { + case 'g': + case 'G': + multiplier *= 1024 * 1024 * 1024; + break; + case 'm': + case 'M': + multiplier *= 1024 * 1024; + break; + case 'k': + case 'K': + multiplier *= 1024; + p++; + if (*p == 'b' || *p == 'B') { + p++; + } + if (err) { + /* extra chars? */ + *err = (*p != '\0') ? EINVAL : 0; + } + break; + case '\0': + if (err) { + *err = 0; + } + break; + default: + if (err) { + *err = EINVAL; + } + return val; + } + + result = val * multiplier; + + return result; +} + /* functions called directly by the plugin interface from the front-end */ /* Begin transaction */ @@ -7200,9 +7267,9 @@ ldbm_back_get_info(Slapi_Backend *be, int cmd, void **info) if (li) { dblayer_private *prv = (dblayer_private *)li->li_dblayer_private; if (prv && prv->dblayer_index_page_size) { - *(size_t *)info = prv->dblayer_index_page_size; + *(uint32_t *)info = prv->dblayer_index_page_size; } else { - *(size_t *)info = DBLAYER_INDEX_PAGESIZE; + *(uint32_t *)info = DBLAYER_INDEX_PAGESIZE; } rc = 0; } diff --git a/ldap/servers/slapd/back-ldbm/dblayer.h b/ldap/servers/slapd/back-ldbm/dblayer.h index 6fe28d1..aa0306a 100644 --- a/ldap/servers/slapd/back-ldbm/dblayer.h +++ b/ldap/servers/slapd/back-ldbm/dblayer.h @@ -28,7 +28,7 @@ #endif /* solaris: mmap */ #endif /* DB_USE_64LFS */ -#define DBLAYER_PAGESIZE (size_t)8 * 1024 +#define DBLAYER_PAGESIZE (uint32_t)8 * 1024 #define DBLAYER_INDEX_PAGESIZE (size_t)8 * 1024 /* With the new idl design, \ the large 8Kbyte pages we use are not optimal. The page pool churns very \ quickly as we add new IDs under a sustained add load. Smaller pages stop \ @@ -103,9 +103,9 @@ struct dblayer_private int dblayer_durable_transactions; int dblayer_checkpoint_interval; int dblayer_circular_logging; - uint64_t dblayer_page_size; /* db page size if configured, + uint32_t dblayer_page_size; /* db page size if configured, * otherwise default to DBLAYER_PAGESIZE */ - uint64_t dblayer_index_page_size; /* db index page size if configured, + uint32_t dblayer_index_page_size; /* db index page size if configured, * otherwise default to * DBLAYER_INDEX_PAGESIZE */ int dblayer_idl_divisor; /* divide page size by this to get IDL diff --git a/ldap/servers/slapd/back-ldbm/filterindex.c b/ldap/servers/slapd/back-ldbm/filterindex.c index aaa1d6e..6d36ba3 100644 --- a/ldap/servers/slapd/back-ldbm/filterindex.c +++ b/ldap/servers/slapd/back-ldbm/filterindex.c @@ -974,7 +974,7 @@ keys2idl( IDList *idl = NULL; slapi_log_err(SLAPI_LOG_TRACE, "keys2idl", "=> type %s indextype %s\n", type, indextype); - for (size_t i = 0; ivals[i] != NULL; i++) { + for (uint32_t i = 0; ivals[i] != NULL; i++) { IDList *idl2 = NULL; idl2 = index_read_ext_allids(pb, be, type, indextype, slapi_value_get_berval(ivals[i]), txn, err, unindexed, allidslimit); @@ -985,8 +985,8 @@ keys2idl( char buf[BUFSIZ]; slapi_log_err(SLAPI_LOG_TRACE, "keys2idl", - " ival[%lu] = \"%s\" => %lu IDs\n", i, - encode(slapi_value_get_berval(ivals[i]), buf), (u_long)IDL_NIDS(idl2)); + " ival[%" PRIu32 "] = \"%s\" => %" PRIu32 " IDs\n", i, + encode(slapi_value_get_berval(ivals[i]), buf), (uint32_t)IDL_NIDS(idl2)); } #endif if (idl2 == NULL) { diff --git a/ldap/servers/slapd/back-ldbm/idl_new.c b/ldap/servers/slapd/back-ldbm/idl_new.c index 6c4abc2..870ec29 100644 --- a/ldap/servers/slapd/back-ldbm/idl_new.c +++ b/ldap/servers/slapd/back-ldbm/idl_new.c @@ -83,10 +83,10 @@ idl_new_get_allidslimit(struct attrinfo *a, int allidslimit) } int -idl_new_exceeds_allidslimit(size_t count, struct attrinfo *a, int allidslimit) +idl_new_exceeds_allidslimit(uint64_t count, struct attrinfo *a, int allidslimit) { - size_t limit = idl_new_get_allidslimit(a, allidslimit); - return (limit != (size_t)-1) && (count > limit); + uint64_t limit = idl_new_get_allidslimit(a, allidslimit); + return (limit != (uint64_t)-1) && (count > limit); } @@ -138,7 +138,7 @@ idl_new_fetch( DBT key; DBT data; ID id = 0; - size_t count = 0; + uint64_t count = 0; /* beware that a large buffer on the stack might cause a stack overflow on some platforms */ char buffer[BULK_FETCH_BUFFER_SIZE]; void *ptr; @@ -245,7 +245,7 @@ idl_new_fetch( count++; } - slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "bulk fetch buffer nids=%lu\n", count); + slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "bulk fetch buffer nids=%" PRIu64 "\n", count); #if defined(DB_ALLIDS_ON_READ) /* enforce the allids read limit */ if ((NEW_IDL_NO_ALLID != *flag_err) && (NULL != a) && @@ -254,7 +254,7 @@ idl_new_fetch( idl->b_ids[0] = ALLID; ret = DB_NOTFOUND; /* fool the code below into thinking that we finished the dups */ slapi_log_err(SLAPI_LOG_BACKLDBM, "idl_new_fetch", "Search for key for attribute index %s " - "exceeded allidslimit %d - count is %lu\n", + "exceeded allidslimit %d - count is %" PRIu64 "\n", a->ai_type, allidslimit, count); break; } @@ -280,7 +280,7 @@ idl_new_fetch( slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "%s returns allids\n", (char *)key.data); } else { - slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "%s returns nids=%lu\n", + slapi_log_err(SLAPI_LOG_TRACE, "idl_new_fetch", "%s returns nids=%" PRIu64 "\n", (char *)key.data, (u_long)IDL_NIDS(idl)); } @@ -348,7 +348,7 @@ idl_new_range_fetch( DBT cur_key = {0}; DBT data = {0}; ID id = 0; - size_t count = 0; + uint64_t count = 0; /* beware that a large buffer on the stack might cause a stack overflow on some platforms */ char buffer[BULK_FETCH_BUFFER_SIZE]; void *ptr; @@ -522,7 +522,7 @@ idl_new_range_fetch( } slapi_log_err(SLAPI_LOG_TRACE, "idl_new_range_fetch", - "Bulk fetch buffer nids=%lu\n", count); + "Bulk fetch buffer nids=%" PRIu64 "\n", count); #if defined(DB_ALLIDS_ON_READ) /* enforce the allids read limit */ if ((NEW_IDL_NO_ALLID != *flag_err) && ai && (idl != NULL) && @@ -584,8 +584,8 @@ idl_new_range_fetch( slapi_log_err(SLAPI_LOG_TRACE, "idl_new_range_fetch", "%s returns allids\n", (char *)cur_key.data); } else { - slapi_log_err(SLAPI_LOG_TRACE, "idl_new_range_fetch", "%s returns nids=%lu\n", - (char *)cur_key.data, (u_long)IDL_NIDS(idl)); + slapi_log_err(SLAPI_LOG_TRACE, "idl_new_range_fetch", "%s returns nids=%" PRIu64 "\n", + (char *)cur_key.data, (uint64_t)IDL_NIDS(idl)); } error: diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c index 0419865..1be15a4 100644 --- a/ldap/servers/slapd/back-ldbm/import-threads.c +++ b/ldap/servers/slapd/back-ldbm/import-threads.c @@ -3563,7 +3563,7 @@ dse_conf_backup_core(struct ldbminfo *li, char *dest_dir, char *file_name, char slapi_search_internal_pb(srch_pb); slapi_pblock_get(srch_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries); for (ep = entries; ep != NULL && *ep != NULL; ep++) { - size_t l = strlen(slapi_entry_get_dn_const(*ep)) + 5 /* "dn: \n" */; + int32_t l = strlen(slapi_entry_get_dn_const(*ep)) + 5 /* "dn: \n" */; slapi_log_err(SLAPI_LOG_TRACE, "dse_conf_backup_core", "dn: %s\n", slapi_entry_get_dn_const(*ep)); @@ -3573,9 +3573,9 @@ dse_conf_backup_core(struct ldbminfo *li, char *dest_dir, char *file_name, char tp = (char *)slapi_ch_malloc(l); /* should be very rare ... */ sprintf(tp, "dn: %s\n", slapi_entry_get_dn_const(*ep)); prrval = PR_Write(prfd, tp, l); - if ((size_t)prrval != l) { + if (prrval != l) { slapi_log_err(SLAPI_LOG_ERR, "dse_conf_backup_core", - "(%s): write %lu failed: %d (%s)\n", + "(%s): write %" PRId32 " failed: %d (%s)\n", filter, l, PR_GetError(), slapd_pr_strerror(PR_GetError())); rval = -1; if (l > sizeof(tmpbuf)) @@ -3609,9 +3609,9 @@ dse_conf_backup_core(struct ldbminfo *li, char *dest_dir, char *file_name, char tp = (char *)slapi_ch_malloc(l); sprintf(tp, "%s: %s\n", attr_name, attr_val->bv_val); prrval = PR_Write(prfd, tp, l); - if ((size_t)prrval != l) { + if (prrval != l) { slapi_log_err(SLAPI_LOG_ERR, "dse_conf_backup_core", - "(%s): write %lu failed: %d (%s)\n", + "(%s): write %" PRId32 " failed: %d (%s)\n", filter, l, PR_GetError(), slapd_pr_strerror(PR_GetError())); rval = -1; if (l > sizeof(tmpbuf)) @@ -3624,9 +3624,9 @@ dse_conf_backup_core(struct ldbminfo *li, char *dest_dir, char *file_name, char } if (ep + 1 != NULL && *(ep + 1) != NULL) { prrval = PR_Write(prfd, "\n", 1); - if ((int)prrval != 1) { + if (prrval != 1) { slapi_log_err(SLAPI_LOG_ERR, "dse_conf_backup_core", - "(%s): write %lu failed: %d (%s)\n", + "(%s): write %" PRId32 " failed: %d (%s)\n", filter, l, PR_GetError(), slapd_pr_strerror(PR_GetError())); rval = -1; goto out; diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c index 412e1d3..63ac88b 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_add.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c @@ -857,7 +857,7 @@ ldbm_back_add(Slapi_PBlock *pb) } retval = parent_update_on_childchange(&parent_modify_c, op, NULL); slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_add", - "conn=%lu op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n", + "conn=%" PRIu64 " op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n", conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, retval); /* The modify context now contains info needed later */ if (retval) { @@ -1177,7 +1177,7 @@ ldbm_back_add(Slapi_PBlock *pb) /* switch the parent entry copy into play */ myrc = modify_switch_entries(&parent_modify_c, be); slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_add", - "conn=%lu op=%d modify_switch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n", + "conn=%" PRIu64 " op=%d modify_switch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n", conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, myrc); if (0 == myrc) { parent_switched = 1; @@ -1257,7 +1257,7 @@ error_return: */ myrc = modify_unswitch_entries(&parent_modify_c, be); slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_add", - "conn=%lu op=%d modify_unswitch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n", + "conn=%" PRIu64 " op=%d modify_unswitch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n", conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, myrc); } diskfull_return: @@ -1394,7 +1394,7 @@ common_return: modify_term(&ruv_c, be); } slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_add", - "conn=%lu op=%d modify_term: old_entry=0x%p, new_entry=0x%p\n", + "conn=%" PRIu64 " op=%d modify_term: old_entry=0x%p, new_entry=0x%p\n", conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry); myrc = modify_term(&parent_modify_c, be); done_with_pblock_entry(pb, SLAPI_ADD_EXISTING_DN_ENTRY); diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c index feb9933..4e1a943 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_config.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c @@ -413,7 +413,7 @@ ldbm_config_dbcachesize_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *)arg; - return (void *)(li->li_new_dbcachesize); + return (void *)((uintptr_t)li->li_new_dbcachesize); } static int @@ -724,7 +724,7 @@ ldbm_config_db_logbuf_size_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *)arg; - return (void *)li->li_dblayer_private->dblayer_logbuf_size; + return (void *)((uintptr_t)li->li_dblayer_private->dblayer_logbuf_size); } static int @@ -736,7 +736,7 @@ ldbm_config_db_logbuf_size_set(void *arg, { struct ldbminfo *li = (struct ldbminfo *)arg; int retval = LDAP_SUCCESS; - size_t val = (size_t)value; + uint64_t val = (uint64_t)value; if (apply) { li->li_dblayer_private->dblayer_logbuf_size = val; @@ -802,7 +802,7 @@ ldbm_config_db_page_size_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *)arg; - return (void *)li->li_dblayer_private->dblayer_page_size; + return (void *)((uintptr_t)li->li_dblayer_private->dblayer_page_size); } static int @@ -814,7 +814,7 @@ ldbm_config_db_page_size_set(void *arg, { struct ldbminfo *li = (struct ldbminfo *)arg; int retval = LDAP_SUCCESS; - size_t val = (size_t)value; + uint32_t val = (uint32_t)((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_page_size = val; @@ -828,7 +828,7 @@ ldbm_config_db_index_page_size_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *)arg; - return (void *)li->li_dblayer_private->dblayer_index_page_size; + return (void *)((uintptr_t)li->li_dblayer_private->dblayer_index_page_size); } static int @@ -840,7 +840,7 @@ ldbm_config_db_index_page_size_set(void *arg, { struct ldbminfo *li = (struct ldbminfo *)arg; int retval = LDAP_SUCCESS; - size_t val = (size_t)value; + uint32_t val = (uint32_t)((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_index_page_size = val; @@ -913,7 +913,7 @@ ldbm_config_db_logfile_size_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *)arg; - return (void *)li->li_dblayer_private->dblayer_logfile_size; + return (void *)((uintptr_t)li->li_dblayer_private->dblayer_logfile_size); } static int @@ -925,7 +925,7 @@ ldbm_config_db_logfile_size_set(void *arg, { struct ldbminfo *li = (struct ldbminfo *)arg; int retval = LDAP_SUCCESS; - size_t val = (size_t)value; + uint64_t val = (uint64_t)((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_logfile_size = val; @@ -1218,12 +1218,12 @@ ldbm_config_db_lock_set(void *arg, void *value, char *errorbuf, int phase, int a { struct ldbminfo *li = (struct ldbminfo *)arg; int retval = LDAP_SUCCESS; - size_t val = (size_t)value; + uint64_t val = (uint64_t)((uintptr_t)value); if (val < BDB_LOCK_NB_MIN) { slapi_create_errormsg(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: Invalid value for %s (%d). Must be greater than %d\n", CONFIG_DB_LOCK, val, BDB_LOCK_NB_MIN); - slapi_log_err(SLAPI_LOG_ERR, "ldbm_config_db_lock_set", "Invalid value for %s (%lu)\n", + slapi_log_err(SLAPI_LOG_ERR, "ldbm_config_db_lock_set", "Invalid value for %s (%" PRIu64 ")\n", CONFIG_DB_LOCK, val); return LDAP_UNWILLING_TO_PERFORM; } @@ -1439,7 +1439,7 @@ ldbm_config_import_cachesize_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *)arg; - return (void *)(li->li_import_cachesize); + return (void *)((uintptr_t)li->li_import_cachesize); } static int @@ -1450,8 +1450,8 @@ ldbm_config_import_cachesize_set(void *arg, int apply) { struct ldbminfo *li = (struct ldbminfo *)arg; - size_t val = (size_t)value; - uint64_t delta = (size_t)value; + uint64_t val = (uint64_t)((uintptr_t)value); + uint64_t delta; /* There is an error here. We check the new val against our current mem-alloc * Issue is that we already are using system pages, so while our value *might* * be valid, we may reject it here due to the current procs page usage. @@ -1819,7 +1819,7 @@ static config_info ldbm_config[] = { {CONFIG_MODE, CONFIG_TYPE_INT_OCTAL, "0600", &ldbm_config_mode_get, &ldbm_config_mode_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, {CONFIG_IDLISTSCANLIMIT, CONFIG_TYPE_INT, "4000", &ldbm_config_allidsthreshold_get, &ldbm_config_allidsthreshold_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, {CONFIG_DIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_directory_get, &ldbm_config_directory_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE | CONFIG_FLAG_SKIP_DEFAULT_SETTING}, - {CONFIG_DBCACHESIZE, CONFIG_TYPE_SIZE_T, DEFAULT_CACHE_SIZE_STR, &ldbm_config_dbcachesize_get, &ldbm_config_dbcachesize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, + {CONFIG_DBCACHESIZE, CONFIG_TYPE_UINT64, DEFAULT_CACHE_SIZE_STR, &ldbm_config_dbcachesize_get, &ldbm_config_dbcachesize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, {CONFIG_DBNCACHE, CONFIG_TYPE_INT, "0", &ldbm_config_dbncache_get, &ldbm_config_dbncache_set, CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, {CONFIG_MAXPASSBEFOREMERGE, CONFIG_TYPE_INT, "100", &ldbm_config_maxpassbeforemerge_get, &ldbm_config_maxpassbeforemerge_set, 0}, @@ -1839,7 +1839,7 @@ static config_info ldbm_config[] = { {CONFIG_DB_INDEX_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_index_page_size_get, &ldbm_config_db_index_page_size_set, 0}, {CONFIG_DB_IDL_DIVISOR, CONFIG_TYPE_INT, "0", &ldbm_config_db_idl_divisor_get, &ldbm_config_db_idl_divisor_set, 0}, {CONFIG_DB_OLD_IDL_MAXIDS, CONFIG_TYPE_INT, "0", &ldbm_config_db_old_idl_maxids_get, &ldbm_config_db_old_idl_maxids_set, 0}, - {CONFIG_DB_LOGFILE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_logfile_size_get, &ldbm_config_db_logfile_size_set, 0}, + {CONFIG_DB_LOGFILE_SIZE, CONFIG_TYPE_UINT64, "0", &ldbm_config_db_logfile_size_get, &ldbm_config_db_logfile_size_set, 0}, {CONFIG_DB_TRICKLE_PERCENTAGE, CONFIG_TYPE_INT, "5", &ldbm_config_db_trickle_percentage_get, &ldbm_config_db_trickle_percentage_set, 0}, {CONFIG_DB_SPIN_COUNT, CONFIG_TYPE_INT, "0", &ldbm_config_db_spin_count_get, &ldbm_config_db_spin_count_set, 0}, {CONFIG_DB_VERBOSE, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_verbose_get, &ldbm_config_db_verbose_set, 0}, @@ -1856,7 +1856,7 @@ static config_info ldbm_config[] = { {CONFIG_IMPORT_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "-1", &ldbm_config_import_cache_autosize_get, &ldbm_config_import_cache_autosize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, {CONFIG_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "10", &ldbm_config_cache_autosize_get, &ldbm_config_cache_autosize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, {CONFIG_CACHE_AUTOSIZE_SPLIT, CONFIG_TYPE_INT, "25", &ldbm_config_cache_autosize_split_get, &ldbm_config_cache_autosize_split_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, - {CONFIG_IMPORT_CACHESIZE, CONFIG_TYPE_SIZE_T, "16777216", &ldbm_config_import_cachesize_get, &ldbm_config_import_cachesize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, + {CONFIG_IMPORT_CACHESIZE, CONFIG_TYPE_UINT64, "16777216", &ldbm_config_import_cachesize_get, &ldbm_config_import_cachesize_set, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, {CONFIG_IDL_SWITCH, CONFIG_TYPE_STRING, "new", &ldbm_config_idl_get_idl_new, &ldbm_config_idl_set_tune, CONFIG_FLAG_ALWAYS_SHOW}, {CONFIG_IDL_UPDATE, CONFIG_TYPE_ONOFF, "on", &ldbm_config_idl_get_update, &ldbm_config_idl_set_update, 0}, {CONFIG_BYPASS_FILTER_TEST, CONFIG_TYPE_STRING, "on", &ldbm_config_get_bypass_filter_test, &ldbm_config_set_bypass_filter_test, CONFIG_FLAG_ALWAYS_SHOW | CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, @@ -2120,6 +2120,10 @@ ldbm_config_get(void *arg, config_info *config, char *buf) val = (size_t)config->config_get_fn(arg); sprintf(buf, "%lu", (long unsigned int)val); break; + case CONFIG_TYPE_UINT64: + val = (uint64_t)((uintptr_t)config->config_get_fn(arg)); + sprintf(buf, "%" PRIu64, (uint64_t)val); + break; case CONFIG_TYPE_STRING: /* Remember the get function for strings returns memory * that must be freed. */ @@ -2371,6 +2375,31 @@ ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struct be } retval = config->config_set_fn(arg, (void *)sz_val, err_buf, phase, apply_mod); break; + case CONFIG_TYPE_UINT64: + if (use_default) { + str_val = config->config_default_value; + } else { + str_val = bval->bv_val; + } + /* get the value as a size_t value */ + sz_val = db_strtoull(str_val, &err); + + /* check for parsing error (e.g. not a number) */ + if (err == EINVAL) { + slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n", + str_val, attr_name); + slapi_log_err(SLAPI_LOG_ERR, "ldbm_config_set", "Value %s for attr %s is not a number\n", str_val, attr_name); + return LDAP_UNWILLING_TO_PERFORM; + /* check for overflow */ + } else if (err == ERANGE) { + slapi_create_errormsg(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is outside the range of representable values\n", + str_val, attr_name); + slapi_log_err(SLAPI_LOG_ERR, "ldbm_config_set", "Value %s for attr %s is outside the range of representable values\n", + str_val, attr_name); + return LDAP_UNWILLING_TO_PERFORM; + } + retval = config->config_set_fn(arg, (void *)sz_val, err_buf, phase, apply_mod); + break; case CONFIG_TYPE_STRING: if (use_default) { retval = config->config_set_fn(arg, config->config_default_value, err_buf, phase, apply_mod); diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.h b/ldap/servers/slapd/back-ldbm/ldbm_config.h index c0f5d31..8abd899 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_config.h +++ b/ldap/servers/slapd/back-ldbm/ldbm_config.h @@ -31,6 +31,7 @@ typedef void *config_get_fn_t(void *arg); #define CONFIG_TYPE_INT_OCTAL 5 /* Same as CONFIG_TYPE_INT, but shown in \ * octal */ #define CONFIG_TYPE_SIZE_T 6 /* val = (size_t) value */ +#define CONFIG_TYPE_UINT64 7 /* val = (uint64_t) value */ /* How changes to some config attributes are handled depends on what * "phase" the server is in. Initialization, reading the config diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c index bc0a365..3781790 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c @@ -211,7 +211,7 @@ ldbm_back_delete(Slapi_PBlock *pb) CACHE_RETURN(&inst->inst_cache, &tombstone); if (tombstone) { slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_delete", - "conn=%lu op=%d [retry: %d] tombstone %s is not freed!!! refcnt %d, state %d\n", + "conn=%" PRIu64 " op=%d [retry: %d] tombstone %s is not freed!!! refcnt %d, state %d\n", conn_id, op_id, retry_count, slapi_entry_get_dn(tombstone->ep_entry), tombstone->ep_refcnt, tombstone->ep_state); } @@ -220,7 +220,7 @@ ldbm_back_delete(Slapi_PBlock *pb) tmptombstone = NULL; } else { slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_delete", - "conn=%lu op=%d [retry: %d] No original_tombstone for %s!!\n", + "conn=%" PRIu64 " op=%d [retry: %d] No original_tombstone for %s!!\n", conn_id, op_id, retry_count, slapi_entry_get_dn(e->ep_entry)); } } @@ -294,11 +294,11 @@ replace_entry: if (slapi_entry_has_conflict_children(e->ep_entry, (void *)li->li_identity) > 0) { ldap_result_message = "Entry has replication conflicts as children"; slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_delete", - "conn=%lu op=%d Deleting entry %s has replication conflicts as children.\n", + "conn=%" PRIu64 " op=%d Deleting entry %s has replication conflicts as children.\n", conn_id, op_id, slapi_entry_get_dn(e->ep_entry)); } else { slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_delete", - "conn=%lu op=%d Deleting entry %s has %d children.\n", + "conn=%" PRIu64 " op=%d Deleting entry %s has %d children.\n", conn_id, op_id, slapi_entry_get_dn(e->ep_entry), retval); } retval = -1; @@ -566,7 +566,7 @@ replace_entry: /* The modify context now contains info needed later */ if (0 != retval) { slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_delete", - "conn=%lu op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n", + "conn=%" PRIu64 " op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n", conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, retval); ldap_result_code = LDAP_OPERATIONS_ERROR; slapi_sdn_done(&parentsdn); @@ -604,7 +604,7 @@ replace_entry: if (slapi_entry_attr_hasvalue(e->ep_entry, SLAPI_ATTR_OBJECTCLASS, SLAPI_ATTR_VALUE_TOMBSTONE) && slapi_is_special_rdn(edn, RDN_IS_TOMBSTONE)) { slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_delete", - "conn=%lu op=%d Turning a tombstone into a tombstone! \"%s\"; e: 0x%p, cache_state: 0x%x, refcnt: %d\n", + "conn=%" PRIu64 " op=%d Turning a tombstone into a tombstone! \"%s\"; e: 0x%p, cache_state: 0x%x, refcnt: %d\n", conn_id, op_id, edn, e, e->ep_state, e->ep_refcnt); ldap_result_code = LDAP_OPERATIONS_ERROR; retval = -1; @@ -612,7 +612,7 @@ replace_entry: } if (!childuniqueid) { slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_delete", - "conn=%lu op=%d No nsUniqueId in the entry \"%s\"; e: 0x%p, cache_state: 0x%x, refcnt: %d\n", + "conn=%" PRIu64 " op=%d No nsUniqueId in the entry \"%s\"; e: 0x%p, cache_state: 0x%x, refcnt: %d\n", conn_id, op_id, edn, e, e->ep_state, e->ep_refcnt); ldap_result_code = LDAP_OPERATIONS_ERROR; retval = -1; @@ -743,7 +743,7 @@ replace_entry: retval = cache_add_tentative(&inst->inst_cache, tombstone, NULL); if (0 > retval) { slapi_log_err(SLAPI_LOG_CACHE, "ldbm_back_delete", - "conn=%lu op=%d tombstone entry %s failed to add to the cache: %d\n", + "conn=%" PRIu64 " op=%d tombstone entry %s failed to add to the cache: %d\n", conn_id, op_id, slapi_entry_get_dn(tombstone->ep_entry), retval); if (LDBM_OS_ERR_IS_DISKFULL(retval)) disk_full = 1; @@ -844,7 +844,7 @@ replace_entry: } if (0 != retval) { slapi_log_err(SLAPI_LOG_ERR, - "ldbm_back_delete", "delete tombsone csn(adding %s) failed, err=%d %s\n", + "ldbm_back_delete", "delete tombstone csn(adding %s) failed, err=%d %s\n", deletion_csn_str, retval, (msg = dblayer_strerror(retval)) ? msg : ""); @@ -1035,7 +1035,7 @@ replace_entry: } if (0 != retval) { slapi_log_err(SLAPI_LOG_ERR, - "ldbm_back_delete", "delete tombsone csn(deleting %s) failed, err=%d %s\n", + "ldbm_back_delete", "delete tombstone csn(deleting %s) failed, err=%d %s\n", deletion_csn_str, retval, (msg = dblayer_strerror(retval)) ? msg : ""); @@ -1276,7 +1276,7 @@ replace_entry: /* Replace the old parent entry with the newly modified one */ myrc = modify_switch_entries(&parent_modify_c, be); slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_delete", - "conn=%lu op=%d modify_switch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n", + "conn=%" PRIu64 " op=%d modify_switch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n", conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, myrc); if (myrc == 0) { parent_switched = 1; @@ -1435,7 +1435,7 @@ error_return: */ myrc = modify_unswitch_entries(&parent_modify_c, be); slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_delete", - "conn=%lu op=%d modify_unswitch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n", + "conn=%" PRIu64 " op=%d modify_unswitch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n", conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, myrc); } @@ -1514,7 +1514,7 @@ diskfull_return: } } slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_delete", - "conn=%lu op=%d modify_term: old_entry=0x%p, new_entry=0x%p, in_cache=%d\n", + "conn=%" PRIu64 " op=%d modify_term: old_entry=0x%p, new_entry=0x%p, in_cache=%d\n", conn_id, op_id, parent_modify_c.old_entry, parent_modify_c.new_entry, cache_is_in_cache(&inst->inst_cache, parent_modify_c.new_entry)); myrc = modify_term(&parent_modify_c, be); diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c index eb26038..643628c 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c @@ -110,7 +110,7 @@ ldbm_instance_config_cachememsize_set(void *arg, { ldbm_instance *inst = (ldbm_instance *)arg; int retval = LDAP_SUCCESS; - size_t val = (size_t)value; + uint64_t val = (uint64_t)((uintptr_t)value); uint64_t delta = 0; uint64_t delta_original = 0; @@ -194,7 +194,7 @@ ldbm_instance_config_dncachememsize_set(void *arg, { ldbm_instance *inst = (ldbm_instance *)arg; int retval = LDAP_SUCCESS; - size_t val = (size_t)value; + uint64_t val = (uint64_t)((uintptr_t)value); uint64_t delta = 0; /* Do whatever we can to make sure the data is ok. */ diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c index 93fb77d..b9a092c 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c @@ -713,7 +713,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb) ldap_result_code = LDAP_ALREADY_EXISTS; if (is_resurect_operation) { slapi_log_err(SLAPI_LOG_CACHE, "ldbm_back_modrdn", - "conn=%lu op=%d cache_add_tentative failed: %s\n", + "conn=%" PRIu64 " op=%d cache_add_tentative failed: %s\n", conn_id, op_id, slapi_entry_get_dn(ec->ep_entry)); } goto error_return; @@ -845,7 +845,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb) retval = parent_update_on_childchange(&parent_modify_context, PARENTUPDATE_DEL, NULL); slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn", - "conn=%lu op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n", + "conn=%" PRIu64 " op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n", conn_id, op_id, parent_modify_context.old_entry, parent_modify_context.new_entry, retval); /* The parent modify context now contains info needed later */ @@ -857,7 +857,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb) retval = parent_update_on_childchange(&newparent_modify_context, PARENTUPDATE_ADD, NULL); slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn", - "conn=%lu op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n", + "conn=%" PRIu64 " op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n", conn_id, op_id, parent_modify_context.old_entry, parent_modify_context.new_entry, retval); /* The newparent modify context now contains info needed later */ if (retval) { @@ -870,7 +870,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb) retval = parent_update_on_childchange(&parent_modify_context, PARENTUPDATE_RESURECT, NULL); if (retval) { slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn", - "conn=%lu op=%d parent_update_on_childchange parent %s of %s failed, rc=%d\n", + "conn=%" PRIu64 " op=%d parent_update_on_childchange parent %s of %s failed, rc=%d\n", conn_id, op_id, slapi_entry_get_dn_const(parent_modify_context.old_entry->ep_entry), slapi_entry_get_dn_const(ec->ep_entry), retval); @@ -1053,7 +1053,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb) { retval = modify_update_all(be, pb, &newparent_modify_context, &txn); slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn", - "conn=%lu op=%d modify_update_all: old_entry=0x%p, new_entry=0x%p, rc=%d\n", + "conn=%" PRIu64 " op=%d modify_update_all: old_entry=0x%p, new_entry=0x%p, rc=%d\n", conn_id, op_id, parent_modify_context.old_entry, parent_modify_context.new_entry, retval); if (DB_LOCK_DEADLOCK == retval) { /* Retry txn */ @@ -1178,7 +1178,7 @@ ldbm_back_modrdn(Slapi_PBlock *pb) if (newparententry != NULL) { myrc = modify_switch_entries(&newparent_modify_context, be); slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn", - "conn=%lu op=%d modify_switch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n", + "conn=%" PRIu64 " op=%d modify_switch_entries: old_entry=0x%p, new_entry=0x%p, rc=%d\n", conn_id, op_id, parent_modify_context.old_entry, parent_modify_context.new_entry, myrc); } @@ -1455,13 +1455,13 @@ common_return: slapi_sdn_done(&dn_newrdn); slapi_sdn_done(&dn_parentdn); slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn", - "conn=%lu op=%d modify_term: old_entry=0x%p, new_entry=0x%p\n", + "conn=%" PRIu64 " op=%d modify_term: old_entry=0x%p, new_entry=0x%p\n", conn_id, op_id, parent_modify_context.old_entry, parent_modify_context.new_entry); myrc = modify_term(&parent_modify_context, be); slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn", - "conn=%lu op=%d modify_term: rc=%d\n", conn_id, op_id, myrc); + "conn=%" PRIu64 " op=%d modify_term: rc=%d\n", conn_id, op_id, myrc); slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_modrdn", - "conn=%lu op=%d modify_term: old_entry=0x%p, new_entry=0x%p\n", + "conn=%" PRIu64 " op=%d modify_term: old_entry=0x%p, new_entry=0x%p\n", conn_id, op_id, newparent_modify_context.old_entry, newparent_modify_context.new_entry); myrc = modify_term(&newparent_modify_context, be); if (free_modrdn_existing_entry) { diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c index e4eb3d1..bcc6302 100644 --- a/ldap/servers/slapd/back-ldbm/monitor.c +++ b/ldap/servers/slapd/back-ldbm/monitor.c @@ -47,9 +47,10 @@ ldbm_back_monitor_instance_search(Slapi_PBlock *pb __attribute__((unused)), struct berval val; struct berval *vals[2]; char buf[BUFSIZ]; - PRUint64 hits, tries; - long nentries, maxentries, count; - size_t size, maxsize; + uint64_t hits, tries; + uint64_t nentries; + int64_t maxentries; + uint64_t size, maxsize, count; size_t thread_size; size_t evicts; size_t slots; @@ -91,19 +92,19 @@ ldbm_back_monitor_instance_search(Slapi_PBlock *pb __attribute__((unused)), /* fetch cache statistics */ cache_get_stats(&(inst->inst_cache), &hits, &tries, &nentries, &maxentries, &size, &maxsize); - sprintf(buf, "%lu", (long unsigned int)hits); + sprintf(buf, "%" PRIu64, hits); MSET("entryCacheHits"); - sprintf(buf, "%lu", (long unsigned int)tries); + sprintf(buf, "%" PRIu64, tries); MSET("entryCacheTries"); - sprintf(buf, "%lu", (long unsigned int)(100.0 * (double)hits / (double)(tries > 0 ? tries : 1))); + sprintf(buf, "%" PRIu64, (uint64_t)(100.0 * (double)hits / (double)(tries > 0 ? tries : 1))); MSET("entryCacheHitRatio"); - sprintf(buf, "%lu", (long unsigned int)size); + sprintf(buf, "%" PRIu64, size); MSET("currentEntryCacheSize"); - sprintf(buf, "%lu", (long unsigned int)maxsize); + sprintf(buf, "%" PRIu64, maxsize); MSET("maxEntryCacheSize"); - sprintf(buf, "%ld", nentries); + sprintf(buf, "%" PRId64, nentries); MSET("currentEntryCacheCount"); - sprintf(buf, "%ld", maxentries); + sprintf(buf, "%" PRId64, maxentries); MSET("maxEntryCacheCount"); if (entryrdn_get_switch()) { @@ -114,15 +115,15 @@ ldbm_back_monitor_instance_search(Slapi_PBlock *pb __attribute__((unused)), MSET("dnCacheHits"); sprintf(buf, "%" PRIu64, tries); MSET("dnCacheTries"); - sprintf(buf, "%lu", (unsigned long)(100.0 * (double)hits / (double)(tries > 0 ? tries : 1))); + sprintf(buf, "%" PRIu64, (uint64_t)(100.0 * (double)hits / (double)(tries > 0 ? tries : 1))); MSET("dnCacheHitRatio"); - sprintf(buf, "%lu", (long unsigned int)size); + sprintf(buf, "%" PRIu64, size); MSET("currentDnCacheSize"); - sprintf(buf, "%lu", (long unsigned int)maxsize); + sprintf(buf, "%" PRIu64, maxsize); MSET("maxDnCacheSize"); - sprintf(buf, "%ld", nentries); + sprintf(buf, "%" PRId64, nentries); MSET("currentDnCacheCount"); - sprintf(buf, "%ld", maxentries); + sprintf(buf, "%" PRId64, maxentries); MSET("maxDnCacheCount"); } /* normalized dn cache stats */ @@ -134,23 +135,23 @@ ldbm_back_monitor_instance_search(Slapi_PBlock *pb __attribute__((unused)), MSET("normalizedDnCacheHits"); sprintf(buf, "%" PRIu64, (tries - hits)); MSET("normalizedDnCacheMisses"); - sprintf(buf, "%lu", (unsigned long)(100.0 * (double)hits / (double)(tries > 0 ? tries : 1))); + sprintf(buf, "%" PRIu64, (uint64_t)(100.0 * (double)hits / (double)(tries > 0 ? tries : 1))); MSET("normalizedDnCacheHitRatio"); sprintf(buf, "%"PRIu64, evicts); MSET("NormalizedDnCacheEvictions"); - sprintf(buf, "%lu", (long unsigned int)size); + sprintf(buf, "%" PRIu64, size); MSET("currentNormalizedDnCacheSize"); if (maxsize == 0) { sprintf(buf, "%d", -1); } else { - sprintf(buf, "%lu", (long unsigned int)maxsize); + sprintf(buf, "%" PRIu64, maxsize); } MSET("maxNormalizedDnCacheSize"); sprintf(buf, "%"PRIu64, thread_size); MSET("NormalizedDnCacheThreadSize"); sprintf(buf, "%"PRIu64, slots); MSET("NormalizedDnCacheThreadSlots"); - sprintf(buf, "%ld", count); + sprintf(buf, "%"PRIu64, count); MSET("currentNormalizedDnCacheCount"); } @@ -234,7 +235,7 @@ ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *entryAft char buf[BUFSIZ]; DB_MPOOL_STAT *mpstat = NULL; DB_MPOOL_FSTAT **mpfstat = NULL; - uintmax_t cache_tries; + uint64_t cache_tries; vals[0] = &val; vals[1] = NULL; @@ -255,7 +256,7 @@ ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *entryAft /* cache tries*/ cache_tries = (mpstat->st_cache_miss + mpstat->st_cache_hit); - sprintf(buf, "%lu", cache_tries); + sprintf(buf, "%"PRIu64, cache_tries); MSET("dbCacheTries"); /* cache hit ratio*/ diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h index da3eef1..eedaa09 100644 --- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -32,14 +32,14 @@ void attr_create_empty(backend *be, char *type, struct attrinfo **ai); /* * cache.c */ -int cache_init(struct cache *cache, size_t maxsize, long maxentries, int type); +int cache_init(struct cache *cache, uint64_t maxsize, long maxentries, int type); void cache_clear(struct cache *cache, int type); void cache_destroy_please(struct cache *cache, int type); -void cache_set_max_size(struct cache *cache, size_t bytes, int type); +void cache_set_max_size(struct cache *cache, uint64_t bytes, int type); void cache_set_max_entries(struct cache *cache, long entries); size_t cache_get_max_size(struct cache *cache); long cache_get_max_entries(struct cache *cache); -void cache_get_stats(struct cache *cache, PRUint64 *hits, PRUint64 *tries, long *entries, long *maxentries, size_t *size, size_t *maxsize); +void cache_get_stats(struct cache *cache, uint64_t *hits, uint64_t *tries, uint64_t *entries, int64_t *maxentries, uint64_t *size, uint64_t *maxsize); void cache_debug_hash(struct cache *cache, char **out); int cache_remove(struct cache *cache, void *e); void cache_return(struct cache *cache, void **bep); @@ -60,10 +60,10 @@ int cache_is_in_cache(struct cache *cache, void *ptr); void check_entry_cache(struct cache *cache, struct backentry *e); #endif -Hashtable *new_hash(u_long size, u_long offset, HashFn hfn, HashTestFn tfn); -int add_hash(Hashtable *ht, void *key, size_t keylen, void *entry, void **alt); -int find_hash(Hashtable *ht, const void *key, size_t keylen, void **entry); -int remove_hash(Hashtable *ht, const void *key, size_t keylen); +Hashtable *new_hash(u_long size, u_long offset, HashFn hfn, HashTestFn tfn);; +int add_hash(Hashtable *ht, void *key, uint32_t keylen, void *entry, void **alt); +int find_hash(Hashtable *ht, const void *key, uint32_t keylen, void **entry); +int remove_hash(Hashtable *ht, const void *key, uint32_t keylen); struct backdn *dncache_find_id(struct cache *cache, ID id); @@ -99,7 +99,7 @@ int dblayer_read_txn_commit(backend *be, back_txn *txn); int dblayer_txn_begin_all(struct ldbminfo *li, back_txnid parent_txn, back_txn *txn); int dblayer_txn_commit_all(struct ldbminfo *li, back_txn *txn); int dblayer_txn_abort_all(struct ldbminfo *li, back_txn *txn); -size_t dblayer_get_optimal_block_size(struct ldbminfo *li); +uint32_t dblayer_get_optimal_block_size(struct ldbminfo *li); void dblayer_unlock_backend(backend *be); void dblayer_lock_backend(backend *be); int dblayer_plugin_begin(Slapi_PBlock *pb); @@ -126,7 +126,8 @@ int dblayer_get_instance_data_dir(backend *be); char *dblayer_strerror(int error); PRInt64 db_atol(char *str, int *err); PRInt64 db_atoi(char *str, int *err); -unsigned long db_strtoul(const char *str, int *err); +uint32_t db_strtoul(const char *str, int *err); +uint64_t db_strtoull(const char *str, int *err); int dblayer_set_batch_transactions(void *arg, void *value, char *errorbuf, int phase, int apply); int dblayer_set_batch_txn_min_sleep(void *arg, void *value, char *errorbuf, int phase, int apply); int dblayer_set_batch_txn_max_sleep(void *arg, void *value, char *errorbuf, int phase, int apply); diff --git a/ldap/servers/slapd/back-ldbm/start.c b/ldap/servers/slapd/back-ldbm/start.c index 45ed091..4bccfc7 100644 --- a/ldap/servers/slapd/back-ldbm/start.c +++ b/ldap/servers/slapd/back-ldbm/start.c @@ -177,8 +177,8 @@ ldbm_back_start_autotune(struct ldbminfo *li) } } - slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %luk physical memory\n", mi->system_total_bytes / 1024); - slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %luk available\n", mi->system_available_bytes / 1024); + slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %" PRIu64 "k physical memory\n", mi->system_total_bytes / 1024); + slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "found %" PRIu64 "k available\n", mi->system_available_bytes / 1024); /* We've now calculated the autotuning values. Do we need to apply it? * we use the logic of "if size is 0, or autosize is > 0. This way three @@ -193,7 +193,7 @@ ldbm_back_start_autotune(struct ldbminfo *li) /* First, check the dbcache */ if (li->li_dbcachesize == 0 || li->li_cache_autosize > 0) { - slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: db cache: %luk\n", db_size / 1024); + slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: db cache: %" PRIu64 "k\n", db_size / 1024); if (db_size < (500 * MEGABYTE)) { db_size = db_size / 1.25; } @@ -223,12 +223,12 @@ ldbm_back_start_autotune(struct ldbminfo *li) * it's highly unlikely. */ if (cache_size == 0 || cache_size == MINCACHESIZE || li->li_cache_autosize > 0) { - slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: %s entry cache (%lu total): %luk\n", inst->inst_name, backend_count, entry_size / 1024); + slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: %s entry cache (%" PRIu64 " total): %luk\n", inst->inst_name, backend_count, entry_size / 1024); cache_set_max_entries(&(inst->inst_cache), -1); cache_set_max_size(&(inst->inst_cache), li->li_cache_autosize_ec, CACHE_TYPE_ENTRY); } if (dncache_size == 0 || dncache_size == MINCACHESIZE || li->li_cache_autosize > 0) { - slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: %s dn cache (%lu total): %luk\n", inst->inst_name, backend_count, dn_size / 1024); + slapi_log_err(SLAPI_LOG_NOTICE, "ldbm_back_start", "cache autosizing: %s dn cache (%" PRIu64 " total): %luk\n", inst->inst_name, backend_count, dn_size / 1024); cache_set_max_entries(&(inst->inst_dncache), -1); cache_set_max_size(&(inst->inst_dncache), li->li_dncache_autosize_ec, CACHE_TYPE_DN); } @@ -389,7 +389,7 @@ ldbm_back_start(Slapi_PBlock *pb) return return_on_disk_full(li); else { if ((li->li_cache_autosize > 0) && (li->li_cache_autosize <= 100)) { - slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_start", "Failed to allocate %lu byte dbcache. " + slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_start", "Failed to allocate %" PRIu64 " byte dbcache. " "Please reduce the value of %s and restart the server.\n", li->li_dbcachesize, CONFIG_CACHE_AUTOSIZE); } diff --git a/ldap/servers/slapd/ch_malloc.c b/ldap/servers/slapd/ch_malloc.c index ef436b3..75e7911 100644 --- a/ldap/servers/slapd/ch_malloc.c +++ b/ldap/servers/slapd/ch_malloc.c @@ -109,21 +109,16 @@ slapi_ch_malloc( /* See slapi-plugin.h */ char * -slapi_ch_memalign(size_t size, size_t alignment) +slapi_ch_memalign(uint32_t size, uint32_t alignment) { char *newmem; - if (size <= 0) { - log_negative_alloc_msg("memalign", "bytes", size); - return 0; - } - if (posix_memalign((void **)&newmem, alignment, size) != 0) { int oserr = errno; oom_occurred(); slapi_log_err(SLAPI_LOG_ERR, SLAPD_MODULE, - "malloc of %lu bytes failed; OS error %d (%s)%s\n", + "malloc of %" PRIu32 " bytes failed; OS error %d (%s)%s\n", size, oserr, slapd_system_strerror(oserr), oom_advice); exit(1); } diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c index cb68a11..d4f36d3 100644 --- a/ldap/servers/slapd/conntable.c +++ b/ldap/servers/slapd/conntable.c @@ -437,7 +437,7 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e) bufptr = newbuf; } - sprintf(bufptr, "%d:%s:%d:%d:%s%s:%s:%s:%lu:ip=%s", + sprintf(bufptr, "%d:%s:%d:%d:%s%s:%s:%s:%" PRIu64 ":ip=%s", i, buf2, ct->c[i].c_opsinitiated, diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index 01db503..b230e22 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -1220,7 +1220,7 @@ slapd_daemon(daemon_ports_t *ports, ns_thrpool_t *tp) threads = g_get_active_threadcnt(); if (threads > 0) { slapi_log_err(SLAPI_LOG_INFO, "slapd_daemon", - "slapd shutting down - waiting for %lu thread%s to terminate\n", + "slapd shutting down - waiting for %" PRIu64 " thread%s to terminate\n", threads, (threads > 1) ? "s" : ""); } @@ -1257,7 +1257,7 @@ slapd_daemon(daemon_ports_t *ports, ns_thrpool_t *tp) DS_Sleep(PR_INTERVAL_NO_WAIT); if (threads != g_get_active_threadcnt()) { slapi_log_err(SLAPI_LOG_TRACE, "slapd_daemon", - "slapd shutting down - waiting for %lu threads to terminate\n", + "slapd shutting down - waiting for %" PRIu64 " threads to terminate\n", g_get_active_threadcnt()); threads = g_get_active_threadcnt(); } diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c index abc1555..152561d 100644 --- a/ldap/servers/slapd/dn.c +++ b/ldap/servers/slapd/dn.c @@ -41,14 +41,14 @@ struct ndn_cache_stats { Slapi_Counter *cache_count; Slapi_Counter *cache_size; Slapi_Counter *cache_evicts; - size_t max_size; - size_t thread_max_size; - size_t slots; + uint64_t max_size; + uint64_t thread_max_size; + uint64_t slots; }; struct ndn_cache_value { - size_t size; - size_t slot; + uint64_t size; + uint64_t slot; char *dn; char *ndn; struct ndn_cache_value *next; @@ -64,21 +64,21 @@ struct ndn_cache { /* * We keep per thread stats and flush them occasionally */ - size_t max_size; + uint64_t max_size; /* Need to track this because we need to provide diffs to counter */ - size_t last_count; - size_t count; + uint64_t last_count; + uint64_t count; /* Number of ops */ - size_t tries; + uint64_t tries; /* hit vs miss. in theroy miss == tries - hits.*/ - size_t hits; + uint64_t hits; /* How many values we kicked out */ - size_t evicts; + uint64_t evicts; /* Need to track this because we need to provide diffs to counter */ - size_t last_size; - size_t size; + uint64_t last_size; + uint64_t size; - size_t slots; + uint64_t slots; /* * This is used by siphash to prevent hash bugket attacks */ @@ -3260,7 +3260,7 @@ ndn_cache_add(char *dn, size_t dn_len, char *ndn, size_t ndn_len) /* stats for monitor */ void -ndn_cache_get_stats(PRUint64 *hits, PRUint64 *tries, size_t *size, size_t *max_size, size_t *thread_size, size_t *evicts, size_t *slots, long *count) +ndn_cache_get_stats(uint64_t *hits, uint64_t *tries, uint64_t *size, uint64_t *max_size, uint64_t *thread_size, uint64_t *evicts, uint64_t *slots, uint64_t *count) { *max_size = t_cache_stats.max_size; *thread_size = t_cache_stats.thread_max_size; diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index 3bd5c18..fa21664 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -5957,10 +5957,10 @@ config_set_maxsasliosize(const char *attrname, char *value, char *errorbuf, int return retVal; } -size_t +int32_t config_get_maxsasliosize() { - size_t maxsasliosize; + int32_t maxsasliosize; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); maxsasliosize = slapdFrontendConfig->maxsasliosize; diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index e1493bb..46294c2 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -698,7 +698,7 @@ main(int argc, char **argv) } else if (secs > 3600) { secs = 3600; } - printf("slapd pid is %d - sleeping for %ld\n", getpid(), secs); + printf("slapd pid is %d - sleeping for %" PRId64 "\n", getpid(), secs); sleep(secs); } } diff --git a/ldap/servers/slapd/monitor.c b/ldap/servers/slapd/monitor.c index a281608..68c4864 100644 --- a/ldap/servers/slapd/monitor.c +++ b/ldap/servers/slapd/monitor.c @@ -59,7 +59,7 @@ monitor_info(Slapi_PBlock *pb __attribute__((unused)), attrlist_replace(&e->e_attrs, "version", vals); slapi_ch_free((void **)&val.bv_val); - val.bv_len = snprintf(buf, sizeof(buf), "%lu", g_get_active_threadcnt()); + val.bv_len = snprintf(buf, sizeof(buf), "%" PRIu64, g_get_active_threadcnt()); val.bv_val = buf; attrlist_replace(&e->e_attrs, "threads", vals); diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h index f54bc6b..98449dc 100644 --- a/ldap/servers/slapd/proto-slap.h +++ b/ldap/servers/slapd/proto-slap.h @@ -491,7 +491,7 @@ char *config_get_referral_mode(void); int config_get_conntablesize(void); int config_check_referral_mode(void); ber_len_t config_get_maxbersize(void); -size_t config_get_maxsasliosize(void); +int32_t config_get_maxsasliosize(void); char *config_get_versionstring(void); char *config_get_buildnum(void); int config_get_enquote_sup_oc(void); diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c index 6892ccf..d9f431c 100644 --- a/ldap/servers/slapd/result.c +++ b/ldap/servers/slapd/result.c @@ -1920,7 +1920,7 @@ log_result(Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag, int nentries struct timespec o_hr_time_end; slapi_operation_time_elapsed(op, &o_hr_time_end); - snprintf(etime, ETIME_BUFSIZ, "%" PRId64 ".%010" PRId64 "", o_hr_time_end.tv_sec, o_hr_time_end.tv_nsec); + snprintf(etime, ETIME_BUFSIZ, "%" PRId64 ".%010" PRId64 "", (int64_t)o_hr_time_end.tv_sec, (int64_t)o_hr_time_end.tv_nsec); slapi_pblock_get(pb, SLAPI_OPERATION_NOTES, &operation_notes); diff --git a/ldap/servers/slapd/sasl_io.c b/ldap/servers/slapd/sasl_io.c index 5fe37dc..5ef56ce 100644 --- a/ldap/servers/slapd/sasl_io.c +++ b/ldap/servers/slapd/sasl_io.c @@ -46,13 +46,13 @@ MOZLDAP is newer than expected, if the ber structure has not changed(see ldap / struct PRFilePrivate { char *decrypted_buffer; - size_t decrypted_buffer_size; - size_t decrypted_buffer_count; - size_t decrypted_buffer_offset; + uint32_t decrypted_buffer_size; + uint32_t decrypted_buffer_count; + uint32_t decrypted_buffer_offset; char *encrypted_buffer; - size_t encrypted_buffer_size; - size_t encrypted_buffer_count; - size_t encrypted_buffer_offset; + uint32_t encrypted_buffer_size; + uint32_t encrypted_buffer_count; + uint32_t encrypted_buffer_offset; Connection *conn; /* needed for connid and sasl_conn context */ PRBool send_encrypted; /* can only send encrypted data after the first read - that is, we cannot send back an encrypted response @@ -130,7 +130,7 @@ sasl_io_init_buffers(sasl_io_private *sp) static void -sasl_io_resize_encrypted_buffer(sasl_io_private *sp, size_t requested_size) +sasl_io_resize_encrypted_buffer(sasl_io_private *sp, uint32_t requested_size) { if (requested_size > sp->encrypted_buffer_size) { sp->encrypted_buffer = slapi_ch_realloc(sp->encrypted_buffer, requested_size); @@ -139,7 +139,7 @@ sasl_io_resize_encrypted_buffer(sasl_io_private *sp, size_t requested_size) } static void -sasl_io_resize_decrypted_buffer(sasl_io_private *sp, size_t requested_size) +sasl_io_resize_decrypted_buffer(sasl_io_private *sp, uint32_t requested_size) { if (requested_size > sp->decrypted_buffer_size) { sp->decrypted_buffer = slapi_ch_realloc(sp->decrypted_buffer, requested_size); @@ -189,10 +189,10 @@ sasl_io_start_packet(PRFileDesc *fd, PRIntn flags, PRIntervalTime timeout, PRInt unsigned char buffer[SASL_IO_BUFFER_START_SIZE]; sasl_io_private *sp = sasl_get_io_private(fd); Connection *c = sp->conn; - PRInt32 amount = sizeof(buffer); - PRInt32 ret = 0; - size_t packet_length = 0; - size_t saslio_limit; + int32_t amount = sizeof(buffer); + int32_t ret = 0; + uint32_t packet_length = 0; + int32_t saslio_limit; *err = 0; debug_print_layers(fd); @@ -404,15 +404,15 @@ sasl_io_start_packet(PRFileDesc *fd, PRIntn flags, PRIntervalTime timeout, PRInt packet_length += sizeof(uint32_t); slapi_log_err(SLAPI_LOG_CONNS, "sasl_io_start_packet", - "read sasl packet length %ld on connection %" PRIu64 "\n", + "read sasl packet length %" PRIu32 " on connection %" PRIu64 "\n", packet_length, c->c_connid); /* Check if the packet length is larger than our max allowed. A * setting of -1 means that we allow any size SASL IO packet. */ saslio_limit = config_get_maxsasliosize(); - if (((long)saslio_limit != -1) && (packet_length > saslio_limit)) { + if ((saslio_limit != -1) && (packet_length > saslio_limit)) { slapi_log_err(SLAPI_LOG_ERR, "sasl_io_start_packet", - "SASL encrypted packet length exceeds maximum allowed limit (length=%ld, limit=%ld)." + "SASL encrypted packet length exceeds maximum allowed limit (length=%" PRIu32 ", limit=%" PRIu32 ")." " Change the nsslapd-maxsasliosize attribute in cn=config to increase limit.\n", packet_length, config_get_maxsasliosize()); PR_SetError(PR_BUFFER_OVERFLOW_ERROR, 0); @@ -434,10 +434,10 @@ sasl_io_read_packet(PRFileDesc *fd, PRIntn flags, PRIntervalTime timeout, PRInt3 PRInt32 ret = 0; sasl_io_private *sp = sasl_get_io_private(fd); Connection *c = sp->conn; - size_t bytes_remaining_to_read = sp->encrypted_buffer_count - sp->encrypted_buffer_offset; + uint32_t bytes_remaining_to_read = sp->encrypted_buffer_count - sp->encrypted_buffer_offset; slapi_log_err(SLAPI_LOG_CONNS, - "sasl_io_read_packet", "Reading %lu bytes for connection %" PRIu64 "\n", + "sasl_io_read_packet", "Reading %" PRIu32" bytes for connection %" PRIu64 "\n", bytes_remaining_to_read, c->c_connid); ret = PR_Recv(fd->lower, sp->encrypted_buffer + sp->encrypted_buffer_offset, bytes_remaining_to_read, flags, timeout); if (ret <= 0) { @@ -461,17 +461,17 @@ sasl_io_recv(PRFileDesc *fd, void *buf, PRInt32 len, PRIntn flags, PRIntervalTim { sasl_io_private *sp = sasl_get_io_private(fd); Connection *c = sp->conn; - PRInt32 ret = 0; - size_t bytes_in_buffer = 0; - PRInt32 err = 0; + int32_t ret = 0; + uint32_t bytes_in_buffer = 0; + int32_t err = 0; /* Do we have decrypted data buffered from 'before' ? */ bytes_in_buffer = sp->decrypted_buffer_count - sp->decrypted_buffer_offset; slapi_log_err(SLAPI_LOG_CONNS, "sasl_io_recv", - "Connection %" PRIu64 " len %d bytes_in_buffer %lu\n", + "Connection %" PRIu64 " len %d bytes_in_buffer %" PRIu32 "\n", c->c_connid, len, bytes_in_buffer); slapi_log_err(SLAPI_LOG_CONNS, "sasl_io_recv", - "Connection %" PRIu64 " len %d encrypted buffer count %lu\n", + "Connection %" PRIu64 " len %d encrypted buffer count %" PRIu32 "\n", c->c_connid, len, sp->encrypted_buffer_count); if (0 == bytes_in_buffer) { /* If there wasn't buffered decrypted data, we need to get some... */ @@ -546,7 +546,7 @@ sasl_io_recv(PRFileDesc *fd, void *buf, PRInt32 len, PRIntn flags, PRIntervalTim } /* Finally, return data from the buffer to the caller */ { - size_t bytes_to_return = sp->decrypted_buffer_count - sp->decrypted_buffer_offset; + uint32_t bytes_to_return = sp->decrypted_buffer_count - sp->decrypted_buffer_offset; if (bytes_to_return > len) { bytes_to_return = len; } @@ -560,7 +560,7 @@ sasl_io_recv(PRFileDesc *fd, void *buf, PRInt32 len, PRIntn flags, PRIntervalTim } else { sp->decrypted_buffer_offset += bytes_to_return; slapi_log_err(SLAPI_LOG_CONNS, "sasl_io_recv", - "Returning %lu bytes to caller %lu bytes left to return for connection %" PRIu64 "\n", + "Returning %" PRIu32 " bytes to caller %" PRIu32 " bytes left to return for connection %" PRIu64 "\n", bytes_to_return, sp->decrypted_buffer_count - sp->decrypted_buffer_offset, c->c_connid); } ret = bytes_to_return; diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index de4ac35..7378c2d 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -2428,7 +2428,7 @@ typedef struct _slapdFrontendConfig int localssf; /* the security strength factor to assign to local conns (ldapi) */ int minssf; /* minimum security strength factor (for SASL and SSL/TLS) */ slapi_onoff_t minssf_exclude_rootdse; /* ON: minssf is ignored when searching rootdse */ - size_t maxsasliosize; /* limit incoming SASL IO packet size */ + int32_t maxsasliosize; /* limit incoming SASL IO packet size */ char *anon_limits_dn; /* template entry for anonymous resource limits */ slapi_int_t listen_backlog_size; /* size of backlog parameter to PR_Listen */ struct passwd *localuserinfo; /* userinfo of localuser */ @@ -2443,7 +2443,7 @@ typedef struct _slapdFrontendConfig /* disk monitoring */ slapi_onoff_t disk_monitoring; - PRInt64 disk_threshold; + uint64_t disk_threshold; int disk_grace_period; slapi_onoff_t disk_logging_critical; diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h index 33e2b95..0646cdf 100644 --- a/ldap/servers/slapd/slapi-plugin.h +++ b/ldap/servers/slapd/slapi-plugin.h @@ -5834,7 +5834,7 @@ char *slapi_ch_malloc(unsigned long size); * \param alignment The alignment. MUST be a power of 2! * \return Pointer to the allocated memory aligned by alignment. */ -char *slapi_ch_memalign(size_t size, size_t alignment); +char *slapi_ch_memalign(uint32_t size, uint32_t alignment); char *slapi_ch_realloc(char *block, unsigned long size); char *slapi_ch_calloc(unsigned long nelem, unsigned long size); char *slapi_ch_strdup(const char *s); diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h index b08c0d7..b347b61 100644 --- a/ldap/servers/slapd/slapi-private.h +++ b/ldap/servers/slapd/slapi-private.h @@ -376,7 +376,7 @@ char *slapi_dn_normalize_case_original(char *dn); int32_t ndn_cache_init(void); void ndn_cache_destroy(void); int ndn_cache_started(void); -void ndn_cache_get_stats(PRUint64 *hits, PRUint64 *tries, size_t *size, size_t *max_size, size_t *thread_size, size_t *evicts, size_t *slots, long *count); +void ndn_cache_get_stats(uint64_t *hits, uint64_t *tries, uint64_t *size, uint64_t *max_size, uint64_t *thread_size, uint64_t *evicts, uint64_t *slots, uint64_t *count); #define NDN_DEFAULT_SIZE 20971520 /* 20mb - size of normalized dn cache */ /* filter.c */ diff --git a/ldap/servers/slapd/tools/dbscan.c b/ldap/servers/slapd/tools/dbscan.c index f4001d2..b2c0b07 100644 --- a/ldap/servers/slapd/tools/dbscan.c +++ b/ldap/servers/slapd/tools/dbscan.c @@ -81,13 +81,13 @@ #include #endif -typedef PRUint32 ID; +typedef uint32_t ID; typedef struct { - PRUint32 max; - PRUint32 used; - PRUint32 id[1]; + uint32_t max; + uint32_t used; + uint32_t id[1]; } IDL; #define RDN_BULK_FETCH_BUFFER_SIZE (8 * 1024) @@ -109,9 +109,9 @@ static void display_entryrdn_self(DB *db, ID id, const char *nrdn, int indent); static void display_entryrdn_children(DB *db, ID id, const char *nrdn, int indent); static void display_entryrdn_item(DB *db, DBC *cursor, DBT *key); -PRUint32 file_type = 0; -PRUint32 min_display = 0; -PRUint32 display_mode = 0; +uint32_t file_type = 0; +uint32_t min_display = 0; +uint32_t display_mode = 0; int truncatesiz = 0; long pres_cnt = 0; long eq_cnt = 0; @@ -145,15 +145,15 @@ db_printfln(char *fmt, ...) fprintf(stdout, "\n"); } -size_t MAX_BUFFER = 4096; -size_t MIN_BUFFER = 20; +uint32_t MAX_BUFFER = 4096; +uint32_t MIN_BUFFER = 20; static IDL * idl_make(DBT *data) { IDL *idl = NULL, *xidl; - if (data->size < 2 * sizeof(PRUint32)) { + if (data->size < 2 * sizeof(uint32_t)) { idl = (IDL *)malloc(sizeof(IDL) + 64 * sizeof(ID)); if (!idl) return NULL; @@ -360,7 +360,7 @@ _cl5ReadMods(char **buff) { char *pos = *buff; ID i; - PRUint32 mod_count; + uint32_t mod_count; /* need to copy first, to skirt around alignment problems on certain architectures */ @@ -384,7 +384,7 @@ void print_ber_attr(char *attrname, char **buff) { char *val = NULL; - PRUint32 bv_len; + uint32_t bv_len; memcpy((char *)&bv_len, *buff, sizeof(bv_len)); bv_len = ntohl(bv_len); @@ -447,8 +447,8 @@ void _cl5ReadMod(char **buff) { char *pos = *buff; - PRUint32 i; - PRUint32 val_count; + uint32_t i; + uint32_t val_count; char *type = NULL; pos++; @@ -458,7 +458,7 @@ _cl5ReadMod(char **buff) certain architectures */ memcpy((char *)&val_count, pos, sizeof(val_count)); val_count = ntohl(val_count); - pos += sizeof(PRUint32); + pos += sizeof(uint32_t); for (i = 0; i < val_count; i++) { print_ber_attr(type, &pos); @@ -473,14 +473,14 @@ void print_ruv(unsigned char *buff) { char *pos = (char *)buff; - PRUint32 i; - PRUint32 val_count; + uint32_t i; + uint32_t val_count; /* need to do the copy first, to skirt around alignment problems on certain architectures */ memcpy((char *)&val_count, pos, sizeof(val_count)); val_count = ntohl(val_count); - pos += sizeof(PRUint32); + pos += sizeof(uint32_t); for (i = 0; i < val_count; i++) { print_ber_attr(NULL, &pos); @@ -491,11 +491,11 @@ print_ruv(unsigned char *buff) *** Copied from cl5_api:cl5DBData2Entry *** Data in db format: ------------------ - <1 byte version><1 byte change_type> + <1 byte version><1 byte change_type> [<1 byte deleteoldrdn>][<4 byte mod count>....] -Note: the length of time is set PRUint32 instead of time_t. Regardless of the +Note: the length of time is set uint32_t instead of time_t. Regardless of the width of long (32-bit or 64-bit), it's stored using 4bytes by the server [153306]. mod format: @@ -509,9 +509,9 @@ print_changelog(unsigned char *data, int len __attribute__((unused))) uint8_t version; unsigned long operation_type; char *pos = (char *)data; - PRUint32 thetime32; + uint32_t thetime32; time_t thetime; - PRUint32 replgen; + uint32_t replgen; /* read byte of version */ version = *((uint8_t *)pos); @@ -530,7 +530,7 @@ print_changelog(unsigned char *data, int len __attribute__((unused))) memcpy((char *)&thetime32, pos, sizeof(thetime32)); replgen = ntohl(thetime32); - pos += sizeof(PRUint32); + pos += sizeof(uint32_t); thetime = (time_t)replgen; db_printf("\treplgen: %ld %s", replgen, ctime((time_t *)&thetime)); @@ -608,7 +608,7 @@ display_index_item(DBC *cursor, DBT *key, DBT *data, unsigned char *buf, int buf while (ret == 0) { ret = cursor->c_get(cursor, key, data, DB_NEXT_DUP); if (ret == 0) - idl = idl_append(idl, *(PRUint32 *)(data->data)); + idl = idl_append(idl, *(uint32_t *)(data->data)); } if (ret == DB_NOTFOUND) ret = 0; @@ -944,7 +944,7 @@ display_entryrdn_item(DB *db, DBC *cursor, DBT *key) int indent = 2; DBT data; int rc; - PRUint32 flags = 0; + uint32_t flags = 0; char buffer[RDN_BULK_FETCH_BUFFER_SIZE]; DBT dataret; int find_key_flag = 0; @@ -1102,7 +1102,7 @@ usage(char *argv0) printf(" index file options:\n"); printf(" -k lookup only a specific key\n"); printf(" -l max length of dumped id list\n"); - printf(" (default %lu; 40 bytes <= size <= 1048576 bytes)\n", MAX_BUFFER); + printf(" (default %" PRIu32 "; 40 bytes <= size <= 1048576 bytes)\n", MAX_BUFFER); printf(" -G only display index entries with more than ids\n"); printf(" -n display ID list lengths\n"); printf(" -r display the conents of ID list\n"); @@ -1132,7 +1132,7 @@ main(int argc, char **argv) DBT key = {0}, data = {0}; int ret; char *find_key = NULL; - PRUint32 entry_id = 0xffffffff; + uint32_t entry_id = 0xffffffff; int c; key.flags = DB_DBT_REALLOC; @@ -1146,7 +1146,7 @@ main(int argc, char **argv) display_mode |= RAWDATA; break; case 'l': { - PRUint32 tmpmaxbufsz = atoi(optarg); + uint32_t tmpmaxbufsz = atoi(optarg); if (tmpmaxbufsz > ONEMEG) { tmpmaxbufsz = ONEMEG; printf("WARNING: max length of dumped id list too long, " diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c index 95cc261..1e64705 100644 --- a/ldap/servers/snmp/main.c +++ b/ldap/servers/snmp/main.c @@ -71,7 +71,7 @@ main(int argc, char *argv[]) } else if (secs > 3600) { secs = 3600; } - printf("%s pid is %d - sleeping for %ld\n", argv[0], getpid(), secs); + printf("%s pid is %d - sleeping for %" PRId64 "\n", argv[0], getpid(), secs); sleep(secs); } } diff --git a/src/libsds/sds/bpt/map.c b/src/libsds/sds/bpt/map.c index 096a38b..ae528f3 100644 --- a/src/libsds/sds/bpt/map.c +++ b/src/libsds/sds/bpt/map.c @@ -294,8 +294,8 @@ sds_node_to_dot(sds_bptree_instance *binst __attribute__((unused)), sds_bptree_n // Given the node write it out as: fprintf(fp, "subgraph c%" PRIu32 " { \n rank=\"same\";\n", node->level); fprintf(fp, " node_%p [label =\" { node=%p items=%d txn=%" PRIu64 " parent=%p | { ", node, node, node->item_count, node->txn_id, node->parent); - for (size_t i = 0; i < SDS_BPTREE_DEFAULT_CAPACITY; i++) { - fprintf(fp, "| %" PRIu64 " | ", (uint64_t)node->keys[i], i + 1); + for (uint64_t i = 0; i < SDS_BPTREE_DEFAULT_CAPACITY; i++) { + fprintf(fp, "| %" PRIu64 " | ", (uint64_t)((uintptr_t)node->keys[i]), i + 1); } fprintf(fp, "}}\"]; \n}\n"); return SDS_SUCCESS; @@ -312,7 +312,7 @@ sds_node_ptrs_to_dot(sds_bptree_instance *binst __attribute__((unused)), sds_bpt fprintf(fp, "\"node_%p\" -> \"node_%p\"; \n", node, node->values[SDS_BPTREE_DEFAULT_CAPACITY]); } } else { - for (size_t i = 0; i < SDS_BPTREE_BRANCH; i++) { + for (uint64_t i = 0; i < SDS_BPTREE_BRANCH; i++) { if (node->values[i] != NULL) { if (i == SDS_BPTREE_DEFAULT_CAPACITY) { // Work around a graphviz display issue, with Left and Right pointers @@ -332,7 +332,7 @@ sds_bptree_display(sds_bptree_instance *binst) { sds_result result = SDS_SUCCESS; - char *path = malloc(sizeof(char) * 20); + char *path = malloc(sizeof(char) * 21); #ifdef SDS_DEBUG sds_log("sds_bptree_display", "Writing step %03d\n", binst->print_iter); #endif diff --git a/src/libsds/sds/bpt_cow/bpt_cow.c b/src/libsds/sds/bpt_cow/bpt_cow.c index 0b6f229..c2ab607 100644 --- a/src/libsds/sds/bpt_cow/bpt_cow.c +++ b/src/libsds/sds/bpt_cow/bpt_cow.c @@ -527,8 +527,8 @@ sds_node_to_dot(sds_bptree_instance *binst __attribute__((unused)), sds_bptree_n // Given the node write it out as: fprintf(fp, "subgraph c%" PRIu32 " { \n rank=\"same\";\n", node->level); fprintf(fp, " node_%p [label =\" { node=%p items=%d txn=%" PRIu64 " parent=%p | { ", node, node, node->item_count, node->txn_id, node->parent); - for (size_t i = 0; i < SDS_BPTREE_DEFAULT_CAPACITY; i++) { - fprintf(fp, "| %" PRIu64 " | ", (uint64_t)node->keys[i], i + 1); + for (uint64_t i = 0; i < SDS_BPTREE_DEFAULT_CAPACITY; i++) { + fprintf(fp, "| %" PRIu64 " | ", (uint64_t)((uintptr_t)node->keys[i]), i + 1); } fprintf(fp, "}}\"]; \n}\n"); return SDS_SUCCESS; @@ -545,7 +545,7 @@ sds_node_ptrs_to_dot(sds_bptree_instance *binst __attribute__((unused)), sds_bpt fprintf(fp, "\"node_%p\" -> \"node_%p\"; \n", node, node->values[SDS_BPTREE_DEFAULT_CAPACITY]); } } else { - for (size_t i = 0; i < SDS_BPTREE_BRANCH; i++) { + for (uint64_t i = 0; i < SDS_BPTREE_BRANCH; i++) { if (node->values[i] != NULL) { if (i == SDS_BPTREE_DEFAULT_CAPACITY) { // Work around a graphviz display issue, with Left and Right pointers @@ -566,7 +566,7 @@ sds_bptree_cow_display(sds_bptree_transaction *btxn) { sds_result result = SDS_SUCCESS; - char *path = malloc(sizeof(char) * 20); + char *path = malloc(sizeof(char) * 36); print_iter += 1; #ifdef SDS_DEBUG sds_log("sds_bptree_cow_display", "Writing step %03d\n", print_iter);