Wednesday, March 28, 2018

[389-commits] [389-ds-base] 01/01: Ticket 46918 - Fix compiler warnings on arm

This is an automated email from the git hooks/post-receive script.

mreynolds pushed a commit to branch master
in repository 389-ds-base.

commit 5e383c8152d1273ff3df11578d4c9a94850ca60a
Author: Mark Reynolds <mreynolds@redhat.com>
Date: Wed Mar 28 14:28:42 2018 -0400

Ticket 46918 - Fix compiler warnings on arm

Description: On "arm" architecture there were many compiler warnings
and after fixing some it also adressed a crash in replication
when trying to update the agreement maxcsn.

All updatream architectures build without compilar warnings,
and coverity scan did not report any regressions.

https://pagure.io/389-ds-base/issue/49618

Reviewed by: simon(Thanks!)
---
ldap/servers/plugins/posix-winsync/posix-winsync.c | 2 +-
ldap/servers/plugins/replication/repl5_agmt.c | 22 ++--
ldap/servers/plugins/replication/repl5_replica.c | 20 +--
ldap/servers/plugins/replication/replutil.c | 2 +-
ldap/servers/slapd/abandon.c | 2 +-
ldap/servers/slapd/back-ldbm/back-ldbm.h | 70 ++++-------
ldap/servers/slapd/back-ldbm/cache.c | 16 +--
ldap/servers/slapd/back-ldbm/dblayer.c | 137 +++++++++++++++------
ldap/servers/slapd/back-ldbm/dblayer.h | 8 +-
ldap/servers/slapd/back-ldbm/filterindex.c | 6 +-
ldap/servers/slapd/back-ldbm/idl_new.c | 16 +--
ldap/servers/slapd/back-ldbm/import-threads.c | 14 +--
ldap/servers/slapd/back-ldbm/ldbm_add.c | 10 +-
ldap/servers/slapd/back-ldbm/ldbm_config.c | 68 +++++++---
ldap/servers/slapd/back-ldbm/ldbm_config.h | 16 ++-
ldap/servers/slapd/back-ldbm/ldbm_delete.c | 26 ++--
.../servers/slapd/back-ldbm/ldbm_instance_config.c | 8 +-
ldap/servers/slapd/back-ldbm/ldbm_modrdn.c | 18 +--
ldap/servers/slapd/back-ldbm/monitor.c | 39 +++---
ldap/servers/slapd/back-ldbm/proto-back-ldbm.h | 17 +--
ldap/servers/slapd/back-ldbm/start.c | 12 +-
ldap/servers/slapd/ch_malloc.c | 9 +-
ldap/servers/slapd/conntable.c | 2 +-
ldap/servers/slapd/daemon.c | 6 +-
ldap/servers/slapd/dn.c | 33 +++--
ldap/servers/slapd/libglobs.c | 4 +-
ldap/servers/slapd/main.c | 2 +-
ldap/servers/slapd/monitor.c | 2 +-
ldap/servers/slapd/proto-slap.h | 2 +-
ldap/servers/slapd/result.c | 2 +-
ldap/servers/slapd/sasl_io.c | 48 ++++----
ldap/servers/slapd/slap.h | 4 +-
ldap/servers/slapd/slapi-plugin.h | 3 +-
ldap/servers/slapd/slapi-private.h | 2 +-
ldap/servers/slapd/tools/dbscan.c | 58 ++++-----
ldap/servers/snmp/main.c | 2 +-
src/libsds/sds/bpt/map.c | 8 +-
src/libsds/sds/bpt_cow/bpt_cow.c | 8 +-
38 files changed, 398 insertions(+), 326 deletions(-)

diff --git a/ldap/servers/plugins/posix-winsync/posix-winsync.c b/ldap/servers/plugins/posix-winsync/posix-winsync.c
index 07e4804..8e5ca4f 100644
--- a/ldap/servers/plugins/posix-winsync/posix-winsync.c
+++ b/ldap/servers/plugins/posix-winsync/posix-winsync.c
@@ -318,7 +318,7 @@ sync_acct_disable(void *cbdata __attribute__((unused)), /* the usual domain conf
mask = 0x2;
adval |= mask; /* set the 0x2 disable bit */
}
- PR_snprintf(acctvalstr, sizeof(acctvalstr), "%lu", adval);
+ PR_snprintf(acctvalstr, sizeof(acctvalstr), "%" PRIu64, adval);
slapi_ch_free_string(&mod_bval->bv_val);
mod_bval->bv_val = slapi_ch_strdup(acctvalstr);
mod_bval->bv_len = strlen(acctvalstr);
diff --git a/ldap/servers/plugins/replication/repl5_agmt.c b/ldap/servers/plugins/replication/repl5_agmt.c
index d71d3f3..9c88d58 100644
--- a/ldap/servers/plugins/replication/repl5_agmt.c
+++ b/ldap/servers/plugins/replication/repl5_agmt.c
@@ -182,25 +182,25 @@ agmt_is_valid(Repl_Agmt *ra)
}
if (ra->port <= 0) {
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "agmt_is_valid - Replication agreement \"%s\" "
- "is malformed: invalid port number %ld.\n",
+ "is malformed: invalid port number %" PRId64 ".\n",
slapi_sdn_get_dn(ra->dn), ra->port);
return_value = 0;
}
if (ra->timeout < 0) {
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "agmt_is_valid - Replication agreement \"%s\" "
- "is malformed: invalid timeout %ld.\n",
+ "is malformed: invalid timeout %" PRId64 ".\n",
slapi_sdn_get_dn(ra->dn), ra->timeout);
return_value = 0;
}
if (ra->busywaittime < 0) {
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "agmt_is_valid - Replication agreement \"%s\" "
- "is malformed: invalid busy wait time %ld.\n",
+ "is malformed: invalid busy wait time %" PRId64 ".\n",
slapi_sdn_get_dn(ra->dn), ra->busywaittime);
return_value = 0;
}
if (ra->pausetime < 0) {
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "agmt_is_valid - Replication agreement \"%s\" "
- "is malformed: invalid pausetime %ld.\n",
+ "is malformed: invalid pausetime %" PRId64 ".\n",
slapi_sdn_get_dn(ra->dn), ra->pausetime);
return_value = 0;
}
@@ -468,7 +468,7 @@ agmt_new_from_entry(Slapi_Entry *e)
if (dot) {
*dot = '\0';
}
- ra->long_name = slapi_ch_smprintf("agmt=\"%s\" (%s:%ld)", agmtname, hostname, ra->port);
+ ra->long_name = slapi_ch_smprintf("agmt=\"%s\" (%s:%" PRId64 ")", agmtname, hostname, ra->port);
}

/* DBDB: review this code */
@@ -791,10 +791,10 @@ agmt_start(Repl_Agmt *ra)
char buf[BUFSIZ];
char unavail_buf[BUFSIZ];

- PR_snprintf(buf, BUFSIZ, "%s;%s;%s;%ld;", slapi_sdn_get_dn(repl_sdn),
+ PR_snprintf(buf, BUFSIZ, "%s;%s;%s;%" PRId64 ";", slapi_sdn_get_dn(repl_sdn),
slapi_rdn_get_value_by_ref(slapi_rdn_get_rdn(ra->rdn)),
ra->hostname, ra->port);
- PR_snprintf(unavail_buf, BUFSIZ, "%s;%s;%s;%ld;unavailable", slapi_sdn_get_dn(repl_sdn),
+ PR_snprintf(unavail_buf, BUFSIZ, "%s;%s;%s;%" PRId64 ";unavailable", slapi_sdn_get_dn(repl_sdn),
slapi_rdn_get_value_by_ref(slapi_rdn_get_rdn(ra->rdn)),
ra->hostname, ra->port);
if (strstr(maxcsns[i], buf) || strstr(maxcsns[i], unavail_buf)) {
@@ -3029,11 +3029,11 @@ agmt_update_maxcsn(Replica *r, Slapi_DN *sdn, int op, LDAPMod **mods, CSN *csn)
* temporarily mark it as "unavailable".
*/
slapi_ch_free_string(&agmt->maxcsn);
- agmt->maxcsn = slapi_ch_smprintf("%s;%s;%s;%ld;unavailable", slapi_sdn_get_dn(agmt->replarea),
+ agmt->maxcsn = slapi_ch_smprintf("%s;%s;%s;%" PRId64 ";unavailable", slapi_sdn_get_dn(agmt->replarea),
slapi_rdn_get_value_by_ref(slapi_rdn_get_rdn(agmt->rdn)), agmt->hostname, agmt->port);
} else if (rid == oprid) {
slapi_ch_free_string(&agmt->maxcsn);
- agmt->maxcsn = slapi_ch_smprintf("%s;%s;%s;%ld;%d;%s", slapi_sdn_get_dn(agmt->replarea),
+ agmt->maxcsn = slapi_ch_smprintf("%s;%s;%s;%" PRId64 ";%" PRIu16 ";%s", slapi_sdn_get_dn(agmt->replarea),
slapi_rdn_get_value_by_ref(slapi_rdn_get_rdn(agmt->rdn)), agmt->hostname,
agmt->port, agmt->consumerRID, maxcsn);
}
@@ -3227,10 +3227,10 @@ agmt_remove_maxcsn(Repl_Agmt *ra)
char unavail_buf[BUFSIZ];
struct berval val;

- PR_snprintf(buf, BUFSIZ, "%s;%s;%s;%ld;", slapi_sdn_get_dn(ra->replarea),
+ PR_snprintf(buf, BUFSIZ, "%s;%s;%s;%" PRId64 ";", slapi_sdn_get_dn(ra->replarea),
slapi_rdn_get_value_by_ref(slapi_rdn_get_rdn(ra->rdn)),
ra->hostname, ra->port);
- PR_snprintf(unavail_buf, BUFSIZ, "%s;%s;%s;%ld;unavailable",
+ PR_snprintf(unavail_buf, BUFSIZ, "%s;%s;%s;%" PRId64 ";unavailable",
slapi_sdn_get_dn(ra->replarea),
slapi_rdn_get_value_by_ref(slapi_rdn_get_rdn(ra->rdn)),
ra->hostname, ra->port);
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 5473d5b..2738b7a 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -72,8 +72,8 @@ struct replica
typedef struct reap_callback_data
{
int rc;
- unsigned long num_entries;
- unsigned long num_purged_entries;
+ uint64_t num_entries;
+ uint64_t num_purged_entries;
CSN *purge_csn;
PRBool *tombstone_reap_stop;
} reap_callback_data;
@@ -1897,7 +1897,7 @@ _replica_init_from_config(Replica *r, Slapi_Entry *e, char *errortext)
/* Verify backoff min and max work together */
if (backoff_min > backoff_max) {
PR_snprintf(errormsg, SLAPI_DSE_RETURNTEXT_SIZE,
- "Backoff minimum (%ld) can not be greater than the backoff maximum (%ld).",
+ "Backoff minimum (%" PRId64 ") can not be greater than the backoff maximum (%" PRId64 ").",
backoff_min, backoff_max);
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "_replica_init_from_config - "
"%s\n", errormsg);
@@ -2996,8 +2996,8 @@ process_reap_entry(Slapi_Entry *entry, void *cb_data)
{
char deletion_csn_str[CSN_STRSIZE];
char purge_csn_str[CSN_STRSIZE];
- unsigned long *num_entriesp = &((reap_callback_data *)cb_data)->num_entries;
- unsigned long *num_purged_entriesp = &((reap_callback_data *)cb_data)->num_purged_entries;
+ uint64_t *num_entriesp = &((reap_callback_data *)cb_data)->num_entries;
+ uint64_t *num_purged_entriesp = &((reap_callback_data *)cb_data)->num_purged_entries;
CSN *purge_csn = ((reap_callback_data *)cb_data)->purge_csn;
/* this is a pointer into the actual value in the Replica object - so that
if the value is set in the replica, we will know about it immediately */
@@ -3181,14 +3181,14 @@ _replica_reap_tombstones(void *arg)
if (LDAP_SUCCESS != oprc) {
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
"_replica_reap_tombstones - Failed when searching for "
- "tombstones in replica %s: %s. Will try again in %ld "
+ "tombstones in replica %s: %s. Will try again in %" PRId64 " "
"seconds.\n",
slapi_sdn_get_dn(replica->repl_root),
ldap_err2string(oprc), replica->tombstone_reap_interval);
} else {
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "_replica_reap_tombstones - Purged %ld of %ld tombstones "
- "in replica %s. Will try again in %ld "
+ "_replica_reap_tombstones - Purged %" PRIu64 " of %" PRIu64 " tombstones "
+ "in replica %s. Will try again in %" PRId64 " "
"seconds.\n",
cb_data.num_purged_entries, cb_data.num_entries,
slapi_sdn_get_dn(replica->repl_root),
@@ -3617,7 +3617,7 @@ replica_set_tombstone_reap_interval(Replica *r, long interval)

found = slapi_eq_cancel(r->repl_eqcxt_tr);
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "replica_set_tombstone_reap_interval - tombstone_reap event (interval=%ld) was %s\n",
+ "replica_set_tombstone_reap_interval - tombstone_reap event (interval=%" PRId64 ") was %s\n",
r->tombstone_reap_interval, (found ? "cancelled" : "not found"));
r->repl_eqcxt_tr = NULL;
}
@@ -3627,7 +3627,7 @@ replica_set_tombstone_reap_interval(Replica *r, long interval)
slapi_current_utc_time() + r->tombstone_reap_interval,
1000 * r->tombstone_reap_interval);
slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
- "replica_set_tombstone_reap_interval - tombstone_reap event (interval=%ld) was %s\n",
+ "replica_set_tombstone_reap_interval - tombstone_reap event (interval=%" PRId64 ") was %s\n",
r->tombstone_reap_interval, (r->repl_eqcxt_tr ? "scheduled" : "not scheduled successfully"));
}
replica_unlock(r->repl_lock);
diff --git a/ldap/servers/plugins/replication/replutil.c b/ldap/servers/plugins/replication/replutil.c
index 7cc1323..a852f24 100644
--- a/ldap/servers/plugins/replication/replutil.c
+++ b/ldap/servers/plugins/replication/replutil.c
@@ -1076,7 +1076,7 @@ repl_config_valid_num(const char *config_attr, char *config_attr_value, int64_t
*returncode = LDAP_UNWILLING_TO_PERFORM;
if (errortext){
PR_snprintf(errortext, SLAPI_DSE_RETURNTEXT_SIZE,
- "Attribute %s value (%s) is invalid, must be a number between %ld and %ld.",
+ "Attribute %s value (%s) is invalid, must be a number between %" PRId64 " and %" PRId64 ".",
config_attr, config_attr_value, min, max);
slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "repl_config_valid_num - %s\n",
errortext);
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..ffc803e 100644
--- a/ldap/servers/slapd/back-ldbm/back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h
@@ -351,7 +351,7 @@ struct backdn
ID ep_id; /* entry id */
char ep_state; /* state in the cache; share ENTRY_STATE_* */
int ep_refcnt; /* entry reference cnt */
- size_t ep_size; /* for cache tracking */
+ uint64_t ep_size; /* for cache tracking */
Slapi_DN *dn_sdn;
void *dn_id_link; /* for hash table */
};
@@ -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 */
+ uint64_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
@@ -551,63 +551,45 @@ struct ldbminfo
int li_allidsthreshold;
char *li_directory;
int li_reslimit_lookthrough_handle;
- size_t li_dbcachesize;
+ uint64_t li_dbcachesize;
int li_dblock;
int li_dbncache;
- int li_import_cache_autosize; /* % of free memory to use
- * for the import caches
- * (-1=default, 80% on cmd import)
- * (0 = off) -- overrides
- * import cache size settings */
- int li_cache_autosize; /* % of free memory to use
- * for the combined caches
- * (0 = off) -- overrides
- * other cache size settings */
- int li_cache_autosize_split; /* % of li_cache_autosize to
- * use for the libdb cache.
- * the rest is split up among
- * the instance entry caches */
- uint64_t li_cache_autosize_ec; /* new instances created while
- * the server is up, should
- * use this as the entry cache
- * size (0 = autosize off) */
+ int li_import_cache_autosize; /* % of free memory to use for the import caches
+ * (-1=default, 80% on cmd import)
+ * (0 = off) -- overrides import cache size settings */
+ int li_cache_autosize; /* % of free memory to use for the combined caches
+ * (0 = off) -- overrides other cache size settings */
+ int li_cache_autosize_split; /* % of li_cache_autosize to use for the libdb cache.
+ * the rest is split up among the instance entry caches */
+ uint64_t li_cache_autosize_ec; /* new instances created while the server is up, should
+ * use this as the entry cache size (0 = autosize off) */
uint64_t li_dncache_autosize_ec; /* Same as above, but dncache. */
- size_t li_import_cachesize; /* size of the mpool for
- * imports */
+ uint64_t li_import_cachesize; /* size of the mpool for imports */
PRLock *li_dbcache_mutex;
PRCondVar *li_dbcache_cv;
- int li_shutdown; /* flag to tell any BE threads
- * to end */
+ int li_shutdown; /* flag to tell any BE threads to end */
PRLock *li_shutdown_mutex; /* protect shutdown flag */
dblayer_private *li_dblayer_private; /* session ptr for databases */
- int li_noparentcheck; /* check if parent exists on
- * add */
+ int li_noparentcheck; /* check if parent exists on add */

/* the next 3 fields are for the params that don't get changed until
* the server is restarted (used by the admin console)
*/
char *li_new_directory;
- size_t li_new_dbcachesize;
+ uint64_t li_new_dbcachesize;
int li_new_dblock;

int li_new_dbncache;

db_upgrade_info *upgrade_info;
- int li_filter_bypass; /* bypass filter testing,
- * when possible */
- int li_filter_bypass_check; /* check that filter bypass
- * is doing the right thing */
- int li_use_vlv; /* use vlv indexes to short-
- * circuit matches when
- * possible */
- void *li_identity; /* The ldbm plugin needs to keep
- * track of its identity so it can
- * perform internal ops. Its
- * identity is given to it when
- * its init function is called. */
-
- Objset *li_instance_set; /* A set containing the ldbm
- * instances. */
+ int li_filter_bypass; /* bypass filter testing, when possible */
+ int li_filter_bypass_check; /* check that filter bypass is doing the right thing */
+ int li_use_vlv; /* use vlv indexes to short-circuit matches when possible */
+ void *li_identity; /* The ldbm plugin needs to keep track of its identity so it can
+ * perform internal ops. Its identity is given to it when
+ * its init function is called. */
+
+ Objset *li_instance_set; /* A set containing the ldbm instances. */

PRLock *li_config_mutex;

diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c
index ee20dc3..77757c2 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, uint64_t 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, PRUint64 *hits, PRUint64 *tries, uint64_t *nentries, uint64_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..5ab2211 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;
}
@@ -1322,9 +1322,9 @@ dblayer_start(struct ldbminfo *li, int dbmode)
priv->dblayer_cachesize = MINCACHESIZE;
}
/* Oops---looks like the admin misconfigured, let's warn them */
- slapi_log_err(SLAPI_LOG_WARNING, "dblayer_start", "Likely CONFIGURATION ERROR - dbcachesize is configured to use more than the available "
- "memory, decreased to (%" PRIu64 " bytes).\n",
- priv->dblayer_cachesize);
+ slapi_log_err(SLAPI_LOG_WARNING, "dblayer_start",
+ "Likely CONFIGURATION ERROR - dbcachesize is configured to use more than the available "
+ "memory, decreased to (%" PRIu64 " bytes).\n", priv->dblayer_cachesize);
li->li_dbcachesize = priv->dblayer_cachesize;
}
spal_meminfo_destroy(mi);
@@ -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,8 +1448,9 @@ 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",
- priv->dblayer_logbuf_size);
+ 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, uint64_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, uint64_t tticnt)
{
if (!ttilist || !*ttilist) {
return;
@@ -3727,12 +3728,12 @@ 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, uint64_t tticnt)
{
while (tticnt > 0) {
tticnt--;
slapi_log_err(SLAPI_LOG_ERR,
- "txn_test_threadmain", "attr [%s] cnt [%lu]\n",
+ "txn_test_threadmain", "attr [%s] cnt [%" PRIu64 "]\n",
ttilist[tticnt]->attr, ttilist[tticnt]->cnt);
}
}
@@ -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 [%" PRIu64 "] 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 [%" PRIu64 "] 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..5e4433e 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.h
+++ b/ldap/servers/slapd/back-ldbm/dblayer.h
@@ -28,8 +28,8 @@

No comments:

Post a Comment