diff options
author | Rich Megginson <rmeggins@redhat.com> | 2008-10-08 17:29:05 +0000 |
---|---|---|
committer | Rich Megginson <rmeggins@redhat.com> | 2008-10-08 17:29:05 +0000 |
commit | b3797a8704696ed77b69a042e75ce5553e24b68b (patch) | |
tree | eae8ee4c9ce9e46c010334d72e942d17ee71f768 /ldap | |
parent | 9506a1d704ce99945e12dc797f932b4a50a0da24 (diff) | |
download | ds-b3797a8704696ed77b69a042e75ce5553e24b68b.tar.gz ds-b3797a8704696ed77b69a042e75ce5553e24b68b.tar.xz ds-b3797a8704696ed77b69a042e75ce5553e24b68b.zip |
Bug Description: Need to address 64-bit compiler warnings - part 1
Reviewed by: nhosoi (Thanks!)
Fix Description: The intptr_t and uintptr_t are types which are defined as integer types that are the same size as the pointer (void *) type. On the platforms we currently support, this is the same as long and unsigned long, respectively (ILP32 and LP64). However, intptr_t and uintptr_t are more portable. These can be used to assign a value passed as a void * to get an integer value, then "cast down" to an int or PRBool, and vice versa. This seems to be a common idiom in other applications where values must be passed as void *.
For the printf/scanf formats, there is a standard header called inttypes.h which defines formats to use for various 64 bit quantities, so that you don't need to figure out if you have to use %lld or %ld for a 64-bit value - you just use PRId64 which is set to the correct value. I also assumed that size_t is defined as the same size as a pointer so I used the PRIuPTR format macro for size_t.
I removed many unused variables and some unused functions.
I put parentheses around assignments in conditional expressions to tell the compiler not to complain about them.
I cleaned up some #defines that were defined more than once.
I commented out some unused goto labels.
Some of our header files shared among several source files define static variables. I made it so that those variables are not defined unless a macro is set in the source file. This avoids a lot of unused variable warnings.
I added some return values to functions that were declared as returning a value but did not return a value. In all of these cases no one was checking the return value anyway.
I put explicit parentheses around cases like this: expr || expr && expr - the && has greater precedence than the ||. The compiler complains because it wants you to make sure you mean expr || (expr && expr), not (expr || expr) && expr.
I cleaned up several places where the compiler was complaining about possible use of uninitialized variables. There are still a lot of these cases remaining.
There are a lot of warnings like this:
lib/ldaputil/certmap.c:1279: warning: dereferencing type-punned pointer will break strict-aliasing rules
These are due to our use of void ** to pass in addresses of addresses of structures. Many of these are calls to slapi_ch_free, but many are not - they are cases where we do not know what the type is going to be and may have to cast and modify the structure or pointer. I started replacing the calls to slapi_ch_free with slapi_ch_free_string, but there are many many more that need to be fixed.
The dblayer code also contains a fix for https://bugzilla.redhat.com/show_bug.cgi?id=463991 - instead of checking for dbenv->foo_handle to see if a db "feature" is enabled, instead check the flags passed to open the dbenv. This works for bdb 4.2 through bdb 4.7 and probably other releases as well.
Platforms tested: RHEL5 x86_64, Fedora 8 i386
Flag Day: no
Doc impact: no
Diffstat (limited to 'ldap')
59 files changed, 399 insertions, 307 deletions
diff --git a/ldap/servers/plugins/acl/aclparse.c b/ldap/servers/plugins/acl/aclparse.c index 36ed8456..4659658e 100644 --- a/ldap/servers/plugins/acl/aclparse.c +++ b/ldap/servers/plugins/acl/aclparse.c @@ -936,8 +936,8 @@ __aclp__getNextLASRule (aci_t *aci_item, char *original_str , char **endOfCurrRu * eg. "'ldap:///all"' or 'ldap:///all")' then exit in_dn_expr mode. */ if ( in_dn_expr && (word[len-1] == '"' || - len>1 && word[len-2] == '"' || - len>2 && word[len-3] == '"')) { + (len>1 && word[len-2] == '"') || + (len>2 && word[len-3] == '"')) ) { in_dn_expr = 0; } @@ -1692,7 +1692,7 @@ static int __acl__init_targetattrfilters( aci_t *aci, char *input_str) { if ((str = strstr(s , "del=")) || ((str = strstr(s , "del ="))) ) { str--; *str = '\0'; - *str++; + str++; } @@ -1704,7 +1704,7 @@ static int __acl__init_targetattrfilters( aci_t *aci, char *input_str) { if ((str = strstr(s , "add=")) || ((str = strstr(s , "add ="))) ) { str--; *str = '\0'; - *str++; + str++; } } else { return(ACL_SYNTAX_ERR); diff --git a/ldap/servers/plugins/acl/aclutil.c b/ldap/servers/plugins/acl/aclutil.c index 7c79a299..106e5e9c 100644 --- a/ldap/servers/plugins/acl/aclutil.c +++ b/ldap/servers/plugins/acl/aclutil.c @@ -1328,13 +1328,14 @@ void acl_ht_add_and_freeOld(acl_ht_t * acl_ht, PLHashNumber key, char *value){ char *old_value = NULL; + uintptr_t pkey = (uintptr_t)key; if ( (old_value = (char *)acl_ht_lookup( acl_ht, key)) != NULL ) { acl_ht_remove( acl_ht, key); slapi_ch_free((void **)&old_value); } - PL_HashTableAdd( acl_ht, (const void *)key, value); + PL_HashTableAdd( acl_ht, (const void *)pkey, value); } /* @@ -1349,7 +1350,7 @@ acl_ht_t *acl_ht_new(void) { static PLHashNumber acl_ht_hash( const void *key) { - return( (PLHashNumber)key ); + return( (PLHashNumber)((uintptr_t)key) ); } /* Free all the values in the ht */ @@ -1397,14 +1398,14 @@ acl_ht_display_entry(PLHashEntry *he, PRIntn i, void *arg) /* remove this entry from the ht--doesn't free the value.*/ void acl_ht_remove( acl_ht_t *acl_ht, PLHashNumber key) { - PL_HashTableRemove( acl_ht, (const void *)key); + PL_HashTableRemove( acl_ht, (const void *)((uintptr_t)key) ); } /* Retrieve a pointer to the value of the entry with key */ void *acl_ht_lookup( acl_ht_t *acl_ht, PLHashNumber key) { - return( PL_HashTableLookup( acl_ht, (const void *)key) ); + return( PL_HashTableLookup( acl_ht, (const void *)((uintptr_t)key)) ); } diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c index 13791c0c..15e266bd 100644 --- a/ldap/servers/plugins/chainingdb/cb_instance.c +++ b/ldap/servers/plugins/chainingdb/cb_instance.c @@ -903,7 +903,7 @@ static int cb_instance_userpassword_set(void *arg, void *value, char *errorbuf, static void *cb_instance_sizelimit_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data = inst->sizelimit; @@ -916,10 +916,10 @@ static int cb_instance_sizelimit_set(void *arg, void *value, char *errorbuf, int cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->sizelimit=(int) value; + inst->sizelimit=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); if (inst->inst_be) - be_set_sizelimit(inst->inst_be, (int) value); + be_set_sizelimit(inst->inst_be, (int) ((uintptr_t)value)); } return LDAP_SUCCESS; } @@ -927,7 +927,7 @@ static int cb_instance_sizelimit_set(void *arg, void *value, char *errorbuf, int static void *cb_instance_timelimit_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data = inst->timelimit; @@ -940,10 +940,10 @@ static int cb_instance_timelimit_set(void *arg, void *value, char *errorbuf, int cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->timelimit=(int) value; + inst->timelimit=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); if (inst->inst_be) - be_set_timelimit(inst->inst_be, (int) value); + be_set_timelimit(inst->inst_be, (int) ((uintptr_t)value)); } return LDAP_SUCCESS; } @@ -951,7 +951,7 @@ static int cb_instance_timelimit_set(void *arg, void *value, char *errorbuf, int static void *cb_instance_max_test_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data = inst->max_test_time; @@ -964,7 +964,7 @@ static int cb_instance_max_test_set(void *arg, void *value, char *errorbuf, int cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->max_test_time=(int) value; + inst->max_test_time=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); } return LDAP_SUCCESS; @@ -973,7 +973,7 @@ static int cb_instance_max_test_set(void *arg, void *value, char *errorbuf, int static void *cb_instance_max_idle_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data = inst->max_idle_time; @@ -986,7 +986,7 @@ static int cb_instance_max_idle_set(void *arg, void *value, char *errorbuf, int cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->max_idle_time=(int) value; + inst->max_idle_time=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); } return LDAP_SUCCESS; @@ -996,7 +996,7 @@ static int cb_instance_max_idle_set(void *arg, void *value, char *errorbuf, int static void *cb_instance_hoplimit_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data = inst->hoplimit; @@ -1009,7 +1009,7 @@ static int cb_instance_hoplimit_set(void *arg, void *value, char *errorbuf, int cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->hoplimit=(int) value; + inst->hoplimit=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); } return LDAP_SUCCESS; @@ -1018,7 +1018,7 @@ static int cb_instance_hoplimit_set(void *arg, void *value, char *errorbuf, int static void *cb_instance_maxbconn_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data = inst->bind_pool->conn.maxconnections; @@ -1031,7 +1031,7 @@ static int cb_instance_maxbconn_set(void *arg, void *value, char *errorbuf, int cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->bind_pool->conn.maxconnections=(int) value; + inst->bind_pool->conn.maxconnections=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); } return LDAP_SUCCESS; @@ -1040,7 +1040,7 @@ static int cb_instance_maxbconn_set(void *arg, void *value, char *errorbuf, int static void *cb_instance_maxconn_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data = inst->pool->conn.maxconnections; @@ -1053,7 +1053,7 @@ static int cb_instance_maxconn_set(void *arg, void *value, char *errorbuf, int p cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->pool->conn.maxconnections=(int) value; + inst->pool->conn.maxconnections=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); } return LDAP_SUCCESS; @@ -1062,7 +1062,7 @@ static int cb_instance_maxconn_set(void *arg, void *value, char *errorbuf, int p static void *cb_instance_abandonto_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data = inst->abandon_timeout.tv_sec; @@ -1084,7 +1084,7 @@ static int cb_instance_abandonto_set(void *arg, void *value, char *errorbuf, int } PR_RWLock_Wlock(inst->rwl_config_lock); - inst->abandon_timeout.tv_sec=(int) value; + inst->abandon_timeout.tv_sec=(int) ((uintptr_t)value); inst->abandon_timeout.tv_usec=0; PR_RWLock_Unlock(inst->rwl_config_lock); } @@ -1094,7 +1094,7 @@ static int cb_instance_abandonto_set(void *arg, void *value, char *errorbuf, int static void *cb_instance_maxbconc_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data = inst->bind_pool->conn.maxconcurrency; @@ -1107,7 +1107,7 @@ static int cb_instance_maxbconc_set(void *arg, void *value, char *errorbuf, int cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->bind_pool->conn.maxconcurrency=(int) value; + inst->bind_pool->conn.maxconcurrency=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); } return LDAP_SUCCESS; @@ -1116,7 +1116,7 @@ static int cb_instance_maxbconc_set(void *arg, void *value, char *errorbuf, int static void *cb_instance_maxconc_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data = inst->pool->conn.maxconcurrency; @@ -1129,7 +1129,7 @@ static int cb_instance_maxconc_set(void *arg, void *value, char *errorbuf, int p cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->pool->conn.maxconcurrency=(int) value; + inst->pool->conn.maxconcurrency=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); } return LDAP_SUCCESS; @@ -1138,7 +1138,7 @@ static int cb_instance_maxconc_set(void *arg, void *value, char *errorbuf, int p static void *cb_instance_imperson_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data = inst->impersonate; @@ -1153,7 +1153,7 @@ static int cb_instance_imperson_set(void *arg, void *value, char *errorbuf, int if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->impersonate=(int) value; + inst->impersonate=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); } else { /* Security check: Make sure the proxing user is */ @@ -1162,7 +1162,7 @@ static int cb_instance_imperson_set(void *arg, void *value, char *errorbuf, int char * rootdn=cb_get_rootdn(); PR_RWLock_Rlock(inst->rwl_config_lock); - if (((int) value) && inst->pool && inst->pool->binddn && + if (((int) ((uintptr_t)value)) && inst->pool && inst->pool->binddn && !strcmp(inst->pool->binddn,rootdn)) { /* UTF-8 aware */ rc=LDAP_UNWILLING_TO_PERFORM; if (errorbuf) @@ -1179,7 +1179,7 @@ static int cb_instance_imperson_set(void *arg, void *value, char *errorbuf, int static void *cb_instance_connlife_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data=inst->pool->conn.connlifetime; @@ -1192,7 +1192,7 @@ static int cb_instance_connlife_set(void *arg, void *value, char *errorbuf, int cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->pool->conn.connlifetime=(int) value; + inst->pool->conn.connlifetime=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); } return LDAP_SUCCESS; @@ -1201,7 +1201,7 @@ static int cb_instance_connlife_set(void *arg, void *value, char *errorbuf, int static void *cb_instance_bindto_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data=inst->bind_pool->conn.op_timeout.tv_sec; @@ -1214,12 +1214,12 @@ static int cb_instance_bindto_set(void *arg, void *value, char *errorbuf, int ph cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->bind_pool->conn.op_timeout.tv_sec=(int) value; + inst->bind_pool->conn.op_timeout.tv_sec=(int) ((uintptr_t)value); inst->bind_pool->conn.op_timeout.tv_usec=0; - inst->bind_pool->conn.bind_timeout.tv_sec=(int) value; + inst->bind_pool->conn.bind_timeout.tv_sec=(int) ((uintptr_t)value); inst->bind_pool->conn.bind_timeout.tv_usec=0; /* Used to bind to the farm server */ - inst->pool->conn.bind_timeout.tv_sec=(int) value; + inst->pool->conn.bind_timeout.tv_sec=(int) ((uintptr_t)value); inst->pool->conn.bind_timeout.tv_usec=0; PR_RWLock_Unlock(inst->rwl_config_lock); } @@ -1229,7 +1229,7 @@ static int cb_instance_bindto_set(void *arg, void *value, char *errorbuf, int ph static void *cb_instance_opto_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data=inst->pool->conn.op_timeout.tv_sec; @@ -1242,7 +1242,7 @@ static int cb_instance_opto_set(void *arg, void *value, char *errorbuf, int phas cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->pool->conn.op_timeout.tv_sec=(int) value; + inst->pool->conn.op_timeout.tv_sec=(int) ((uintptr_t)value); inst->pool->conn.op_timeout.tv_usec=0; PR_RWLock_Unlock(inst->rwl_config_lock); } @@ -1252,7 +1252,7 @@ static int cb_instance_opto_set(void *arg, void *value, char *errorbuf, int phas static void *cb_instance_ref_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data=inst->searchreferral; @@ -1265,7 +1265,7 @@ static int cb_instance_ref_set(void *arg, void *value, char *errorbuf, int phase cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->searchreferral=(int) value; + inst->searchreferral=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); } return LDAP_SUCCESS; @@ -1274,7 +1274,7 @@ static int cb_instance_ref_set(void *arg, void *value, char *errorbuf, int phase static void *cb_instance_acl_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data=inst->local_acl; @@ -1295,7 +1295,7 @@ static int cb_instance_acl_set(void *arg, void *value, char *errorbuf, int phase return LDAP_SUCCESS; } PR_RWLock_Wlock(inst->rwl_config_lock); - inst->local_acl=(int) value; + inst->local_acl=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); } return LDAP_SUCCESS; @@ -1304,7 +1304,7 @@ static int cb_instance_acl_set(void *arg, void *value, char *errorbuf, int phase static void *cb_instance_bindretry_get(void *arg) { cb_backend_instance * inst=(cb_backend_instance *) arg; - int data; + uintptr_t data; PR_RWLock_Rlock(inst->rwl_config_lock); data=inst->bind_retry; @@ -1317,7 +1317,7 @@ static int cb_instance_bindretry_set(void *arg, void *value, char *errorbuf, int cb_backend_instance * inst=(cb_backend_instance *) arg; if (apply) { PR_RWLock_Wlock(inst->rwl_config_lock); - inst->bind_retry=(int) value; + inst->bind_retry=(int) ((uintptr_t)value); PR_RWLock_Unlock(inst->rwl_config_lock); } return LDAP_SUCCESS; @@ -1383,7 +1383,7 @@ struct berval *bval, char *err_buf, int phase, int apply_mod) } else { int_val = cb_atoi((char *)bval->bv_val); } - retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod); + retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod); break; case CB_CONFIG_TYPE_INT_OCTAL: if (use_default) { @@ -1391,7 +1391,7 @@ struct berval *bval, char *err_buf, int phase, int apply_mod) } else { int_val = (int) strtol((char *)bval->bv_val, NULL, 8); } - retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod); + retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod); break; case CB_CONFIG_TYPE_LONG: if (use_default) { @@ -1414,7 +1414,7 @@ struct berval *bval, char *err_buf, int phase, int apply_mod) } else { int_val = !strcasecmp((char *) bval->bv_val, "on"); } - retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod); + retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod); break; } return retval; @@ -1435,10 +1435,10 @@ void cb_instance_config_get(void *arg, cb_instance_config_info *config, char *bu switch(config->config_type) { case CB_CONFIG_TYPE_INT: - sprintf(buf, "%d", (int) config->config_get_fn(arg)); + sprintf(buf, "%d", (int) ((uintptr_t)config->config_get_fn(arg))); break; case CB_CONFIG_TYPE_INT_OCTAL: - sprintf(buf, "%o", (int) config->config_get_fn(arg)); + sprintf(buf, "%o", (int) ((uintptr_t)config->config_get_fn(arg))); break; case CB_CONFIG_TYPE_LONG: sprintf(buf, "%ld", (long) config->config_get_fn(arg)); @@ -1451,7 +1451,7 @@ void cb_instance_config_get(void *arg, cb_instance_config_info *config, char *bu slapi_ch_free((void **)&tmp_string); break; case CB_CONFIG_TYPE_ONOFF: - if ((int) config->config_get_fn(arg)) { + if ((int) ((uintptr_t)config->config_get_fn(arg))) { sprintf(buf,"%s","on"); } else { sprintf(buf,"%s","off"); diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c index 7b7470bd..24184914 100644 --- a/ldap/servers/plugins/dna/dna.c +++ b/ldap/servers/plugins/dna/dna.c @@ -55,6 +55,13 @@ #include "prclist.h" #include "ldif.h" +/* Required to get portable printf/scanf format macros */ +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#else +#error Need to define portable format macros such as PRIu64 +#endif /* HAVE_INTTYPES_H */ + /* get file mode flags for unix */ #ifndef _WIN32 #include <sys/stat.h> @@ -708,7 +715,7 @@ dna_parse_config_entry(Slapi_Entry * e, int apply) } slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM, - "----------> %s [%llu]\n", DNA_NEXTVAL, entry->nextval, 0, + "----------> %s [%" PRIu64 "]\n", DNA_NEXTVAL, entry->nextval, 0, 0); value = slapi_entry_attr_get_charptr(e, DNA_PREFIX); @@ -736,7 +743,7 @@ dna_parse_config_entry(Slapi_Entry * e, int apply) } slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM, - "----------> %s [%llu]\n", DNA_INTERVAL, entry->interval, 0, 0); + "----------> %s [%" PRIu64 "]\n", DNA_INTERVAL, entry->interval, 0, 0); #endif value = slapi_entry_attr_get_charptr(e, DNA_GENERATE); @@ -844,7 +851,7 @@ dna_parse_config_entry(Slapi_Entry * e, int apply) entry->threshold = strtoull(value, 0, 0); slapi_log_error(SLAPI_LOG_CONFIG, DNA_PLUGIN_SUBSYSTEM, - "----------> %s [%llu]\n", DNA_THRESHOLD, value, 0, 0); + "----------> %s [%" PRIu64 "]\n", DNA_THRESHOLD, value, 0, 0); slapi_ch_free_string(&value); } else { @@ -1319,8 +1326,8 @@ dna_notice_allocation(struct configEntry *config_entry, PRUint64 new, * don't need to do this if we already have a next range on deck. */ if ((config_entry->next_range_lower == 0) && (config_entry->remaining <= config_entry->threshold)) { slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM, - "dna_notice_allocation: Passed threshold of %llu remaining values " - "for range %s. (%llu values remain)\n", + "dna_notice_allocation: Passed threshold of %" PRIu64 " remaining values " + "for range %s. (%" PRIu64 " values remain)\n", config_entry->threshold, config_entry->dn, config_entry->remaining); /* Only attempt to fix maxval if the fix flag is set. */ if (fix != 0) { @@ -1461,13 +1468,11 @@ static int dna_request_range(struct configEntry *config_entry, struct dnaServer *server, PRUint64 *lower, PRUint64 *upper) { - Slapi_DN *agmt_sdn = NULL; char *bind_dn = NULL; char *bind_passwd = NULL; char *bind_method = NULL; int is_ssl = 0; int is_client_auth = 0; - int replport = 0; struct berval *request = NULL; char *retoid = NULL; struct berval *responsedata = NULL; @@ -1767,12 +1772,12 @@ dna_first_free_value(struct configEntry *config_entry, if (prefix) { /* The 7 below is for all of the filter characters "(&(=))" * plus the trailing \0. The 20 is for the maximum string - * representation of a %llu. */ + * representation of a " PRIu64 ". */ filterlen = strlen(config_entry->filter) + strlen(prefix) + strlen(type) + 7 + 20; filter = slapi_ch_malloc(filterlen); - snprintf(filter, filterlen, "(&%s(%s=%s%llu))", + snprintf(filter, filterlen, "(&%s(%s=%s%" PRIu64 "))", config_entry->filter, type, prefix, tmpval); } else { ctrls = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl)); @@ -1785,7 +1790,7 @@ dna_first_free_value(struct configEntry *config_entry, return LDAP_OPERATIONS_ERROR; } - filter = slapi_ch_smprintf("(&%s(&(%s>=%llu)(%s<=%llu)))", + filter = slapi_ch_smprintf("(&%s(&(%s>=%" PRIu64 ")(%s<=%" PRIu64 ")))", config_entry->filter, type, tmpval, type, config_entry->maxval); @@ -1836,7 +1841,7 @@ dna_first_free_value(struct configEntry *config_entry, /* filter is guaranteed to be big enough since we allocated * enough space to fit a string representation of any unsigned * 64-bit integer */ - snprintf(filter, filterlen, "(&%s(%s=%s%llu))", + snprintf(filter, filterlen, "(&%s(%s=%s%" PRIu64 "))", config_entry->filter, type, prefix, tmpval); /* clear out the pblock so we can re-use it */ @@ -1968,7 +1973,7 @@ static int dna_get_next_value(struct configEntry *config_entry, * of our current range */ if (nextval <= (config_entry->maxval + config_entry->interval)) { /* try to set the new next value in the config entry */ - snprintf(next_value, sizeof(next_value),"%llu", nextval); + snprintf(next_value, sizeof(next_value),"%" PRIu64, nextval); /* set up our replace modify operation */ replace_val[0] = next_value; @@ -1998,7 +2003,7 @@ static int dna_get_next_value(struct configEntry *config_entry, if (LDAP_SUCCESS == ret) { slapi_ch_free_string(next_value_ret); - *next_value_ret = slapi_ch_smprintf("%llu", setval); + *next_value_ret = slapi_ch_smprintf("%" PRIu64, setval); if (NULL == *next_value_ret) { ret = LDAP_OPERATIONS_ERROR; goto done; @@ -2045,7 +2050,7 @@ dna_update_shared_config(struct configEntry * config_entry) /* We store the number of remaining assigned values * in the shared config entry. */ - snprintf(remaining_vals, sizeof(remaining_vals),"%llu", config_entry->remaining); + snprintf(remaining_vals, sizeof(remaining_vals),"%" PRIu64, config_entry->remaining); /* set up our replace modify operation */ replace_val[0] = remaining_vals; @@ -2130,7 +2135,7 @@ dna_update_next_range(struct configEntry *config_entry, int ret = 0; /* Try to set the new next range in the config entry. */ - snprintf(nextrange_value, sizeof(nextrange_value), "%llu-%llu", + snprintf(nextrange_value, sizeof(nextrange_value), "%" PRIu64 "-%" PRIu64, lower, upper); /* set up our replace modify operation */ @@ -2199,8 +2204,8 @@ dna_activate_next_range(struct configEntry *config_entry) int ret = 0; /* Setup the modify operation for the config entry */ - snprintf(maxval_val, sizeof(maxval_val),"%llu", config_entry->next_range_upper); - snprintf(nextval_val, sizeof(nextval_val),"%llu", config_entry->next_range_lower); + snprintf(maxval_val, sizeof(maxval_val),"%" PRIu64, config_entry->next_range_upper); + snprintf(nextval_val, sizeof(nextval_val),"%" PRIu64, config_entry->next_range_lower); maxval_vals[0] = maxval_val; maxval_vals[1] = 0; @@ -2817,8 +2822,8 @@ static int dna_extend_exop(Slapi_PBlock *pb) char highstr[16]; /* Create the exop response */ - snprintf(lowstr, sizeof(lowstr), "%llu", lower); - snprintf(highstr, sizeof(highstr), "%llu", upper); + snprintf(lowstr, sizeof(lowstr), "%" PRIu64, lower); + snprintf(highstr, sizeof(highstr), "%" PRIu64, upper); range_low.bv_val = lowstr; range_low.bv_len = strlen(range_low.bv_val); range_high.bv_val = highstr; @@ -2846,12 +2851,12 @@ static int dna_extend_exop(Slapi_PBlock *pb) slapi_pblock_set(pb, SLAPI_EXT_OP_RET_VALUE, respdata); /* send the response ourselves */ - send_ldap_result( pb, ret, NULL, NULL, 0, NULL ); + slapi_send_ldap_result( pb, ret, NULL, NULL, 0, NULL ); ret = SLAPI_PLUGIN_EXTENDED_SENT_RESULT; ber_bvfree(respdata); slapi_log_error(SLAPI_LOG_PLUGIN, DNA_PLUGIN_SUBSYSTEM, - "dna_extend_exop: Released range %llu-%llu.\n", + "dna_extend_exop: Released range %" PRIu64 "-%" PRIu64 ".\n", lower, upper); } @@ -2993,7 +2998,7 @@ dna_release_range(char *range_dn, PRUint64 *lower, PRUint64 *upper) *lower = *upper - release + 1; /* try to set the new maxval in the config entry */ - snprintf(max_value, sizeof(max_value),"%llu", (*lower - 1)); + snprintf(max_value, sizeof(max_value),"%" PRIu64, (*lower - 1)); /* set up our replace modify operation */ replace_val[0] = max_value; @@ -3092,11 +3097,11 @@ void dna_dump_config_entry(struct configEntry * entry) printf("<---- filter ---------> %s\n", entry->filter); printf("<---- prefix ---------> %s\n", entry->prefix); printf("<---- scope ----------> %s\n", entry->scope); - printf("<---- next value -----> %llu\n", entry->nextval); - printf("<---- max value ------> %llu\n", entry->maxval); - printf("<---- interval -------> %llu\n", entry->interval); + printf("<---- next value -----> %" PRIu64 "\n", entry->nextval); + printf("<---- max value ------> %" PRIu64 "\n", entry->maxval); + printf("<---- interval -------> %" PRIu64 "\n", entry->interval); printf("<---- generate flag --> %s\n", entry->generate); printf("<---- shared cfg base > %s\n", entry->shared_cfg_base); printf("<---- shared cfg DN --> %s\n", entry->shared_cfg_dn); - printf("<---- threshold -----> %llu", entry->threshold); + printf("<---- threshold ------> %" PRIu64 "", entry->threshold); } diff --git a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c index 1f3b5db4..93aa9207 100644 --- a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c +++ b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c @@ -177,7 +177,7 @@ free_pam_response(int nresp, struct pam_response *resp) * tell if this is actually the case. */ static int -pam_conv_func(int num_msg, struct pam_message **msg, struct pam_response **resp, void *mydata) +pam_conv_func(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *mydata) { int ii; struct berval *creds; diff --git a/ldap/servers/plugins/passthru/ptconfig.c b/ldap/servers/plugins/passthru/ptconfig.c index e929483b..28579183 100644 --- a/ldap/servers/plugins/passthru/ptconfig.c +++ b/ldap/servers/plugins/passthru/ptconfig.c @@ -102,7 +102,7 @@ int passthru_config( int argc, char **argv ) { int i, j, rc, tosecs, using_def_connlifetime; - char *p, **suffixarray; + char **suffixarray; PassThruServer *prevsrvr, *srvr; PassThruSuffix *suffix, *prevsuffix; LDAPURLDesc *ludp; @@ -144,7 +144,7 @@ passthru_config( int argc, char **argv ) and that the url does not look like this: ldap://host also assumes suffixes do not have any / in them */ - if (p = strrchr(srvr->ptsrvr_url, '/')) { /* look for last / */ + if ((p = strrchr(srvr->ptsrvr_url, '/'))) { /* look for last / */ p = strchr(p, ' '); /* look for first space after last / */ if (p) { if (!strchr(p, ',')) { /* no comma */ diff --git a/ldap/servers/plugins/presence/presence.c b/ldap/servers/plugins/presence/presence.c index 9a6e97b8..18739a75 100644 --- a/ldap/servers/plugins/presence/presence.c +++ b/ldap/servers/plugins/presence/presence.c @@ -66,13 +66,7 @@ /*** from proto-slap.h ***/ -int slapd_log_error_proc( char *subsystem, char *fmt, ... ) -#ifdef __GNUC__ - __attribute__ ((format (printf, 2, 3))); -#else - ; -#endif - +int slapd_log_error_proc( char *subsystem, char *fmt, ... ); /*** from ldaplog.h ***/ @@ -346,7 +340,6 @@ int presence_init( Slapi_PBlock *pb ) int presence_start( Slapi_PBlock *pb ) { char * plugindn = NULL; - char * httpRootDir = NULL; LDAPDebug( LDAP_DEBUG_PLUGIN, "--> presence_start -- begin\n",0,0,0); @@ -1105,7 +1098,6 @@ static int setTypes(PLHashEntry *he, PRIntn i, void *arg) { int status; int props = SLAPI_ATTR_FLAG_OPATTR; - Slapi_Attr *attr = NULL; Slapi_ValueSet *results = NULL; int type_name_disposition = 0; char *actual_type_name = 0; @@ -1150,7 +1142,6 @@ logGraphicAttributeValue( Slapi_Attr *attr, const char *attrname ) v = slapi_value_get_berval(val); if (v) { char *ldifvalue; - size_t attrnamelen = strlen( attrname ); LDAPDebug( LDAP_DEBUG_PLUGIN, "----------> %s size [%d] \n", attrname,v->bv_len,0); diff --git a/ldap/servers/plugins/pwdstorage/crypt_pwd.c b/ldap/servers/plugins/pwdstorage/crypt_pwd.c index aa7ac3a7..02ec7d08 100644 --- a/ldap/servers/plugins/pwdstorage/crypt_pwd.c +++ b/ldap/servers/plugins/pwdstorage/crypt_pwd.c @@ -53,7 +53,9 @@ char *crypt(char *key, char *salt); #else #include <sys/socket.h> #if defined( hpux ) || defined ( AIX ) || defined (LINUX) || defined (OSF1) +#ifndef __USE_XOPEN #define __USE_XOPEN /* linux */ +#endif /* __USE_XOPEN */ #include <unistd.h> #else /* hpux */ #include <crypt.h> diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c index 034174ab..d81e2a09 100644 --- a/ldap/servers/plugins/replication/cl5_api.c +++ b/ldap/servers/plugins/replication/cl5_api.c @@ -3376,8 +3376,6 @@ out: */ static int _cl5Upgrade4_4(char *fromVersion, char *toVersion) { - PRDirEntry *entry = NULL; - DB *thisdb = NULL; CL5OpenMode backup; int rc = 0; diff --git a/ldap/servers/plugins/replication/repl5_agmt.c b/ldap/servers/plugins/replication/repl5_agmt.c index b37ef756..60d3565b 100644 --- a/ldap/servers/plugins/replication/repl5_agmt.c +++ b/ldap/servers/plugins/replication/repl5_agmt.c @@ -1183,7 +1183,7 @@ agmt_validate_replicated_attributes(Repl_Agmt *ra) { char *this_attr = NULL; int i = 0; - for (i = 0; this_attr = frac_attrs[i]; i++) + for (i = 0; (this_attr = frac_attrs[i]); i++) { if (charray_inlist(verbotten_attrs,this_attr)) { int k = 0; diff --git a/ldap/servers/plugins/replication/repl5_connection.c b/ldap/servers/plugins/replication/repl5_connection.c index aa754cf4..a8aecafe 100644 --- a/ldap/servers/plugins/replication/repl5_connection.c +++ b/ldap/servers/plugins/replication/repl5_connection.c @@ -1728,7 +1728,7 @@ repl5_stop_debug_timeout(Slapi_Eq_Context eqctx, int *setlevel) char msg[SLAPI_DSE_RETURNTEXT_SIZE]; if (eqctx && !*setlevel) { - int found = slapi_eq_cancel(eqctx); + (void)slapi_eq_cancel(eqctx); } if (s_debug_timeout && s_debug_level && *setlevel) { diff --git a/ldap/servers/plugins/replication/repl5_protocol_util.c b/ldap/servers/plugins/replication/repl5_protocol_util.c index 4a4114d7..f1b70364 100644 --- a/ldap/servers/plugins/replication/repl5_protocol_util.c +++ b/ldap/servers/plugins/replication/repl5_protocol_util.c @@ -417,7 +417,8 @@ acquire_replica(Private_Repl_Protocol *prp, char *prot_oid, RUV **ruv) } } } -error: + +/* error: */ if (NULL != ruv_bervals) ber_bvecfree(ruv_bervals); if (NULL != replarea_sdn) diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c index 87b8b6d3..69a44673 100644 --- a/ldap/servers/plugins/replication/repl5_replica.c +++ b/ldap/servers/plugins/replication/repl5_replica.c @@ -1076,7 +1076,7 @@ replica_update_csngen_state_ext (Replica *r, const RUV *ruv, const CSN *extracsn rc = csngen_adjust_time (gen, csn); /* rc will be either CSN_SUCCESS (0) or clock skew */ -done: +/* done: */ PR_Unlock(r->repl_lock); if (csn != extracsn) /* do not free the given csn */ diff --git a/ldap/servers/plugins/replication/repl5_updatedn_list.c b/ldap/servers/plugins/replication/repl5_updatedn_list.c index 3d897198..8cdb8d5e 100644 --- a/ldap/servers/plugins/replication/repl5_updatedn_list.c +++ b/ldap/servers/plugins/replication/repl5_updatedn_list.c @@ -193,7 +193,7 @@ replica_updatedn_list_ismember(ReplicaUpdateDNList list, const Slapi_DN *dn) /* Bug 605169 - null ndn would cause core dump */ if ( ndn ) { - ret = (PRBool)PL_HashTableLookupConst(hash, ndn); + ret = (PRBool)((uintptr_t)PL_HashTableLookupConst(hash, ndn)); } return ret; diff --git a/ldap/servers/plugins/roles/roles_plugin.c b/ldap/servers/plugins/roles/roles_plugin.c index 9edc903c..96f92756 100644 --- a/ldap/servers/plugins/roles/roles_plugin.c +++ b/ldap/servers/plugins/roles/roles_plugin.c @@ -50,15 +50,9 @@ #include "vattr_spi.h" #include "roles_cache.h" +#define DEFINE_STATECHANGE_STATICS 1 #include "statechange.h" - -#ifdef SOURCEFILE -#undef SOURCEFILE -#endif -#define SOURCEFILE "roles_plugin.c" -static char *sourcefile = SOURCEFILE; - #define STATECHANGE_ROLES_ID "Roles" #define STATECHANGE_ROLES_CONFG_FILTER "objectclass=nsRoleDefinition" #define STATECHANGE_ROLES_ENTRY_FILTER "objectclass=*" diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c index 180abb0a..db04273a 100644 --- a/ldap/servers/slapd/agtmmap.c +++ b/ldap/servers/slapd/agtmmap.c @@ -195,7 +195,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl) { /* Without this we will get segv when we try to read/write later */ buf = calloc (1, sz); - write (fd, buf, sz); + (void)write (fd, buf, sz); free (buf); } diff --git a/ldap/servers/slapd/auth.c b/ldap/servers/slapd/auth.c index 6e6ffe14..0b68a688 100644 --- a/ldap/servers/slapd/auth.c +++ b/ldap/servers/slapd/auth.c @@ -449,7 +449,7 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData) if ( conn->c_flags & CONN_FLAG_START_TLS ) { if ( cipherInfo.symKeyBits == 0 ) { start_tls_graceful_closure( conn, NULL, 1 ); - slapi_ch_free((void **)&cipher); + slapi_ch_free_string(&cipher); return ; } } @@ -457,7 +457,7 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData) if (config_get_SSLclientAuth() == SLAPD_SSLCLIENTAUTH_OFF ) { slapi_log_access (LDAP_DEBUG_STATS, "conn=%d SSL %i-bit %s\n", conn->c_connid, keySize, cipher ? cipher : "NULL" ); - slapi_ch_free((void **)&cipher); + slapi_ch_free_string(&cipher); return; } if (clientCert == NULL) { @@ -499,7 +499,7 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData) LDAPDebug (LDAP_DEBUG_TRACE, "<= ldapu_cert_to_ldap_entry() %i (%s)%s\n", err, extraErrorMsg, chain ? "" : " NULL"); } - slapi_ch_free((void**)&basedn); + slapi_ch_free_string(&basedn); slapu_msgfree (internal_ld, chain); } if (subject) free (subject); @@ -522,6 +522,6 @@ handle_handshake_done (PRFileDesc *prfd, void* clientData) bind_credentials_set( conn, SLAPD_AUTH_SSL, clientDN, SLAPD_AUTH_SSL, clientDN, clientCert , NULL); - slapi_ch_free((void **)&cipher); + slapi_ch_free_string(&cipher); /* clientDN and clientCert will be freed later */ } diff --git a/ldap/servers/slapd/back-ldbm/back-ldbm.h b/ldap/servers/slapd/back-ldbm/back-ldbm.h index d589f0d6..f362f76c 100644 --- a/ldap/servers/slapd/back-ldbm/back-ldbm.h +++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h @@ -114,6 +114,15 @@ typedef unsigned short u_int16_t; #define MEGABYTE (1024 * 1024) #define GIGABYTE (1024 * MEGABYTE) +#define DB_USES_LOCKING(env) \ + (DB_INIT_LOCK & ((env)->get_open_flags((env), NULL))) +#define DB_USES_TRANSACTIONS(env) \ + (DB_INIT_TXN & ((env)->get_open_flags((env), NULL))) +#define DB_USES_MPOOL(env) \ + (DB_INIT_MPOOL & ((env)->get_open_flags((env), NULL))) +#define DB_USES_LOGGING(env) \ + (DB_INIT_LOG & ((env)->get_open_flags((env), NULL))) + /* include NSPR header files */ #include "nspr.h" diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c index abd71b85..bc8b55f7 100644 --- a/ldap/servers/slapd/back-ldbm/dblayer.c +++ b/ldap/servers/slapd/back-ldbm/dblayer.c @@ -97,6 +97,13 @@ #include "dblayer.h" #include <prrwlock.h> +/* Required to get portable printf/scanf format macros */ +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#else +#error Need to define portable format macros such as PRIu64 +#endif /* HAVE_INTTYPES_H */ + #if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4100 #define DB_OPEN(oflags, db, txnid, file, database, type, flags, mode, rval) \ { \ @@ -284,7 +291,7 @@ dblayer_bt_compare(DB *db, const DBT *dbt1, const DBT *dbt2) int dblayer_set_batch_transactions(void *arg, void *value, char *errorbuf, int phase, int apply) { - int val = (int) value; + int val = (int)((uintptr_t)value); int retval = LDAP_SUCCESS; if (apply) { @@ -304,7 +311,7 @@ dblayer_set_batch_transactions(void *arg, void *value, char *errorbuf, int phase void * dblayer_get_batch_transactions(void *arg) { - return (void *)trans_batch_limit; + return (void *)((uintptr_t)trans_batch_limit); } @@ -465,25 +472,25 @@ int dblayer_open_huge_file(const char *path, int oflag, int mode) } -/* Helper function for large seeks, db2.4 */ -static int dblayer_seek24_large(int fd, size_t pgsize, db_pgno_t pageno, - u_long relative, int isrewind, int whence) +#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300 +/* Helper function for large seeks, db4.3 */ +static int dblayer_seek43_large(int fd, off64_t offset, int whence) { - off64_t offset = 0, ret; + int ret = 0; - offset = (off64_t)pgsize * pageno + relative; - if (isrewind) offset = -offset; ret = lseek64(fd, offset, whence); return (ret < 0) ? errno : 0; } - -#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300 -/* Helper function for large seeks, db4.3 */ -static int dblayer_seek43_large(int fd, off64_t offset, int whence) +#else +/* Helper function for large seeks, db2.4 */ +static int dblayer_seek24_large(int fd, size_t pgsize, db_pgno_t pageno, + u_long relative, int isrewind, int whence) { - int ret = 0; + off64_t offset = 0, ret; + offset = (off64_t)pgsize * pageno + relative; + if (isrewind) offset = -offset; ret = lseek64(fd, offset, whence); return (ret < 0) ? errno : 0; @@ -892,7 +899,7 @@ void dblayer_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size_ if (feof(f)) break; if (strncmp(s, "VmSize:", 7) == 0) { - sscanf(s+7, "%d", procpages); + sscanf(s+7, "%" PRIuPTR, procpages); break; } } @@ -3449,7 +3456,7 @@ static int deadlock_threadmain(void *param) { if (priv->dblayer_enable_transactions) { - if (NULL != priv->dblayer_env->dblayer_DB_ENV->lk_handle) { + if (DB_USES_LOCKING(priv->dblayer_env->dblayer_DB_ENV)) { int aborted; if ((rval = LOCK_DETECT(priv->dblayer_env->dblayer_DB_ENV, 0, @@ -3619,7 +3626,7 @@ static int checkpoint_threadmain(void *param) checkpoint_interval) continue; - if (NULL == priv->dblayer_env->dblayer_DB_ENV->tx_handle) + if (!DB_USES_TRANSACTIONS(priv->dblayer_env->dblayer_DB_ENV)) continue; /* now checkpoint */ @@ -3777,7 +3784,7 @@ static int trickle_threadmain(void *param) DS_Sleep(interval); /* 622855: wait for other threads fully started */ if (priv->dblayer_enable_transactions) { - if ( (NULL != priv->dblayer_env->dblayer_DB_ENV->mp_handle) && + if ( DB_USES_MPOOL(priv->dblayer_env->dblayer_DB_ENV) && (0 != priv->dblayer_trickle_percentage) ) { int pages_written = 0; diff --git a/ldap/servers/slapd/back-ldbm/dbverify.c b/ldap/servers/slapd/back-ldbm/dbverify.c index c6f910b9..aaece1ff 100644 --- a/ldap/servers/slapd/back-ldbm/dbverify.c +++ b/ldap/servers/slapd/back-ldbm/dbverify.c @@ -50,7 +50,6 @@ dbverify_ext( ldbm_instance *inst, int verbose ) char *filep = NULL; PRDir *dirhandle = NULL; PRDirEntry *direntry = NULL; - backend *be = inst->inst_be; DB *dbp = NULL; int tmplen = 0; int filelen = 0; @@ -87,7 +86,6 @@ dbverify_ext( ldbm_instance *inst, int verbose ) (direntry = PR_ReadDir(dirhandle, PR_SKIP_DOT | PR_SKIP_DOT_DOT))) { /* struct attrinfo *ai = NULL; */ - char *p = NULL; dbp = NULL; if (!direntry->name) diff --git a/ldap/servers/slapd/back-ldbm/import-merge.c b/ldap/servers/slapd/back-ldbm/import-merge.c index 445860ec..b2d2074d 100644 --- a/ldap/servers/slapd/back-ldbm/import-merge.c +++ b/ldap/servers/slapd/back-ldbm/import-merge.c @@ -49,6 +49,13 @@ #include "back-ldbm.h" #include "import.h" +/* Required to get portable printf/scanf format macros */ +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#else +#error Need to define portable format macros such as PRIu64 +#endif /* HAVE_INTTYPES_H */ + struct _import_merge_thang { int type; @@ -667,7 +674,7 @@ int import_mega_merge(ImportJob *job) if (1 == job->number_indexers) { import_log_notice(job, "Beginning %d-way merge of one file...", passes); } else { - import_log_notice(job, "Beginning %d-way merge of up to %lu files...", + import_log_notice(job, "Beginning %d-way merge of up to %" PRIuPTR " files...", passes, job->number_indexers); } diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c index afbc178d..c6303d33 100644 --- a/ldap/servers/slapd/back-ldbm/import-threads.c +++ b/ldap/servers/slapd/back-ldbm/import-threads.c @@ -49,6 +49,13 @@ * a wire import (aka "fast replica" import) won't have a producer thread. */ +/* Required to get portable printf/scanf format macros */ +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#else +#error Need to define portable format macros such as PRIu64 +#endif /* HAVE_INTTYPES_H */ + #include "back-ldbm.h" #include "vlv_srch.h" #include "import.h" @@ -56,6 +63,7 @@ #define STDIN_FILENO 0 #endif +static void import_wait_for_space_in_fifo(ImportJob *job, size_t new_esize); static struct backentry *import_make_backentry(Slapi_Entry *e, ID id) { @@ -570,8 +578,8 @@ void import_producer(void *param) "ending line %d of file \"%s\"", escape_string(slapi_entry_get_dn(e), ebuf), curr_lineno, curr_filename); - import_log_notice(job, "REASON: entry too large (%d bytes) for " - "the buffer size (%d bytes)", newesize, job->fifo.bsize); + import_log_notice(job, "REASON: entry too large (%ld bytes) for " + "the buffer size (%" PRIuPTR " bytes)", newesize, job->fifo.bsize); backentry_free(&ep); job->skipped++; continue; @@ -804,8 +812,8 @@ void index_producer(void *param) char ebuf[BUFSIZ]; import_log_notice(job, "WARNING: skipping entry \"%s\"", escape_string(slapi_entry_get_dn(e), ebuf)); - import_log_notice(job, "REASON: entry too large (%d bytes) for " - "the buffer size (%d bytes)", newesize, job->fifo.bsize); + import_log_notice(job, "REASON: entry too large (%" PRIuPTR " bytes) for " + "the buffer size (%" PRIuPTR " bytes)", newesize, job->fifo.bsize); backentry_free(&ep); job->skipped++; continue; @@ -1185,7 +1193,7 @@ void import_worker(void *param) int idl_disposition = 0; struct vlvIndex* vlv_index = NULL; void *substring_key_buffer = NULL; - FifoItem *fi; + FifoItem *fi = NULL; int is_objectclass_attribute; int is_nsuniqueid_attribute; void *attrlist_cursor; @@ -1598,8 +1606,8 @@ static int bulk_import_queue(ImportJob *job, Slapi_Entry *entry) char ebuf[BUFSIZ]; import_log_notice(job, "WARNING: skipping entry \"%s\"", escape_string(slapi_entry_get_dn(ep->ep_entry), ebuf)); - import_log_notice(job, "REASON: entry too large (%d bytes) for " - "the import buffer size (%d bytes). Try increasing nsslapd-cachememsize.", newesize, job->fifo.bsize); + import_log_notice(job, "REASON: entry too large (%" PRIuPTR " bytes) for " + "the import buffer size (%" PRIuPTR " bytes). Try increasing nsslapd-cachememsize.", newesize, job->fifo.bsize); backentry_clear_entry(ep); /* entry is released in the frontend on failure*/ backentry_free( &ep ); /* release the backend wrapper, here */ PR_Unlock(job->wire_lock); @@ -1670,7 +1678,7 @@ int ldbm_back_wire_import(Slapi_PBlock *pb) { struct ldbminfo *li; backend *be = NULL; - ImportJob *job; + ImportJob *job = NULL; PRThread *thread; int state; @@ -1954,7 +1962,7 @@ dse_conf_verify_core(struct ldbminfo *li, char *src_dir, char *file_name, char * if (entry_filter != NULL) /* Single instance restoration */ { - if (!(int)strstr(estr, entry_filter)) + if (NULL == strstr(estr, entry_filter)) continue; } diff --git a/ldap/servers/slapd/back-ldbm/import.c b/ldap/servers/slapd/back-ldbm/import.c index 533a61c3..2a2c6917 100644 --- a/ldap/servers/slapd/back-ldbm/import.c +++ b/ldap/servers/slapd/back-ldbm/import.c @@ -46,6 +46,12 @@ * please make sure you use 4-space indentation on this file. */ +/* Required to get portable printf/scanf format macros */ +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#else +#error Need to define portable format macros such as PRIu64 +#endif /* HAVE_INTTYPES_H */ #include "back-ldbm.h" #include "vlv_srch.h" @@ -1149,7 +1155,7 @@ int import_main_offline(void *arg) import_log_notice(job, "Index buffering is disabled."); else import_log_notice(job, - "Index buffering enabled with bucket size %lu", + "Index buffering enabled with bucket size %" PRIuPTR, job->job_index_buffer_suggestion); job->worker_list = producer; @@ -1312,7 +1318,7 @@ error: if (job->not_here_skipped) { if (job->skipped) - import_log_notice(job, "Import complete. Processed %lu entries " + import_log_notice(job, "Import complete. Processed %" PRIuPTR " entries " "(%d bad entries were skipped, " "%d entries were skipped because they don't " "belong to this database) in %d seconds. " @@ -1320,7 +1326,7 @@ error: job->skipped, job->not_here_skipped, seconds_to_import, entries_per_second); else - import_log_notice(job, "Import complete. Processed %lu entries " + import_log_notice(job, "Import complete. Processed %" PRIuPTR " entries " "(%d entries were skipped because they don't " "belong to this database) " "in %d seconds. (%.2f entries/sec)", @@ -1330,13 +1336,13 @@ error: else { if (job->skipped) - import_log_notice(job, "Import complete. Processed %lu entries " + import_log_notice(job, "Import complete. Processed %" PRIuPTR " entries " "(%d were skipped) in %d seconds. " "(%.2f entries/sec)", entries_processed, job->skipped, seconds_to_import, entries_per_second); else - import_log_notice(job, "Import complete. Processed %lu entries " + import_log_notice(job, "Import complete. Processed %" PRIuPTR " entries " "in %d seconds. (%.2f entries/sec)", entries_processed, seconds_to_import, entries_per_second); diff --git a/ldap/servers/slapd/back-ldbm/import.h b/ldap/servers/slapd/back-ldbm/import.h index f94004fd..0ae56c1d 100644 --- a/ldap/servers/slapd/back-ldbm/import.h +++ b/ldap/servers/slapd/back-ldbm/import.h @@ -235,4 +235,3 @@ void import_producer(void *param); void index_producer(void *param); void import_foreman(void *param); void import_worker(void *param); -static void import_wait_for_space_in_fifo(ImportJob *job, size_t new_esize); diff --git a/ldap/servers/slapd/back-ldbm/ldbm_attr.c b/ldap/servers/slapd/back-ldbm/ldbm_attr.c index 520bca91..d13495b9 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_attr.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_attr.c @@ -258,16 +258,16 @@ attr_index_config( preamble, officialOID, index_rules[j] ); slapi_ch_free((void**)&preamble); } - } else if (p = - strstr(index_rules[j], INDEX_ATTR_SUBSTRBEGIN)) { + } else if ((p = + strstr(index_rules[j], INDEX_ATTR_SUBSTRBEGIN))) { _set_attr_substrlen(INDEX_SUBSTRBEGIN, index_rules[j], &substrlens); - } else if (p = - strstr(index_rules[j], INDEX_ATTR_SUBSTRMIDDLE)) { + } else if ((p = + strstr(index_rules[j], INDEX_ATTR_SUBSTRMIDDLE))) { _set_attr_substrlen(INDEX_SUBSTRMIDDLE, index_rules[j], &substrlens); - } else if (p = - strstr(index_rules[j], INDEX_ATTR_SUBSTREND)) { + } else if ((p = + strstr(index_rules[j], INDEX_ATTR_SUBSTREND))) { _set_attr_substrlen(INDEX_SUBSTREND, index_rules[j], &substrlens); } else if (!slapi_matchingrule_is_ordering(index_rules[j], attrsyntax_oid)) { diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c index 1ddd1f21..e5e2e889 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_config.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c @@ -42,6 +42,13 @@ /* ldbm_config.c - Handles configuration information that is global to all ldbm instances. */ +/* Required to get portable printf/scanf format macros */ +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#else +#error Need to define portable format macros such as PRIu64 +#endif /* HAVE_INTTYPES_H */ + #include "back-ldbm.h" #include "dblayer.h" @@ -147,14 +154,14 @@ static void *ldbm_config_lookthroughlimit_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) (li->li_lookthroughlimit); + return (void *) ((uintptr_t)(li->li_lookthroughlimit)); } static int ldbm_config_lookthroughlimit_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); /* Do whatever we can to make sure the data is ok. */ @@ -169,14 +176,14 @@ static void *ldbm_config_mode_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) (li->li_mode); + return (void *) ((uintptr_t)(li->li_mode)); } static int ldbm_config_mode_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); /* Do whatever we can to make sure the data is ok. */ @@ -191,14 +198,14 @@ static void *ldbm_config_allidsthreshold_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) (li->li_allidsthreshold); + return (void *) ((uintptr_t)(li->li_allidsthreshold)); } static int ldbm_config_allidsthreshold_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); /* Do whatever we can to make sure the data is ok. */ @@ -365,14 +372,14 @@ static void *ldbm_config_maxpassbeforemerge_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) (li->li_maxpassbeforemerge); + return (void *) ((uintptr_t)(li->li_maxpassbeforemerge)); } static int ldbm_config_maxpassbeforemerge_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { if (val < 0) { @@ -391,14 +398,14 @@ static void *ldbm_config_dbncache_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) (li->li_new_dbncache); + return (void *) ((uintptr_t)(li->li_new_dbncache)); } static int ldbm_config_dbncache_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { if (val < 0) { @@ -454,14 +461,14 @@ static void *ldbm_config_db_durable_transactions_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_durable_transactions; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_durable_transactions); } static int ldbm_config_db_durable_transactions_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_durable_transactions = val; @@ -474,7 +481,7 @@ static void *ldbm_config_db_lockdown_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_lockdown; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_lockdown); } static int ldbm_config_db_lockdown_set( @@ -487,7 +494,7 @@ static int ldbm_config_db_lockdown_set( { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_lockdown = val; @@ -500,14 +507,14 @@ static void *ldbm_config_db_circular_logging_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_circular_logging; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_circular_logging); } static int ldbm_config_db_circular_logging_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_circular_logging = val; @@ -520,14 +527,14 @@ static void *ldbm_config_db_transaction_logging_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_enable_transactions; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_enable_transactions); } static int ldbm_config_db_transaction_logging_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_enable_transactions = val; @@ -560,14 +567,14 @@ static void *ldbm_config_db_checkpoint_interval_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_checkpoint_interval; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_checkpoint_interval); } static int ldbm_config_db_checkpoint_interval_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_checkpoint_interval = val; @@ -620,14 +627,14 @@ static void *ldbm_config_db_idl_divisor_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_idl_divisor; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_idl_divisor); } static int ldbm_config_db_idl_divisor_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_idl_divisor = val; @@ -660,14 +667,14 @@ static void *ldbm_config_db_spin_count_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_spin_count; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_spin_count); } static int ldbm_config_db_spin_count_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_spin_count = val; @@ -680,14 +687,14 @@ static void *ldbm_config_db_trickle_percentage_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_trickle_percentage; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_trickle_percentage); } static int ldbm_config_db_trickle_percentage_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (val < 0 || val > 100) { PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, @@ -707,14 +714,14 @@ static void *ldbm_config_db_verbose_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_verbose; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_verbose); } static int ldbm_config_db_verbose_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_verbose = val; @@ -727,14 +734,14 @@ static void *ldbm_config_db_debug_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_debug; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_debug); } static int ldbm_config_db_debug_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_debug = val; @@ -747,14 +754,14 @@ static void *ldbm_config_db_named_regions_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_named_regions; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_named_regions); } static int ldbm_config_db_named_regions_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_named_regions = val; @@ -767,14 +774,14 @@ static void *ldbm_config_db_private_mem_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_private_mem; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_private_mem); } static int ldbm_config_db_private_mem_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_private_mem = val; @@ -787,14 +794,14 @@ static void *ldbm_config_db_private_import_mem_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_private_import_mem; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_private_import_mem); } static int ldbm_config_db_private_import_mem_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_private_import_mem = val; @@ -820,7 +827,7 @@ static int ldbm_config_db_shm_key_set( { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_shm_key = val; @@ -833,7 +840,7 @@ static void *ldbm_config_db_lock_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_lock_config; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_lock_config); } @@ -859,14 +866,14 @@ static void *ldbm_config_db_cache_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_cache_config; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_cache_config); } static int ldbm_config_db_cache_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_cache_config = val; @@ -879,14 +886,14 @@ static void *ldbm_config_db_debug_checkpointing_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->db_debug_checkpointing; + return (void *) ((uintptr_t)li->li_dblayer_private->db_debug_checkpointing); } static int ldbm_config_db_debug_checkpointing_set(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->db_debug_checkpointing = val; @@ -922,7 +929,7 @@ static void *ldbm_config_import_cache_autosize_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *)arg; - return (void *)(li->li_import_cache_autosize); + return (void *)((uintptr_t)(li->li_import_cache_autosize)); } static int ldbm_config_import_cache_autosize_set(void *arg, void *value, char *errorbuf, @@ -931,7 +938,7 @@ static int ldbm_config_import_cache_autosize_set(void *arg, void *value, char *e struct ldbminfo *li = (struct ldbminfo *)arg; if (apply) - li->li_import_cache_autosize = (int)value; + li->li_import_cache_autosize = (int)((uintptr_t)value); return LDAP_SUCCESS; } @@ -939,7 +946,7 @@ static void *ldbm_config_cache_autosize_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *)arg; - return (void *)(li->li_cache_autosize); + return (void *)((uintptr_t)(li->li_cache_autosize)); } static int ldbm_config_cache_autosize_set(void *arg, void *value, char *errorbuf, @@ -948,7 +955,7 @@ static int ldbm_config_cache_autosize_set(void *arg, void *value, char *errorbuf struct ldbminfo *li = (struct ldbminfo *)arg; if (apply) - li->li_cache_autosize = (int)value; + li->li_cache_autosize = (int)((uintptr_t)value); return LDAP_SUCCESS; } @@ -956,7 +963,7 @@ static void *ldbm_config_cache_autosize_split_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *)arg; - return (void *)(li->li_cache_autosize_split); + return (void *)((uintptr_t)(li->li_cache_autosize_split)); } static int ldbm_config_cache_autosize_split_set(void *arg, void *value, char *errorbuf, @@ -965,7 +972,7 @@ static int ldbm_config_cache_autosize_split_set(void *arg, void *value, char *er struct ldbminfo *li = (struct ldbminfo *)arg; if (apply) - li->li_cache_autosize_split = (int)value; + li->li_cache_autosize_split = (int)((uintptr_t)value); return LDAP_SUCCESS; } @@ -1021,7 +1028,7 @@ static void *ldbm_config_serial_lock_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_fat_lock; + return (void *) ((uintptr_t)li->li_fat_lock); } static int ldbm_config_serial_lock_set(void *arg, void *value, char *errorbuf, @@ -1030,7 +1037,7 @@ static int ldbm_config_serial_lock_set(void *arg, void *value, char *errorbuf, struct ldbminfo *li = (struct ldbminfo *) arg; if (apply) { - li->li_fat_lock = (int) value; + li->li_fat_lock = (int) ((uintptr_t)value); } return LDAP_SUCCESS; @@ -1040,7 +1047,7 @@ static void *ldbm_config_legacy_errcode_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_legacy_errcode; + return (void *) ((uintptr_t)li->li_legacy_errcode); } static int ldbm_config_legacy_errcode_set(void *arg, void *value, char *errorbuf, @@ -1049,7 +1056,7 @@ static int ldbm_config_legacy_errcode_set(void *arg, void *value, char *errorbuf struct ldbminfo *li = (struct ldbminfo *) arg; if (apply) { - li->li_legacy_errcode = (int) value; + li->li_legacy_errcode = (int) ((uintptr_t)value); } return LDAP_SUCCESS; @@ -1099,7 +1106,7 @@ static void *ldbm_config_get_bypass_filter_test(void *arg) static int ldbm_config_set_use_vlv_index(void *arg, void *value, char *errorbuf, int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *) arg; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { if (val) { @@ -1115,7 +1122,7 @@ static void *ldbm_config_get_use_vlv_index(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_use_vlv; + return (void *) ((uintptr_t)li->li_use_vlv); } static int @@ -1174,7 +1181,7 @@ static void *ldbm_config_db_tx_max_get(void *arg) { struct ldbminfo *li = (struct ldbminfo *) arg; - return (void *) li->li_dblayer_private->dblayer_tx_max; + return (void *) ((uintptr_t)li->li_dblayer_private->dblayer_tx_max); } static int ldbm_config_db_tx_max_set( @@ -1187,7 +1194,7 @@ static int ldbm_config_db_tx_max_set( { struct ldbminfo *li = (struct ldbminfo *) arg; int retval = LDAP_SUCCESS; - int val = (int) value; + int val = (int) ((uintptr_t)value); if (apply) { li->li_dblayer_private->dblayer_tx_max = val; @@ -1409,17 +1416,17 @@ void ldbm_config_get(void *arg, config_info *config, char *buf) switch(config->config_type) { case CONFIG_TYPE_INT: - sprintf(buf, "%d", (int) config->config_get_fn(arg)); + sprintf(buf, "%d", (int) ((uintptr_t)config->config_get_fn(arg))); break; case CONFIG_TYPE_INT_OCTAL: - sprintf(buf, "%o", (int) config->config_get_fn(arg)); + sprintf(buf, "%o", (int) ((uintptr_t)config->config_get_fn(arg))); break; case CONFIG_TYPE_LONG: sprintf(buf, "%ld", (long) config->config_get_fn(arg)); break; case CONFIG_TYPE_SIZE_T: val = (size_t) config->config_get_fn(arg); - sprintf(buf, "%lu", val); + sprintf(buf, "%" PRIuPTR, val); break; case CONFIG_TYPE_STRING: /* Remember the get function for strings returns memory @@ -1429,7 +1436,7 @@ void ldbm_config_get(void *arg, config_info *config, char *buf) slapi_ch_free((void **)&tmp_string); break; case CONFIG_TYPE_ONOFF: - if ((int) config->config_get_fn(arg)) { + if ((int) ((uintptr_t)config->config_get_fn(arg))) { sprintf(buf, "on"); } else { sprintf(buf, "off"); @@ -1578,7 +1585,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc } /* convert 64 bit value to 32 bit value */ LL_L2I(int_val, llval); - retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod); + retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod); break; case CONFIG_TYPE_INT_OCTAL: if (use_default) { @@ -1586,7 +1593,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc } else { int_val = (int) strtol((char *)bval->bv_val, NULL, 8); } - retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod); + retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod); break; case CONFIG_TYPE_LONG: if (use_default) { @@ -1657,7 +1664,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc } else { int_val = !strcasecmp((char *) bval->bv_val, "on"); } - retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod); + retval = config->config_set_fn(arg, (void *) ((uintptr_t)int_val), err_buf, phase, apply_mod); break; } diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c index 51d71a35..56889e5d 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c @@ -136,7 +136,7 @@ ldbm_instance_config_readonly_get(void *arg) { ldbm_instance *inst = (ldbm_instance *)arg; - return (void *)inst->inst_be->be_readonly; + return (void *)((uintptr_t)inst->inst_be->be_readonly); } static void * @@ -165,7 +165,7 @@ ldbm_instance_config_require_index_get(void *arg) { ldbm_instance *inst = (ldbm_instance *)arg; - return (void *)inst->require_index; + return (void *)((uintptr_t)inst->require_index); } static int @@ -219,6 +219,7 @@ static int ldbm_instance_config_readonly_set(void *arg, void *value, char *errorbuf, int phase, int apply) { ldbm_instance *inst = (ldbm_instance *)arg; + uintptr_t pval = (uintptr_t)value; if (!apply) { return LDAP_SUCCESS; @@ -229,15 +230,15 @@ ldbm_instance_config_readonly_set(void *arg, void *value, char *errorbuf, int ph * but won't change them until the instance is un-busy again. */ if (! (inst->inst_flags & INST_FLAG_BUSY)) { - slapi_mtn_be_set_readonly(inst->inst_be, (int)value); + slapi_mtn_be_set_readonly(inst->inst_be, (int)pval); } - if ((int)value) { + if ((int)pval) { inst->inst_flags |= INST_FLAG_READONLY; } else { inst->inst_flags &= ~INST_FLAG_READONLY; } } else { - slapi_be_set_readonly(inst->inst_be, (int)value); + slapi_be_set_readonly(inst->inst_be, (int)pval); } return LDAP_SUCCESS; @@ -252,7 +253,7 @@ ldbm_instance_config_require_index_set(void *arg, void *value, char *errorbuf, i return LDAP_SUCCESS; } - inst->require_index = (int)value; + inst->require_index = (int)((uintptr_t)value); return LDAP_SUCCESS; } diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c index 36e84230..ee433970 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c @@ -578,10 +578,10 @@ mods_have_effect (Slapi_Entry *entry, Slapi_Mods *smods) */ for ( j = 0; j < smods->num_mods - 1; j++ ) { if ( (mod = smods->mods[j]) != NULL ) { - if ( (mod->mod_op & LDAP_MOD_REPLACE) == 0 || - mod->mod_vals.modv_bvals && - strcasecmp (mod->mod_type, "modifiersname") && - strcasecmp (mod->mod_type, "modifytime") ) { + if ( ((mod->mod_op & LDAP_MOD_REPLACE) == 0) || + (mod->mod_vals.modv_bvals && + strcasecmp (mod->mod_type, "modifiersname") && + strcasecmp (mod->mod_type, "modifytime") ) ) { goto done; } } @@ -589,9 +589,9 @@ mods_have_effect (Slapi_Entry *entry, Slapi_Mods *smods) if ( entry && entry->e_sdn.dn ) { for ( j = 0; j < smods->num_mods - 1; j++ ) { - if ( (mod = smods->mods[j]) != NULL && - strcasecmp (mod->mod_type, "modifiersname") && - strcasecmp (mod->mod_type, "modifytime") ) { + if ( ((mod = smods->mods[j]) != NULL) && + strcasecmp (mod->mod_type, "modifiersname") && + strcasecmp (mod->mod_type, "modifytime") ) { for ( attr = entry->e_attrs; attr; attr = attr->a_next ) { /* Mods have effect if at least a null-value-mod is * to actually remove an existing attribute diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c index e4f82b2f..2cf91f3a 100644 --- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c +++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c @@ -47,6 +47,13 @@ * code for db2index (is this still in use?) */ +/* Required to get portable printf/scanf format macros */ +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#else +#error Need to define portable format macros such as PRIu64 +#endif /* HAVE_INTTYPES_H */ + #include "back-ldbm.h" #include "vlv_srch.h" #include "dblayer.h" @@ -76,7 +83,7 @@ size_t import_get_index_buffer_size() { static PRIntn import_subcount_hash_compare_keys(const void *v1, const void *v2) { - return( ((ID)v1 == (ID)v2 ) ? 1 : 0); + return( ((ID)((uintptr_t)v1) == (ID)((uintptr_t)v2) ) ? 1 : 0); } static PRIntn import_subcount_hash_compare_values(const void *v1, const void *v2) @@ -86,7 +93,7 @@ static PRIntn import_subcount_hash_compare_values(const void *v1, const void *v2 static PLHashNumber import_subcount_hash_fn(const void *id) { - return (PLHashNumber) id; + return (PLHashNumber) ((uintptr_t)id); } void import_subcount_stuff_init(import_subcount_stuff *stuff) @@ -263,7 +270,7 @@ int import_subcount_mother_init(import_subcount_stuff *mothers, ID parent_id, size_t count) { PR_ASSERT(NULL == PL_HashTableLookup(mothers->hashtable,(void*)parent_id)); - PL_HashTableAdd(mothers->hashtable,(void*)parent_id,(void*)count); + PL_HashTableAdd(mothers->hashtable,(void*)((uintptr_t)parent_id),(void*)count); return 0; } @@ -276,7 +283,7 @@ static int import_subcount_mothers_lookup(import_subcount_stuff *mothers, *count = 0; /* Lookup hash table for ID */ stored_count = (size_t)PL_HashTableLookup(mothers->hashtable, - (void*)parent_id); + (void*)((uintptr_t)parent_id)); /* If present, return the count found */ if (0 != stored_count) { *count = stored_count; @@ -292,11 +299,11 @@ int import_subcount_mother_count(import_subcount_stuff *mothers, ID parent_id) /* Lookup the hash table for the target ID */ stored_count = (size_t)PL_HashTableLookup(mothers->hashtable, - (void*)parent_id); + (void*)((uintptr_t)parent_id)); PR_ASSERT(0 != stored_count); /* Increment the count */ stored_count++; - PL_HashTableAdd(mothers->hashtable, (void*)parent_id, (void*)stored_count); + PL_HashTableAdd(mothers->hashtable, (void*)((uintptr_t)parent_id), (void*)stored_count); return 0; } @@ -320,7 +327,7 @@ static int import_update_entry_subcount(backend *be, ID parentid, * let's do it so we can reuse the modify routines) */ cache_lock_entry( &inst->inst_cache, e ); modify_init(&mc,e); - sprintf(value_buffer,"%lu",sub_count); + sprintf(value_buffer,"%" PRIuPTR,sub_count); /* attr numsubordinates could already exist in the entry, let's check whether it's already there or not */ isreplace = (attrlist_find(e->ep_entry->e_attrs, numsubordinates) != NULL); @@ -761,12 +768,12 @@ ldbm_back_ldbm2ldif( Slapi_PBlock *pb ) int appendmode = 0; int appendmode_1 = 0; int noversion = 0; - ID lastid; + ID lastid = 0; int task_flags; Slapi_Task *task; int run_from_cmdline = 0; char *instance_name; - ldbm_instance *inst; + ldbm_instance *inst = NULL; int str2entry_options= 0; int retry; int we_start_the_backends = 0; @@ -1812,7 +1819,6 @@ err_out: dbc->c_close(dbc); } if (return_value < 0) {/* error case: undo vlv indexing */ - struct vlvIndex *vlvip = NULL; /* if jumped to out due to an error, vlv lock has not been released */ for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) { vlvIndex_go_offline(pvlv[vlvidx], be); diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c index 17d8ac03..8282d0d3 100644 --- a/ldap/servers/slapd/back-ldbm/monitor.c +++ b/ldap/servers/slapd/back-ldbm/monitor.c @@ -42,6 +42,13 @@ /* monitor.c - ldbm backend monitor function */ +/* Required to get portable printf/scanf format macros */ +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#else +#error Need to define portable format macros such as PRIu64 +#endif /* HAVE_INTTYPES_H */ + #include "back-ldbm.h" #include "dblayer.h" /* XXXmcs: not sure this is good to do... */ #include <sys/stat.h> @@ -117,9 +124,9 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e, MSET("entryCacheTries"); sprintf(buf, "%lu", (unsigned long)(100.0*(double)hits / (double)(tries > 0 ? tries : 1))); MSET("entryCacheHitRatio"); - sprintf(buf, "%lu", size); + sprintf(buf, "%" PRIuPTR, size); MSET("currentEntryCacheSize"); - sprintf(buf, "%lu", maxsize); + sprintf(buf, "%" PRIuPTR, maxsize); MSET("maxEntryCacheSize"); sprintf(buf, "%ld", nentries); MSET("currentEntryCacheCount"); diff --git a/ldap/servers/slapd/back-ldbm/parents.c b/ldap/servers/slapd/back-ldbm/parents.c index 7e470241..5fb2fc1f 100644 --- a/ldap/servers/slapd/back-ldbm/parents.c +++ b/ldap/servers/slapd/back-ldbm/parents.c @@ -44,6 +44,13 @@ #include "back-ldbm.h" +/* Required to get portable printf/scanf format macros */ +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#else +#error Need to define portable format macros such as PRIu64 +#endif /* HAVE_INTTYPES_H */ + char *numsubordinates = "numsubordinates"; char *hassubordinates = "hassubordinates"; @@ -130,7 +137,7 @@ int parent_update_on_childchange(modify_context *mc,int op, size_t *new_sub_coun else { char value_buffer[20]; /* enough digits for 2^64 children */ - sprintf(value_buffer,"%lu", current_sub_count); + sprintf(value_buffer,"%" PRIuPTR, current_sub_count); slapi_mods_add(smods, mod_op | LDAP_MOD_BVALUES, numsubordinates, strlen(value_buffer), value_buffer); } ret = modify_apply_mods(mc,smods); /* smods passed in */ diff --git a/ldap/servers/slapd/back-ldbm/perfctrs.c b/ldap/servers/slapd/back-ldbm/perfctrs.c index 458084c7..c6affe36 100644 --- a/ldap/servers/slapd/back-ldbm/perfctrs.c +++ b/ldap/servers/slapd/back-ldbm/perfctrs.c @@ -296,7 +296,7 @@ void perfctrs_update(perfctrs_private *priv, DB_ENV *db_env) return; } /* Call libdb to get the various stats */ - if (NULL != db_env->lg_handle) + if (DB_USES_LOGGING(db_env)) { DB_LOG_STAT *logstat = NULL; ret = LOG_STAT(db_env,&logstat,0,malloc); @@ -307,7 +307,7 @@ void perfctrs_update(perfctrs_private *priv, DB_ENV *db_env) } free(logstat); } - if (NULL != db_env->tx_handle) + if (DB_USES_TRANSACTIONS(db_env)) { DB_TXN_STAT *txnstat = NULL; ret = TXN_STAT(db_env, &txnstat, 0, malloc); @@ -320,7 +320,7 @@ void perfctrs_update(perfctrs_private *priv, DB_ENV *db_env) if (txnstat) free(txnstat); } - if (NULL != db_env->lk_handle) + if (DB_USES_LOCKING(db_env)) { DB_LOCK_STAT *lockstat = NULL; ret = LOCK_STAT(db_env,&lockstat,0,malloc); @@ -338,7 +338,7 @@ void perfctrs_update(perfctrs_private *priv, DB_ENV *db_env) } free(lockstat); } - if (NULL != db_env->mp_handle) + if (DB_USES_MPOOL(db_env)) { DB_MPOOL_STAT *mpstat = NULL; ret = MEMP_STAT(db_env,&mpstat,NULL,0,malloc); diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c index 0e940903..72c84530 100644 --- a/ldap/servers/slapd/bind.c +++ b/ldap/servers/slapd/bind.c @@ -103,7 +103,7 @@ is_root_dn_pw( const char *dn, const Slapi_Value *cred ) rv = slapi_pw_find_sv( rdnpwvals, cred ) == 0; value_done(&rdnpwbv); } - slapi_ch_free( (void **) &rootpw ); + slapi_ch_free_string( &rootpw ); return rv; } @@ -787,6 +787,6 @@ slapi_add_auth_response_control( Slapi_PBlock *pb, const char *binddn ) } if ( NULL != dnbuf_dynamic ) { - slapi_ch_free( (void **)&dnbuf_dynamic ); + slapi_ch_free_string( &dnbuf_dynamic ); } } diff --git a/ldap/servers/slapd/config.c b/ldap/servers/slapd/config.c index fe62e9b1..8c0c67eb 100644 --- a/ldap/servers/slapd/config.c +++ b/ldap/servers/slapd/config.c @@ -566,11 +566,11 @@ slapd_bootstrap_config(const char *configdir) } } - slapi_ch_free((void **)&buf); + slapi_ch_free_string(&buf); } bail: - slapi_ch_free((void **)&buf); + slapi_ch_free_string(&buf); return rc; } diff --git a/ldap/servers/slapd/configdse.c b/ldap/servers/slapd/configdse.c index d8151a3c..317c78db 100644 --- a/ldap/servers/slapd/configdse.c +++ b/ldap/servers/slapd/configdse.c @@ -102,7 +102,7 @@ isASyntaxOrMrPluginOrPss(Slapi_Entry *e) retval = (ptype && !strcasecmp(ptype, "pwdstoragescheme")); if (!retval) retval = (ptype && !strcasecmp(ptype, "reverpwdstoragescheme")); - slapi_ch_free((void**)&ptype); + slapi_ch_free_string(&ptype); return retval; } @@ -178,7 +178,7 @@ read_config_dse (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int be = slapi_get_next_backend (cookie); } - slapi_ch_free ((void **)&cookie); + slapi_ch_free_string (&cookie); /* show be_type */ attrlist_delete( &e->e_attrs, "nsslapd-betype"); @@ -195,7 +195,7 @@ read_config_dse (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int be = slapi_get_next_backend(cookie); } - slapi_ch_free ( (void **) &cookie); + slapi_ch_free_string (&cookie); /* show private suffixes */ attrlist_delete ( &e->e_attrs, "nsslapd-privatenamespaces"); @@ -222,7 +222,7 @@ read_config_dse (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int be = slapi_get_next_backend(cookie); } - slapi_ch_free ((void **) &cookie); + slapi_ch_free_string (&cookie); /* show syntax plugins */ attrlist_delete ( &e->e_attrs, CONFIG_PLUGIN_ATTRIBUTE ); @@ -432,7 +432,7 @@ finish_and_return: /* if the password has been set, it will be hashed */ if ((pwd = config_get_rootpw()) != NULL) { slapi_entry_attr_set_charptr(e, CONFIG_ROOTPW_ATTRIBUTE, pwd); - slapi_ch_free((void**)&pwd); + slapi_ch_free_string(&pwd); } *returncode= rc; diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c index ade87707..42cb7c6b 100644 --- a/ldap/servers/slapd/conntable.c +++ b/ldap/servers/slapd/conntable.c @@ -438,7 +438,7 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e) val.bv_len = strlen( bufptr ); attrlist_merge( &e->e_attrs, "connection", vals ); if (newbuf) { - slapi_ch_free((void **) &newbuf); + slapi_ch_free_string(&newbuf); } } PR_Unlock( ct->c[i].c_mutex ); diff --git a/ldap/servers/slapd/detach.c b/ldap/servers/slapd/detach.c index a547b50c..dc8f9881 100644 --- a/ldap/servers/slapd/detach.c +++ b/ldap/servers/slapd/detach.c @@ -127,7 +127,7 @@ detach( int slapd_exemode, int importexport_encrypt, } (void) chdir( errorlog ); config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, errorlog, errorbuf, 1); - slapi_ch_free((void**)&errorlog); + slapi_ch_free_string(&errorlog); } } else { /* calling config_set_workingdir to check for validity of directory, don't apply */ @@ -135,7 +135,7 @@ detach( int slapd_exemode, int importexport_encrypt, exit(1); } (void) chdir( workingdir ); - slapi_ch_free((void**)&workingdir); + slapi_ch_free_string(&workingdir); } if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) { diff --git a/ldap/servers/slapd/dse.c b/ldap/servers/slapd/dse.c index 49f12000..03630a3d 100644 --- a/ldap/servers/slapd/dse.c +++ b/ldap/servers/slapd/dse.c @@ -72,6 +72,13 @@ #include <pwd.h> #endif /* _WIN32 */ +/* Required to get portable printf/scanf format macros */ +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#else +#error Need to define portable format macros such as PRIu64 +#endif /* HAVE_INTTYPES_H */ + /* #define SLAPI_DSE_DEBUG */ /* define this to force trace log */ /* messages to always be logged */ @@ -463,6 +470,8 @@ dse_destroy(struct dse *pdse) slapi_ch_free((void **)&pdse); LDAPDebug( SLAPI_DSE_TRACELEVEL, "Removed [%d] entries from the dse tree.\n", nentries,0,0 ); + + return 0; /* no one checks this return value */ } /* @@ -603,7 +612,7 @@ dse_updateNumSubordinates(Slapi_Entry *entry, int op) struct berval val; vals[0] = &val; vals[1] = NULL; - sprintf(value_buffer,"%lu",current_sub_count); + sprintf(value_buffer,"%" PRIuPTR,current_sub_count); val.bv_val = value_buffer; val.bv_len = strlen (val.bv_val); switch(mod_op) diff --git a/ldap/servers/slapd/filter.c b/ldap/servers/slapd/filter.c index 9e0b1f0e..867b37fd 100644 --- a/ldap/servers/slapd/filter.c +++ b/ldap/servers/slapd/filter.c @@ -1280,7 +1280,7 @@ slapi_filter_to_string_internal( const struct slapi_filter *f, char *buf, size_t if(1 < *bufsize) { sprintf( buf, ")" ); - *bufsize--; + (*bufsize)--; } } break; @@ -1313,7 +1313,7 @@ slapi_filter_to_string_internal( const struct slapi_filter *f, char *buf, size_t if(1 < *bufsize) { sprintf( buf, ")" ); - *bufsize--; + (*bufsize)--; } } break; diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index eef97ecd..6b896835 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -5066,6 +5066,8 @@ config_set_value( { struct berval **values = 0; char *sval = 0; + int ival = 0; + uintptr_t pval; /* for null values, just set the attr value to the empty string */ @@ -5125,7 +5127,9 @@ config_set_value( case CONFIG_CONSTANT_INT: PR_ASSERT(value); /* should be a constant value */ - slapi_entry_attr_set_int(e, cgas->attr_name, (int)value); + pval = (uintptr_t)value; + ival = (int)pval; + slapi_entry_attr_set_int(e, cgas->attr_name, ival); break; case CONFIG_SPECIAL_SSLCLIENTAUTH: diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c index ac055e08..26d58369 100644 --- a/ldap/servers/slapd/log.c +++ b/ldap/servers/slapd/log.c @@ -2216,12 +2216,12 @@ log__needrotation(LOGFD fp, int logtype) { time_t curr_time; time_t log_createtime= 0; - time_t syncclock; + time_t syncclock = 0; int type = LOG_CONTINUE; int f_size = 0; int maxlogsize, nlogs; int rotationtime_secs = -1; - int sync_enabled, timeunit; + int sync_enabled = 0, timeunit = 0; if (fp == NULL) { return LOG_ROTATE; diff --git a/ldap/servers/slapd/log.h b/ldap/servers/slapd/log.h index dddc4875..8fea00bd 100644 --- a/ldap/servers/slapd/log.h +++ b/ldap/servers/slapd/log.h @@ -49,9 +49,13 @@ *************************************************************************/ #include <stdio.h> #ifdef LINUX +#ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE /* glibc2 needs this */ +#endif +#ifndef __USE_XOPEN #define __USE_XOPEN #endif +#endif #include <time.h> #include <stdarg.h> #include <sys/types.h> diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index f4e44f48..61ead86f 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -261,7 +261,6 @@ static void fix_ownership() { struct passwd* pw=NULL; - char dirname[MAXPATHLEN + 1]; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); @@ -630,7 +629,6 @@ main( int argc, char **argv) slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); daemon_ports_t ports_info = {0}; Slapi_Backend *be = NULL; - int init_ssl; #ifndef __LP64__ #if defined(__hpux) && !defined(__ia64) /* for static constructors */ @@ -2598,7 +2596,6 @@ slapd_exemode_dbverify() int return_value = 0; Slapi_PBlock pb; struct slapdplugin *backend_plugin; - slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); /* this should be the first time to be called! if the init order * is ever changed, these lines should be changed (or erased)! diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c index 5087c373..12e803ea 100644 --- a/ldap/servers/slapd/mapping_tree.c +++ b/ldap/servers/slapd/mapping_tree.c @@ -1998,7 +1998,7 @@ int slapi_mapping_tree_select(Slapi_PBlock *pb, Slapi_Backend **be, Slapi_Entry * will be transferred to the internal DSE backend */ if( sdn_is_nulldn(target_sdn) && - ((op_type == SLAPI_OPERATION_SEARCH) && (scope == LDAP_SCOPE_BASE) || + (((op_type == SLAPI_OPERATION_SEARCH) && (scope == LDAP_SCOPE_BASE)) || (op_type != SLAPI_OPERATION_SEARCH)) ) { mtn_unlock(); diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c index 4d3b13b5..42bf77e0 100644 --- a/ldap/servers/slapd/pblock.c +++ b/ldap/servers/slapd/pblock.c @@ -2873,7 +2873,7 @@ slapi_pblock_set( Slapi_PBlock *pblock, int arg, void *value ) case SLAPI_LDIF2DB_ENCRYPT: case SLAPI_DB2LDIF_DECRYPT: - pblock->pb_ldif_encrypt = (int)value; + pblock->pb_ldif_encrypt = *((int *)value); break; default: diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c index a5a0692d..eabdd042 100644 --- a/ldap/servers/slapd/saslbind.c +++ b/ldap/servers/slapd/saslbind.c @@ -297,7 +297,6 @@ static Slapi_Entry *ids_sasl_user_to_entry( int attrsonly = 0, scope = LDAP_SCOPE_SUBTREE; LDAPControl **ctrls = NULL; Slapi_Entry *entry = NULL; - Slapi_DN *sdn; char **attrs = NULL; int regexmatch = 0; char *base = NULL; diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c index 1f4d189f..3827d304 100644 --- a/ldap/servers/slapd/snmp_collator.c +++ b/ldap/servers/slapd/snmp_collator.c @@ -399,7 +399,6 @@ int snmp_collator_start() int err; char *statspath = config_get_rundir(); - char *lp = NULL; char *instdir = config_get_configdir(); char *instname = NULL; diff --git a/ldap/servers/slapd/statechange.h b/ldap/servers/slapd/statechange.h index c3946ee5..30438afb 100644 --- a/ldap/servers/slapd/statechange.h +++ b/ldap/servers/slapd/statechange.h @@ -78,7 +78,9 @@ typedef void (*api_statechange_unregister_all)(char *caller_id, caller_data_free #define STATECHANGE_VATTR_ENTRY_INVALIDATE 2 /* Vattr api caller data to be passed to statechange_register() */ +#ifdef DEFINE_STATECHANGE_STATICS static int vattr_global_invalidate = STATECHANGE_VATTR_GLOBAL_INVALIDATE; -static int vattr_entry_invalidate = STATECHANGE_VATTR_ENTRY_INVALIDATE; +/* static int vattr_entry_invalidate = STATECHANGE_VATTR_ENTRY_INVALIDATE; */ +#endif /* DEFINE_STATECHANGE_STATICS */ #endif /*_STATE_NOTIFY_H_*/ diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c index 67c93c16..3324dea2 100644 --- a/ldap/servers/slapd/task.c +++ b/ldap/servers/slapd/task.c @@ -193,6 +193,8 @@ int slapi_task_get_state(Slapi_Task *task) if (task) { return task->task_state; } + + return 0; /* return value not currently used */ } /* this changes the 'nsTaskStatus' value, which is transient (anything logged @@ -341,6 +343,8 @@ void * slapi_task_get_data(Slapi_Task *task) if (task) { return task->task_private; } + + return NULL; /* return value not currently used */ } /* @@ -371,6 +375,8 @@ int slapi_task_get_refcount(Slapi_Task *task) if (task) { return task->task_refcount; } + + return 0; /* return value not currently used */ } /* name is, for example, "import" */ diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c index 33037734..b2e1f764 100644 --- a/ldap/servers/slapd/tools/ldclt/ldapfct.c +++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c @@ -671,9 +671,9 @@ connectToServer ( */ tttctx->ldapCtx = ldapssl_init(mctx.hostname, mctx.port, 1); if (mctx.mode & VERY_VERBOSE) - printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%08x\n", + printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%p\n", mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port, - (unsigned int)tttctx->ldapCtx); + tttctx->ldapCtx); if (tttctx->ldapCtx == NULL) { printf ("ldclt[%d]: T%03d: Cannot ldapssl_init (%s, %d), errno=%d\n", @@ -689,14 +689,14 @@ connectToServer ( ret = ldapssl_enable_clientauth(tttctx->ldapCtx, "", mctx.keydbpin, mctx.cltcertname); if (mctx.mode & VERY_VERBOSE) printf - ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)", - mctx.pid, tttctx->thrdNum, (unsigned int)tttctx->ldapCtx, mctx.keydbpin, + ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)", + mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin, mctx.cltcertname); if (ret < 0) { printf - ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)", - mctx.pid, tttctx->thrdNum, (unsigned int)tttctx->ldapCtx, mctx.keydbpin, + ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)", + mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin, mctx.cltcertname); ldap_perror(tttctx->ldapCtx, "ldapssl_enable_clientauth"); fflush (stdout); @@ -709,9 +709,9 @@ connectToServer ( */ tttctx->ldapCtx = ldap_init (mctx.hostname, mctx.port); if (mctx.mode & VERY_VERBOSE) - printf ("ldclt[%d]: T%03d: After ldap_init (%s, %d), ldapCtx=0x%08x\n", + printf ("ldclt[%d]: T%03d: After ldap_init (%s, %d), ldapCtx=0x%p\n", mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port, - (unsigned int)tttctx->ldapCtx); + tttctx->ldapCtx); if (tttctx->ldapCtx == NULL) { printf ("ldclt[%d]: T%03d: Cannot ldap_init (%s, %d), errno=%d\n", @@ -805,7 +805,6 @@ connectToServer ( } else if ((mctx.mod2 & M2_SASLAUTH) && ((!(tttctx->binded)) || (mctx.mode & BIND_EACH_OPER))) { void *defaults; - LDAPControl **rctrls = NULL; char *my_saslauthid = NULL; if ( mctx.sasl_mech == NULL) { @@ -1836,9 +1835,9 @@ createMissingNodes ( */ tttctx->ldapCtx = ldapssl_init(mctx.hostname, mctx.port, 1); if (mctx.mode & VERY_VERBOSE) - printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%08x\n", + printf ("ldclt[%d]: T%03d: After ldapssl_init (%s, %d), ldapCtx=0x%p\n", mctx.pid, tttctx->thrdNum, mctx.hostname, mctx.port, - (unsigned int)tttctx->ldapCtx); + tttctx->ldapCtx); if (tttctx->ldapCtx == NULL) { printf ("ldclt[%d]: T%03d: Cannot ldapssl_init (%s, %d), errno=%d\n", @@ -1854,14 +1853,14 @@ createMissingNodes ( ret = ldapssl_enable_clientauth(tttctx->ldapCtx, "", mctx.keydbpin, mctx.cltcertname); if (mctx.mode & VERY_VERBOSE) printf - ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)", - mctx.pid, tttctx->thrdNum, (unsigned int)tttctx->ldapCtx, mctx.keydbpin, + ("ldclt[%d]: T%03d: After ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)", + mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin, mctx.cltcertname); if (ret < 0) { printf - ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)", - mctx.pid, tttctx->thrdNum, (unsigned int)tttctx->ldapCtx, mctx.keydbpin, + ("ldclt[%d]: T%03d: Cannot ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)", + mctx.pid, tttctx->thrdNum, tttctx->ldapCtx, mctx.keydbpin, mctx.cltcertname); fflush (stdout); return (-1); diff --git a/ldap/servers/slapd/tools/ldclt/scalab01.c b/ldap/servers/slapd/tools/ldclt/scalab01.c index 2228a852..3dc2bda8 100644 --- a/ldap/servers/slapd/tools/ldclt/scalab01.c +++ b/ldap/servers/slapd/tools/ldclt/scalab01.c @@ -524,8 +524,8 @@ scalab01_connectSuperuser (void) */ s1ctx.ldapCtx = ldapssl_init(mctx.hostname, mctx.port, 1); if (mctx.mode & VERY_VERBOSE) - printf ("ldclt[%d]: ctrl: ldapssl_init (%s, %d), ldapCtx=0x%08x\n", - mctx.pid, mctx.hostname, mctx.port, (unsigned int)s1ctx.ldapCtx); + printf ("ldclt[%d]: ctrl: ldapssl_init (%s, %d), ldapCtx=0x%p\n", + mctx.pid, mctx.hostname, mctx.port, s1ctx.ldapCtx); if (s1ctx.ldapCtx == NULL) { printf ("ldclt[%d]: ctrl: Cannot ldapssl_init (%s, %d), errno=%d\n", @@ -541,13 +541,13 @@ scalab01_connectSuperuser (void) ret = ldapssl_enable_clientauth(s1ctx.ldapCtx, "", mctx.keydbpin, mctx.cltcertname); if (mctx.mode & VERY_VERBOSE) printf - ("ldclt[%d]: ctrl: After ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)", - mctx.pid, (unsigned int)s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname); + ("ldclt[%d]: ctrl: After ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)", + mctx.pid, s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname); if (ret < 0) { printf - ("ldclt[%d]: ctrl: Cannot ldapssl_enable_clientauth (ldapCtx=0x%08x, %s, %s)", - mctx.pid, (unsigned int)s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname); + ("ldclt[%d]: ctrl: Cannot ldapssl_enable_clientauth (ldapCtx=0x%p, %s, %s)", + mctx.pid, s1ctx.ldapCtx, mctx.keydbpin, mctx.cltcertname); ldap_perror(s1ctx.ldapCtx, "ldapssl_enable_clientauth"); fflush (stdout); return (-1); @@ -561,8 +561,8 @@ scalab01_connectSuperuser (void) */ s1ctx.ldapCtx = ldap_init (mctx.hostname, mctx.port); if (mctx.mode & VERY_VERBOSE) - printf ("ldclt[%d]: ctrl: After ldap_init (%s, %d), ldapCtx=0x%08x\n", - mctx.pid, mctx.hostname, mctx.port, (unsigned int)s1ctx.ldapCtx); + printf ("ldclt[%d]: ctrl: After ldap_init (%s, %d), ldapCtx=0x%p\n", + mctx.pid, mctx.hostname, mctx.port, s1ctx.ldapCtx); if (s1ctx.ldapCtx == NULL) { printf ("ldclt[%d]: ctrl: Cannot ldap_init (%s, %d), errno=%d\n", diff --git a/ldap/servers/slapd/tools/ldif.c b/ldap/servers/slapd/tools/ldif.c index 5e4e63e2..bf100539 100644 --- a/ldap/servers/slapd/tools/ldif.c +++ b/ldap/servers/slapd/tools/ldif.c @@ -145,7 +145,7 @@ int main( int argc, char **argv ) perror( "realloc" ); return( 1 ); } - fgets(buf+curlen, maxlen/2 + 1, stdin); + (void)fgets(buf+curlen, maxlen/2 + 1, stdin); } /* we have a full line, chop potential newline and turn into ldif */ if( buf[curlen-1] == '\n' ) diff --git a/ldap/servers/slapd/tools/mmldif.c b/ldap/servers/slapd/tools/mmldif.c index 19b039b1..579605a9 100644 --- a/ldap/servers/slapd/tools/mmldif.c +++ b/ldap/servers/slapd/tools/mmldif.c @@ -816,7 +816,7 @@ readrec(edfFILE * edf1, attrib1_t ** attrib) lookahead = fgetc(edf1->fp); if (lookahead != ' ') break; - fgets(line, sizeof(line), edf1->fp); + (void)fgets(line, sizeof(line), edf1->fp); len = strlen(line); for (lptr = line+len-1; len; len--, lptr--) { if ((*lptr != '\n') && (*lptr != '\r')) @@ -854,7 +854,7 @@ readrec(edfFILE * edf1, attrib1_t ** attrib) lookahead = fgetc(edf1->fp); if (lookahead != ' ') break; - fgets(line, sizeof(line), edf1->fp); + (void)fgets(line, sizeof(line), edf1->fp); len = strlen(line); for (lptr = line+len-1; len; len--, lptr--) { if ((*lptr != '\n') && (*lptr != '\r')) diff --git a/ldap/servers/slapd/tools/pwenc.c b/ldap/servers/slapd/tools/pwenc.c index 16aa4fc4..d18622eb 100644 --- a/ldap/servers/slapd/tools/pwenc.c +++ b/ldap/servers/slapd/tools/pwenc.c @@ -145,7 +145,7 @@ init_config(char *configdir) fprintf( stderr, "%s\n", errorbuf ); return( NULL ); } - slapi_ch_free((void **)&abs_configdir); + slapi_ch_free_string(&abs_configdir); slapdFrontendConfig = getFrontendConfig(); if (0 == slapd_config(slapdFrontendConfig->configdir, configfile)) { @@ -169,11 +169,9 @@ main( argc, argv ) struct pw_scheme *pwsp, *cmppwsp; extern int optind; char *cpwd = NULL; /* candidate password for comparison */ - char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE]; slapdFrontendConfig_t *slapdFrontendConfig = NULL; char *opts = "Hs:c:D:"; - char *configdir = NULL; name = argv[ 0 ]; pwsp = cmppwsp = NULL; @@ -409,7 +407,7 @@ slapd_config(const char *configdir, const char *givenconfigfile) rc= 1; /* OK */ } - slapi_ch_free((void **)&buf); + slapi_ch_free_string(&buf); } return rc; diff --git a/ldap/servers/slapd/tools/rsearch/infadd.c b/ldap/servers/slapd/tools/rsearch/infadd.c index 0ee08165..607381a3 100644 --- a/ldap/servers/slapd/tools/rsearch/infadd.c +++ b/ldap/servers/slapd/tools/rsearch/infadd.c @@ -344,11 +344,12 @@ int main(int argc, char **argv) } if (lmtCount && ntotal >= lmtCount) { if (!quiet) { + tmpv = (double)ntotal*1000.0/(counter*sampleInterval); fprintf(stdout, "Total added records: %d, Average rate: %7.2f/thrd, " "%6.2f/sec = %6.4fmsec/op\n", ntotal, (double)ntotal/(double)numThreads, - (tmpv = (double)ntotal*1000.0/(counter*sampleInterval)), + tmpv, (double)1000.0/tmpv); } exit(1); diff --git a/ldap/servers/slapd/tools/rsearch/rsearch.c b/ldap/servers/slapd/tools/rsearch/rsearch.c index 313eed3d..621a22e5 100644 --- a/ldap/servers/slapd/tools/rsearch/rsearch.c +++ b/ldap/servers/slapd/tools/rsearch/rsearch.c @@ -501,12 +501,12 @@ int main(int argc, char** argv) exit(0); } if (timeLimit && (lifeTime >= timeLimit)) { - double tmpv; + double tmpv = (val + sumVal)/counter; if (verbose) printf("%d sec >= %d\n", lifeTime, timeLimit); printf("Final Average rate: " "%6.2f/sec = %6.4fmsec/op, total:%6u\n", - (tmpv = (val + sumVal)/counter), + tmpv, (double)1000.0/tmpv, total); exit(0); diff --git a/ldap/servers/slapd/tools/rsearch/searchthread.c b/ldap/servers/slapd/tools/rsearch/searchthread.c index 48430439..1ef0b7a2 100644 --- a/ldap/servers/slapd/tools/rsearch/searchthread.c +++ b/ldap/servers/slapd/tools/rsearch/searchthread.c @@ -501,7 +501,7 @@ void search_start(void *v) { SearchThread *st = (SearchThread *)v; PRIntervalTime timer; - int notBound = 1, res, searches = 0; + int notBound = 1, res = LDAP_SUCCESS, searches = 0; PRUint32 span; st->alive = 1; diff --git a/ldap/servers/slapd/uuid.c b/ldap/servers/slapd/uuid.c index 92e22f42..43aa003f 100644 --- a/ldap/servers/slapd/uuid.c +++ b/ldap/servers/slapd/uuid.c @@ -361,8 +361,8 @@ static int uuid_create_st(guid_t *uuid) /* uuid_create -- multithreaded generation */ static int uuid_create_mt(guid_t *uuid) { - uuid_time_t timestamp; - unsigned16 clock_seq; + uuid_time_t timestamp = 0; + unsigned16 clock_seq = 0; /* just bumps time sequence number. the actual time calls are made by a uuid_update_state */ diff --git a/ldap/servers/snmp/ldap-agent.h b/ldap/servers/snmp/ldap-agent.h index f6bddbd0..28f3cc2a 100644 --- a/ldap/servers/snmp/ldap-agent.h +++ b/ldap/servers/snmp/ldap-agent.h @@ -47,7 +47,27 @@ extern "C" { #endif +/* net-snmp-config.h defines + all of these unconditionally - so we undefine + them here to make the compiler warnings shut up + hopefully we don't need the real versions + of these, but then with no warnings the compiler + will just silently redefine them to the wrong + ones anyway + Then undefine them after the include so that + our own local defines will take effect +*/ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION #include <net-snmp/net-snmp-config.h> +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/net-snmp-agent-includes.h> #include <net-snmp/library/snmp_assert.h> |