summaryrefslogtreecommitdiffstats
path: root/ldap/servers/slapd/tools
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2008-10-08 17:29:05 +0000
committerRich Megginson <rmeggins@redhat.com>2008-10-08 17:29:05 +0000
commitb3797a8704696ed77b69a042e75ce5553e24b68b (patch)
treeeae8ee4c9ce9e46c010334d72e942d17ee71f768 /ldap/servers/slapd/tools
parent9506a1d704ce99945e12dc797f932b4a50a0da24 (diff)
downloadds-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/servers/slapd/tools')
-rw-r--r--ldap/servers/slapd/tools/ldclt/ldapfct.c29
-rw-r--r--ldap/servers/slapd/tools/ldclt/scalab01.c16
-rw-r--r--ldap/servers/slapd/tools/ldif.c2
-rw-r--r--ldap/servers/slapd/tools/mmldif.c4
-rw-r--r--ldap/servers/slapd/tools/pwenc.c6
-rw-r--r--ldap/servers/slapd/tools/rsearch/infadd.c3
-rw-r--r--ldap/servers/slapd/tools/rsearch/rsearch.c4
-rw-r--r--ldap/servers/slapd/tools/rsearch/searchthread.c2
8 files changed, 32 insertions, 34 deletions
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;